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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bgreen1989
Forum Newbie
Posts: 1
Joined: Tue Dec 09, 2008 1:37 am
Contact:

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

Post 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.
User avatar
papa
Forum Regular
Posts: 958
Joined: Wed Aug 27, 2008 3:36 am
Location: Sweden/Sthlm

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

Post by papa »

Try hardcode trackNo and recordNo and some other basic error search.
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

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

Post 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);
Post Reply