Page 1 of 1

mysql_fetch_row($result) - $row[1] no output

Posted: Tue Dec 09, 2008 2:08 am
by bgreen1989
hi there, this is my first time to post in this forum.
i am having a problem with my php file, particularly in

Code: Select all

 
require_once("db_config.php");
$trackNo = $_GET["trackNo"];
$recordNo = (int)substr($_GET["recordNo"],5);
 
$result = mysql_query("SELECT record_name,record_type_id FROM sra_details WHERE tracking_no='".$trackNo."' AND record_type_id=".$recordNo."");
if (!$result) {
    echo 'Could not run query: ' . mysql_error();
    exit;
}
$row = mysql_fetch_array($result, MYSQL_ASSOC);
echo "Document: ".$row["record_name"];
 
mysql_query is successful.
i just don't know why $row["record_name"] echos nothing.

hoping for reply asap.
thank you so much.

Re: mysql_fetch_row($result) - $row[1] no output

Posted: Tue Dec 09, 2008 7:19 am
by papa
Try hardcode trackNo and recordNo and some other basic error search.

Re: mysql_fetch_row($result) - $row[1] no output

Posted: Tue Dec 09, 2008 8:10 am
by Eran
There could be two reasons - your query returns an empty set (no rows found matching the query) and the value in the column is empty or null.

var_dump the contents of the row, to see what's inside:

Code: Select all

var_dump($row);
Also check the number of returned rows:

Code: Select all

echo mysql_num_rows($result);