cereal 1,524 Nearly a Senior Poster Featured Poster

No, open the main index.php file, in the first lines, depending on the CodeIgniter version in use, you should see (for version 2.*):

define('ENVIRONMENT', 'development');

while, for version 3.*:

define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'development');

Be sure the value is development.

Note

With version 3.* it's possible to push a server environment variable to define the environment through the .htaccess file. For example:

SetEnvIf Host www.domain.tld$ CI_ENV=production

The same can be applied at server config, so if you're using CI 3.* be sure your hosting is not setting this by default. It can be overridden by replacing the define() with the CI 2.* version code string.

cereal 1,524 Nearly a Senior Poster Featured Poster

Ok then what happens to the page? Is it blank? Try to change the ENVIRONMENT to development that should show the errors, this can be set in the index.php page, otherwise check CI error log.

cereal 1,524 Nearly a Senior Poster Featured Poster

Same for me, I just received a notification sent 4 days ago.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi Dani,

I pushed the cash button one month ago and since then the status is Last Cash Out: Pending for $21.63, is there something wrong? I remember there was a bug related to the reward system:

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, there are two possible reasons:

  1. the url helper is not loaded
  2. missing trailing slash in application/config/config.php $config['base_url']:

    $config['base_url'] = 'http://domain.tld'; # <- missing final /
    
cereal 1,524 Nearly a Senior Poster Featured Poster

Ok, thanks for the update!

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,
in my opinion you don't strictly need a new table. To generate a live rank you could add an internal counter to the query, select the results as a subquery and finally display the result set. For example:

SELECT @a := @a + 1 AS `rank`,
       `sub`.`student_code`,
       `sub`.`total`
FROM   (SELECT @a := 0) AS v,
       (SELECT `student_code`,
               SUM(`mark`) AS `total`
        FROM   `results`
        GROUP  BY `student_code`
        ORDER  BY `total` DESC) AS sub; 

It returns something like:

+------+--------------+--------+
| rank | student_code | total  |
+------+--------------+--------+
|    1 |            5 | 428.19 |
|    2 |            3 | 396.83 |
|    3 |            2 | 351.29 |
|    4 |            4 | 271.04 |
|    5 |            1 | 124.56 |
+------+--------------+--------+
5 rows in set (0.00 sec)

But you can do the same in PHP by adding a counter while looping the results, at database level just order by the total, in descending order.

Also, by adding a datetime column (for example created_at) to each mark you could perform rank searches in defined ranges:

SELECT @a := @a + 1 AS `rank`,
       `sub`.`student_code`,
       `sub`.`total`
FROM   (SELECT @a := 0) AS v,
       (SELECT `student_code`,
               SUM(`mark`) AS `total`
        FROM   `results`
        WHERE  `created_at` BETWEEN '2015-03-01' AND '2015-03-31'
        GROUP  BY `student_code`
        ORDER  BY `total` DESC) AS sub;

Live example: http://sqlfiddle.com/#!9/1ff51/1

Then, if you want to save these results, just perform an INSERT ... SELECT query:

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

remove the WHERE condition and add GROUP BY student_code to the select statement and it should work fine, but consider that you could use a view, otherwise when you add something else to the results table you have to check and update the totals table.

Examples:

INSERT INTO `results`(`student_code`, `mark`) VALUES(1, '10.20'), (1, '5.30'), (2, '7.30'), (3, '1.25'), (2, '1.25'), (3, '100.99');

INSERT INTO `totals`(`student_code`, `total`) SELECT `student_code`, SUM(`mark`) AS total FROM `results` GROUP BY `results`.`student_code`;

Or:

CREATE VIEW `v_totals` AS SELECT `student_code`, SUM(`mark`) AS `total` FROM `results` GROUP BY `student_code`;

Live examples: http://sqlfiddle.com/#!9/552f4/1

cereal 1,524 Nearly a Senior Poster Featured Poster

There are two problems here:

$query =  $query1." ".UNION." ".$query2;
$resultID = mysql_query($query);

First: UNION will be evaluated by PHP as a constant, not as a string part of a query, the correct syntax would be:

$query = "$query1 UNION $query2";

Second: the last query will connect to the last available connection, i.e. to $link2 and so it will return values only from the last database. You could loop the results you got from the queries (1 and 2) into an array, through PHP:

$results = array();
$i = 0;

while($row = $result1)
{
    $results[$i]['phone'] = $row['phone'];
    $results[$i]['name'] = $row['name'];
    $i++;
}

while($row = $result2)
{
    $results[$i]['phone'] = $row['phone'];
    $results[$i]['name'] = $row['name'];
    $i++;
}

by using PDO or MySQLi it would be even simplier because you can get the full result set and simply use an array_merge() which would be faster than the loops.

Or use federated tables: in this case one of the databases connects the other and reads the data as it would be in local, that way your current code would work fine:

cereal 1,524 Nearly a Senior Poster Featured Poster

A prepared statement consists in a group of SQL commands submitted by the MySQL client:

These are supported by both PDO and MYSQLi. When you see the -> it means you're accessing an object, but the same can be done with the procedural style.

Almost always the PHP documentation offers the examples for both styles, check this example:

<?php
$link = mysqli_connect("localhost", "my_user", "my_password", "world");

/* check connection */
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
}

$city = "Amersfoort";

/* create a prepared statement */
$stmt = mysqli_stmt_init($link);
if (mysqli_stmt_prepare($stmt, 'SELECT District FROM City WHERE Name=?')) {

    /* bind parameters for markers */
    mysqli_stmt_bind_param($stmt, "s", $city);

    /* execute query */
    mysqli_stmt_execute($stmt);

    /* bind result variables */
    mysqli_stmt_bind_result($stmt, $district);

    /* fetch value */
    mysqli_stmt_fetch($stmt);

    printf("%s is in district %s\n", $city, $district);

    /* close statement */
    mysqli_stmt_close($stmt);
}

/* close connection */
mysqli_close($link);

?>

Source: http://php.net/manual/en/mysqli-stmt.prepare.php#example-1887

cereal 1,524 Nearly a Senior Poster Featured Poster

@phoenix

that's why I was writing about prepared statements, the quote is not supposed to be submitted to the query, unless is escaped correctly, and that's why the security test was generating the syntax error, they supposed you where using quotes in your query:

"SELECT * FROM items WHERE ITEM = '$ITEM'"

So they tried to escape them by submitting the number with a quote:

71'

To get a query like this:

"SELECT * FROM items WHERE ITEM = '71''"

Which seems to not make sense but if you add other instructions right after the quote, you could execute whatever you want:

71' OR '1'='1

for example. At the end the query will look like this:

"SELECT * FROM items WHERE ITEM = '71' OR '1'='1'"

To solve with MySQLi you can use prepared statements or you can escape the input with mysqli_real_escape_string():

$id = mysqli_real_escape_string($con, $id);
$item_query = mysqli_query($con ,"SELECT * FROM product WHERE item_id = $id ");

Docs:

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi all!

@phoenix

I suppose you have a form with an input field like this:

<input type="text" name="ITEM" id="ITEM">

From which you set the $ITEM variable, so try to send something different from the expected value, you expect an integer. Send this instead:

1 OR 1=1

It will probably return all the rows in the item table. This is an SQL injection and it means the input submitted to the query function is not sanitized nor validated, so an attacker can try to run other queries and get some extra information or execute remote code.

This is the reason you should use prepared statements, for example:

$stmt = $mysqli->prepare("SELECT * FROM item WHERE id = ?");
$stmt->bind_param('i', $ITEM);
$stmt->execute();

$results = $stmt->get_result();

# looping results
while($row = $results->fetch_assoc())

For more examples check this code snippet by pritaeas:

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

I would like to help, if you can, send me the link.

cereal 1,524 Nearly a Senior Poster Featured Poster

My local system being my cell phone ?

No, it should be a computer in your local network, this will use a script to get the information from the remote database, then it will connect to your cell phone, through the script you posted in your first post, basically it would look like this:

    # pulling from remote

    +----------------+       +--------+       +---------------------+
    |Remote Database |  <--> | Router |  <--> |     Local system    |
    +----------------+       +--------+       |[PC with PHP scripts]|
                                              +---------------------+

                                                      +            
                                                      |            
                                                      |            
                                                      v            

                                                +------------+     
                                                |SMS Gateway |     
                                                |  [Phone]   |     
                                                +------------+     

If, instead, you redirect the connection from the router to the SMS gateway, then you won't need a local server and you could submit the input directly to the gateway:

    # receiving from remote

    +----------------+        +----------------+      +-----------------+
    |Remote Database |  +-->  | Router         | +--> | SMS Gateway     |
    +----------------+        | Public IP:PORT |      | Private IP:PORT |
                              +----------------+      +-----------------+

As suggested in my first post check the documentation of your router about the NAT or DMZ configuration, and if you need help tell us model and version.

A part this I cannot help much further, for me this is more a network issue rather than programming. Maybe you want to ask support to the Networking forum:

anitg commented: Very clear explanation +0
cereal 1,524 Nearly a Senior Poster Featured Poster

No problem, with patience we can try to fix it.

Until the SMS gateway is behind your router the only methods to access it directly are those already suggested in my previous answer.

There are other solutions among these: you could create a feed (for example an RSS feed) in the remote server to be read by your local system, or simply query the remote database, for example, every N minutes. The pros of this solution is that the remote server doesn't need to know the IP of the local server, nor your public IP. The cons is that the execution is not synchronous.

cereal 1,524 Nearly a Senior Poster Featured Poster

Ok, when connecting to your public IP from remote you're connnecting to the router, what you have to do is to redirect the connection from the router to the internal server IP, this is defined as network address translation (NAT).

In practice in your router there should be an interface in which you can define the internal IP and the port, so that the request comining from remote acts like this:

REMOTE_REQUEST ===> [ROUTER]PUBLIC_IP:PORT ===> [SMS SERVER]INTERNAL_IP:PORT

Another solution is to set the SMS server in the DMZ and expose it directly to the internet:

Check the documentation of your router, if you need help let us know the model and version.

cereal 1,524 Nearly a Senior Poster Featured Poster

It could be the link, the above would work only in the intranet. To connect to an external remote server, you must point the server to use the public IP. Anyway to get some extra information add:

curl_setopt($curl_handle, CURLOPT_VERBOSE, true);

That will print the requests and responses of both sides.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, have you tried the solution offered in their forum? Here's the link:

cereal 1,524 Nearly a Senior Poster Featured Poster

The date_diff() function requires two arguments, also both must be resources of the DateTimeInterface, if you pass a string, as in your example, the function will fail.

So, you must write:

<?php

    $date_a = '2015-04-01';
    $date_b = '2015-03-25';

    $dt_a = new Datetime($date_a);
    $dt_b = new Datetime($date_b);

    $interval = date_diff($dt_a, $dt_b);
    echo $interval->format('%R%a days'); # -7 days

Or use the object style, like your previous example. Note that the result is an object that cannot be converted directly to a string, so you must use the format() method.

cereal 1,524 Nearly a Senior Poster Featured Poster

Add or die(mysql_error()); to the insert query, it seems correct to me, so if it fails is because there could some constraint that is not satisfied, like a NOT NULL column not involved in the insert process.

So try:

mysql_query("INSERT INTO improvement_plan (Responsible2,Progressid) VALUES ('" . $responsible2 . "','" . $_SESSION['Progressid'] . "')") or die(mysql_error());

What error is returning PHPMailer? Are you sure this is correct?

$mail->SMTPAuth = false;

Usually when using an SMTP you should define username, password, encryption type, port to connect. At the moment I see that the sender will be the email defined in the $_SESSION array:

$mail->From =($_SESSION['Email']);          # sender
$mail->FromName =($_SESSION['Username']);
$mail->AddAddress('$cemail2');

So if the SMTP requires authentication, then you have to provide those values in relation to the sender email and this email must be allowed to connect that specific SMTP server, otherwise it will not work. An example of setup:

$mail->isSMTP();                        // Set mailer to use SMTP
$mail->Host = 'smtp1.example.com';      // Specify main and backup SMTP servers
$mail->SMTPAuth = true;                 // Enable SMTP authentication
$mail->Username = 'user@example.com';   // SMTP username
$mail->Password = 'secret';             // SMTP password
$mail->SMTPSecure = 'tls';              // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587;
cereal 1,524 Nearly a Senior Poster Featured Poster

You're welcome. Let's try to simplify the task:

  1. you have a form to select a responsible, populated by user table
  2. basing on selection you get an email address from user table
  3. you insert the improvement_plan table
  4. you finally send an email

You're trying to do this on the same page, but it seems you're mixing the two different states of the script:

  1. the starting state: when the user has not chosen a responsible and the form has not been submitted;
  2. the ending state: when the form have been submitted, at this point you have sent the email, all the information you're trying to print to the client will be sent to the browser only after the script has been executed and on reload the new information will disappear.

So, as example, your script should look like this:

<?php

    session_start();

    # database connection
    $cn = mysql_connect("localhost","user","") or die(mysql_error());
    mysql_select_db("p", $cn) or die(mysql_error());

    # work on form POST request
    if(isset($_POST['Notify2']))
    {
        $responsible = filter_input(INPUT_POST, 'responsible2', FILTER_SANITIZE_STRING);

        # get the email address from user table
        $qry1 = mysql_query("SELECT * FROM user WHERE Position = '$responsible'");
        $row  = mysql_fetch_assoc($qry1);

        # set the variables
        $cemail2    = $row['Email'];
        $position   = $row['Position'];
        $progressID = $_SESSION['Progressid'];

        # insert into improvement_plan table
        $insert = mysql_query("INSERT INTO improvement_plan (Responsible2, Progressid) VALUES('$position', '$progressID')") or die(mysql_error());
        $Ipid = mysql_insert_id();

        # send the email
        if( ! empty($Ipid))
        {
            $message = "New improvement plan added successfully";

            # PHPMailer code here
            require 'PHPMailer_5.2.4/PHPMailer_5.2.4/class.phpmailer.php';

            $mail = new PHPMailer;
            $mail->IsSMTP();
            $mail->Host         = 'smtp.office365.com';     // Specify …
cereal 1,524 Nearly a Senior Poster Featured Poster

Hi! If using Ubuntu then open the terminal and type:

locate java.desktop

It should find few entries under /usr/share/app-install/desktop/, these are the files used to generate the desktop entries. If you don't get results try to update the mlocate database through the command updatedb. If you get some results the one you need is:

openjdk-7-jre\:openjdk-7-java.desktop

So open the mimeapps.list file in your profile:

leafpad ~/.local/share/applications/mimeapps.list

And add this line:

application/jar=openjdk-7-jre\:openjdk-7-java.desktop;

The format is simple: mime-type = app.desktop. Then if the option does not appear, create a shortcut in ~/.local/share/applications/:

ln -s /usr/share/app-install/desktop/openjdk-7-jre\:openjdk-7-java.desktop ~/.local/share/applications/.

And then it should work. If this does not help then you have to manually create a .desktop file, these are the contents of mine:

[Desktop Entry]
X-AppInstall-Package=openjdk-7-jre
X-AppInstall-Popcon=7303
X-AppInstall-Section=main

Name=OpenJDK Java 7 Runtime
Comment=OpenJDK Java 7 Runtime
Exec=cautious-launcher %f /usr/bin/java -jar
Terminal=false
Type=Application
Icon=openjdk-7
MimeType=application/x-java-archive;application/java-archive;application/x-jar;
NoDisplay=true

X-Ubuntu-Gettext-Domain=app-install-data

Hope it helps, bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

Works fine for me:

CREATE TABLE `user` (
  `userid` char(50) NOT NULL default '',
  `password` char(12) NOT NULL default '',
  `lastlogin` timestamp NOT NULL,
  `newmessage` int(4) unsigned NOT NULL DEFAULT 0,
  `companyid` char(10) default NULL,
  `departmentid` char(10) default NULL,
  `status` char(50) default NULL,
  PRIMARY KEY  (`userid`),
  KEY `loginuser` (`userid`,`lastlogin`)
) ENGINE=MyISAM;

Here's a live test: http://sqlfiddle.com/#!9/855fe/1

If it still does not work for you, then paste your updated schema.

cereal 1,524 Nearly a Senior Poster Featured Poster

Ok, here there are two errors on this line:

`newmessage`int(4) unsigned NOT NULL DEFAULT `0`,

The space between the column name and the type is missing, and the default value is defined with backticks instead of quotes, so:

`newmessage` int(4) unsigned NOT NULL DEFAULT '0',

But there is also another problem with the previous line:

`lastlogin` timestamp(14) NOT NULL,

Depending on the version in use you will get this error:

ERROR 1426 (42000): Too big precision 14 specified for 'lastlogin'. Maximum is 6.

To avoid it you can avoid to define the precision:

`lastlogin` timestamp NOT NULL,

For more information read these links:

cereal 1,524 Nearly a Senior Poster Featured Poster

I've registered an account and got your same result, probably their system requires some time (few hours) to enable the API key.

If by waiting you don't solve try to ask their support team: api-support@authorSTREAM.com

In general, for generic issues like these try to get a response from the support teams before asking to Daniweb forums, here we help in specific programming issues.

cereal 1,524 Nearly a Senior Poster Featured Poster

Whoops! Sorry, wait a moment. I thought you were using PDO when you started your thread, so I've been referring to it:

Your error:

call to undefined method ADODB_mysqli::setAtribute() in

instead refers to MySQLi, which is another API: https://php.net/mysqlinfo.api.choosing

Also ADOdb uses another syntax, so my previous code is almost useless. I'm not familiar with this library, but try:

$ret  = 'world';
$sso  = 'hello';
$dsn  = "mysqli://$dbusername:$dbpassword@$servername/$dbname?persist";
$conn = ADONewConnection($dsn);

$conn->Execute("SET @test = ?", array($ret));
$conn->Execute("CALL test_proc(?, @test)", array($sso));
$result = $conn->getOne("SELECT @test as result");

echo $result;

It works fine for me.

cereal 1,524 Nearly a Senior Poster Featured Poster

Are you setting the connection? For example:

$servername = "localhost";
$dbname     = "test";
$dbusername = "root";
$dbpassword = "";

$conn = new PDO("mysql:host=$servername;dbname=$dbname", $dbusername, $dbpassword);

Otherwise PHP will send a notice for undefined variable $conn and a fatal error:

Fatal error: Call to a member function setAttribute() on a non-object

EDIT:

Also, your var_dump seems more the output of errorInfo(), when creating a connection PDO will return an object on success, errors or exceptions on failure. Can you share your connection code? (No need of credentials)

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

in this case you can use header(), you could setup actions.php like an hub and define specific redirect links:

switch($_GET['action']):
{
    case 'send':

        # run insert query
        $redirectTo = "http://website.tld/pageY.php";
        break;

    case 'update':

        # run code here
        $redirectTo = "http://website.tld/pageX.php";
        break;

    default:

        $redirectTo = "http://website.tld/pageA.php";
}

header("Location: $redirectTo");

Also when using single quotes, PHP will not parse the variable, so:

header('location:items.php?item=$itemid');

Will literally output items.php?item=$itemid, not items.php?item=17 as expected. You have to use double quotes:

header("Location: http://website.tld/items.php?item=$itemid");
cereal 1,524 Nearly a Senior Poster Featured Poster

The user connecting from the PHP script does have the Execute privilege to run procedures?

Docs:

You can verify this with a try/catch block:

<?php

    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

    try {

        $ret = 'world';
        $sso = 'hello';

        $stmt1 = $conn->prepare("SET @test = ?");
        $stmt1->execute(array($ret));

        $stmt2 = $conn->prepare("CALL test_proc(?, @test)");
        $stmt2->execute(array($sso));

        $query = $conn->query("SELECT @test as result")->fetch(PDO::FETCH_OBJ);
        echo $query->result;

    } catch(PDOException $e) {
        echo $e->getMessage();
    }

If the problem is the privilege then you should get an access violation error. Here's a live test script which seems to work fine:

Just click Run.

cereal 1,524 Nearly a Senior Poster Featured Poster

Ok, the only form elements I see here are:

<form name="progress" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">

    <input type="hidden" name="Progressid" value="<?php echo $_SESSION['Progressid']; ?>" />

    <input type="submit" name="Notify2" value="Notify"/>

</form>

So the only values you will get from the $_POST array are Progressid and Notify2:

Array
(
    [Progressid] => 4
    [Notify2] => Notify
)

In your current sources I see the block code to generate $_POST['responsible2'] in the receiving script, you should move that select to the form script and add an input field to enter the email address. Basically your form should look like this:

<form name="progress" method="post" action="">

    <input type="hidden" name="Progressid" value="4" />

    <label for="responsible2">Responsible</label>
    <select name="responsible2" id="responsible2">
        <option value="1">abc</option>
        <option value="2">def</option>
        <option value="3">ghi</option>
    </select>

    <label for="email">E-mail Address</label>
    <input type="email" name="Email" id="email" />

    <input type="submit" name="Notify2" value="Notify"/>

</form>

Only at this point you can start to receive data from the $_POST array, for example:

Array
(
    [Progressid] => 4
    [responsible2] => 1
    [Email] => name.surname@domain.tld
    [Notify2] => Notify
)

I suggest you to understand how forms are handled by PHP:

Then, if you still need help try to update your code and to paste it here correctly, please read the syntax helper:

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

are you using MySQL on Windows? Is this a new installation? Which version? Could you paste the specific message and code error?

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

check the data models in the Education section at:

If it does not help, write about your project, try to define the basic information you would need to create such application. This should help you to shed some light and then you can ask more specific help, at the moment your question is very generic, so it's difficult to give an appropriate help.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

I got the same issues that you have described with both APIs, but standing at the documentation I cannot help:

as it seems that your queries are correct, and their results aren't. Try to contact their assistance services to understand if you have to do something different.

cereal 1,524 Nearly a Senior Poster Featured Poster

Try if it works fine from the mysql client, because it returns this error to me:

ERROR 1414 (42000): OUT or INOUT argument 2 for routine dbase.test_proc is not a variable or NEW pseudo-variable in BEFORE trigger

You can try to bypass the error by setting a variable before calling the procedure, like this:

DROP PROCEDURE IF EXISTS test_proc;
DELIMITER $$
CREATE PROCEDURE `test_proc`(In user_id varchar(100), OUT message varchar(1000))
BEGIN
 set message ='OK';
END $$
DELIMITER ;

-- as suggested here: https://bugs.mysql.com/bug.php?id=25970#c195094
SET @test = 'world';
CALL test_proc('hello', @test);
SELECT @test;

In PDO this becomes:

<?php

    $conn = require './pdo.php';

    $ret = 'world';
    $sso = 'hello';

    $stmt1 = $conn->prepare("SET @test = ?");
    $stmt1->execute(array($ret));

    $stmt2 = $conn->prepare("CALL test_proc(?, @test)");
    $stmt2->execute(array($sso));

    $query = $conn->query("SELECT @test as result")->fetch(PDO::FETCH_OBJ);

    echo $query->result;

Which seems to return fine to me: OK.

cereal 1,524 Nearly a Senior Poster Featured Poster

To define different formats you have to append the parameter httpAccept to the link, for example:

&httpAccept=application/json
&httpAccept=application/xml
&httpAccept=application/atom+xml
&httpAccept=application/rss+xml

Documentation: http://www.nature.com/developers/documentation/api-references/opensearch-api/#apiref

So to get the document in XML format you would write:

$url = 'http://api.nature.com/content/opensearch/request?queryType=searchTerms&query=darwin&httpAccept=application/xml';

Accessing the information is not simple, here I will explain three methods with, from the hardest to the easiest:

  • xml
  • json
  • json (as array)
XML

When using the XML method you have to check the source to read the namespaces used to define the document. With SimpleXML you can get the list by using this method getDocNamespaces():

$content = simplexml_load_file($url);
print_r($content->getDocNamespaces(true, true));

Which returns:

Array
(
    [xsi] => http://www.w3.org/2001/XMLSchema-instance
    [srw] => http://docs.oasis-open.org/ns/search-ws/sru-2-0-response
    [] => http://docs.oasis-open.org/ns/search-ws/sru-2-0-response
    [ns1] => http://docs.oasis-open.org/ns/search-ws/sru-2-0-response
    [dc] => http://purl.org/dc/elements/1.1/
    [dcterms] => http://purl.org/dc/terms/
    [pam] => http://prismstandard.org/namespaces/pam/2.0/
    [prism] => http://prismstandard.org/namespaces/basic/2.1/
    [xhtml] => http://www.w3.org/1999/xhtml
    [ns2] => http://docs.oasis-open.org/ns/search-ws/sru-2-0-response
    [ns3] => http://docs.oasis-open.org/ns/search-ws/sru-2-0-response
    [ns4] => http://www.nature.com/opensearch/ns/sru/
)

If you read the document structure you will see:

<records>
    <record>
        <recordData>
            <pam:message
                xmlns:dc="http://purl.org/dc/elements/1.1/"
                xmlns:dcterms="http://purl.org/dc/terms/"
                xmlns:pam="http://prismstandard.org/namespaces/pam/2.0/"
                xmlns:prism="http://prismstandard.org/namespaces/basic/2.1/"
                xmlns:xhtml="http://www.w3.org/1999/xhtml"
                xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
                xsi:schemaLocation="http://prismstandard.org/namespaces/pam/2.0/ http://prismstandard.org/schemas/pam/2.1/pam.xsd">

                <pam:article>
                    <xhtml:head>
                        <dc:identifier>doi:10.1038/081007a0</dc:identifier>
                        <dc:title>&lt;i&gt;The &lt;span&gt;Darwin&lt;/span&gt; Celebrations at Cambridge&lt;/i&gt;</dc:title>
                        ...
                        <prism:publicationDate>1909-07-01</prism:publicationDate>
                        ...

So to access the information under the object recordData you have to load the namespaces for:

  • pam:
  • xhtml:
  • dc: & prism:

Basically to get the first record you …

cereal 1,524 Nearly a Senior Poster Featured Poster

@Sophia

hi, could you show us the form used to submit the POST values to your script?

cereal 1,524 Nearly a Senior Poster Featured Poster

Erorare reference : This email was looking for a about is sent without authentication

It means that the SMTP server used to send the email requires the authentication for the email defined here:

$emailFrom ="contact@yoursite.com";

i.e. it requires the password. With mail() you can do this only by editing the php.ini file as explained here:

A better solution is to use libraries like PHPMailer or SwiftMailer:

Otherwise you have to use PHP sockets, which is what the above libraries do. A basic script would look like in this example:

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, open the Developer Tools console in Google Chrome, then click on the smartphone icon, it allows to test some device resolutions, here's a screenshot:

http://i.imgur.com/cs3ZeA7.png

diafol commented: Great advice +15
cereal 1,524 Nearly a Senior Poster Featured Poster

SimpleXML should not replace the underscore with an hyphen, probably the XML generated by the NYPL has already that format. Could you provide the query link? In any case, when this happens use the alternative syntax to call the variables:

$a = 'hello';

echo $a;
echo ${'a'}; # alternative syntax

So, for example, with the XML object you would write:

echo $xml->response->{'content-partner'}->title;

Reference: http://php.net/manual/en/simplexml.examples-basic.php#example-5913

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

you don't need file_get_contents() in this case, if you get the results in XML format then use simplexml_load_string(), like this:

$xml = simplexml_load_string($resp);

It returns an object, for example:

echo $xml->response->capture[0]->itemLink;

If instead you get the results as JSON use json_decode():

$data = json_decode($resp, true);

By adding true as second argument, $data will be a simple array, otherwise it will be an object.

Docs:

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, read this: https://www.daniweb.com/community/syntax#quotes

The syntax help is accessible by clicking on the ? icon in the text editor.

cereal 1,524 Nearly a Senior Poster Featured Poster

Oh that's correct: if you define four types, then submit four variables.

For example, with one variable to submit you would write:

$stmt->bind_param('s', $nm);

To submit two variables:

$stmt->bind_param('ss', $nm, $gd);

And so on. s stands for string, you can check the types here:

By submitting an extra variable MySQLi will generate a warning because the definition ssss does not match the number of submitted variables.

Now, by defining the variables after the bind, PHP will also generate a notice for each undefined variable at line four, to avoid it you should define them before, as in my previous example.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

you're defining the variables after the binding, this will lead to an error, try:

$nm = $_POST['nm'];
$nm = $_POST['ln'];
$gd = $_POST['gd'];
$tl = $_POST['tl'];
$ar = $_POST['ar'];

$stmt->bind_param('ssss', $nm, $ln, $gd, $tl, $ar);
cereal 1,524 Nearly a Senior Poster Featured Poster

In addition, if you're using Laravel, then you can use the asset() helper:

$link = asset("/images/Work_Anniversary.png");

This will prepend the application url.

cereal 1,524 Nearly a Senior Poster Featured Poster

Try to change the header to:

curl_setopt($curl, CURLOPT_HTTPHEADER, array(
    "Authorization: Token token=$token"
));

Then it should work fine. To debug the request add:

curl_setopt($curl, CURLINFO_HEADER_OUT, true);

And:

$info = curl_getinfo($curl, CURLINFO_HEADER_OUT);

Which prints:

GET /api/v1/items/8568ccd0-c614-012f-1d74-58d385a7bc34.json HTTP/1.1
Host: api.repo.nypl.org
Accept: */*
Authorization: Token token=YOUR_TOKEN
cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

I haven't tested this but try to set the subquery in the select() method:

$this->db->distinct();

# select
$this->db->select("*, (SELECT GROUP_CONCAT(cd1.name ORDER BY level SEPARATOR '&nbsp;&nbsp;&gt;&nbsp;&nbsp;') FROM " . $this->db->dbprefix . "category_path cp LEFT JOIN " . $this->db->dbprefix . " category_description cd1 ON (cp.path_id = cd1.category_id AND cp.category_id != cp.path_id) WHERE cp.category_id = c.category_id AND cd1.language_id = '" . (int)$language_id . "' GROUP BY cp.category_id) AS path");

# join
$this->db->join($this->db->dbprefix . "category_description AS cd2", "c.category_id = cd2.category_id", "left");

# where
$this->db->where("c.category_id", (int)$category_id);
$this->db->where("cd2.language_id", (int)$language_id);

$query = $this->db->get($this->db->dbprefix . "category c");

With the $this->db->get_compiled_select() method you can see the query generated by active query.

cereal 1,524 Nearly a Senior Poster Featured Poster

In addition, you could use mysqli_fetch_all() to retrieve all the rows:

$result = mysqli_fetch_all($query, MYSQLI_ASSOC);

foreach($result as $key => $row)
{
    echo $row['title'].'<br>';
}

But it requires Mysqlnd (the native driver):

cereal 1,524 Nearly a Senior Poster Featured Poster

It happens because $connect is defined out of the scope of the function, to fix it do:

<?php

include 'config.php';

function findProducts($connect) {
    $query = mysqli_query($connect, "SELECT * FROM cart");
    while($row = mysqli_fetch_assoc($query)){
        echo $row['title'].'<br>';
    }
}

echo findProducts($connect)
cereal 1,524 Nearly a Senior Poster Featured Poster

In these cases you should hear some beeps from the motherboard, the sequence can help you to understand the issue, in the documentation you should find the meaning of each sequence.

Anyway, make sure everything is well connected to the motherboard, including jumpers and connectors. If it does not solve then disconnect the harddisk from the motherboard and try to boot and to access the bios.

If still it does not work do not reconnect the harddisk, start to remove the RAM modules, test them one by one in each RAM slot until you understand if the problem is generated by one of the modules or by a slot: it can happen that a module or a slot connection area is dirty or that the element is burnt. Do the same with any external peripheral.

cereal 1,524 Nearly a Senior Poster Featured Poster

@Nilo, do:

$row = $conn->query("SELECT MAX(id) AS last_id FROM Posts")->fetch(PDO::FETCH_OBJ);
echo $row->last_id;

It's important to define an alias MAX(id) AS last_id otherwise you get:

stdClass Object
(
    [MAX(id)] => 100
)

Which can be accessed with another syntax:

echo $row->{'MAX(id)'};