msql_fetch_row(Invalid SQL Command?)

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
PHPMan
Forum Newbie
Posts: 13
Joined: Thu Nov 18, 2004 8:47 am

msql_fetch_row(Invalid SQL Command?)

Post by PHPMan »

Im getting a parse error, and its telling me the
mysql_fetch_row command is an invalid command?
Im wondering if its invalid, what am I to use to get data displayed in the table here? Below Ive included the parse error, and the code Im using
Any help on fixing this is much appreciated

Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/jetlinka/public_html/memphisair/roster/index_content.php on line 15


Code:
<?php
mysql_connect("localhost", "jetlinka_mei", "memphis");
$db = mysql_connect('localhost', 'jetlinka_mei', 'memphis');
if (!$db) {
// Select the database you want to use – You can use a variable here too instead
if (!mysql_select_db('jetlinka_mei')) { // Did selection fail?
// Handle error
echo 'DB Selection failed. <br />Error # ', mysql_errno(), ' Error msg: ', mysql_error();
exit;
}
$sql = "SELECT name, email FROM join";
$result = mysql_query($sql, $db);
if (!$result) {
// Handle error
echo 'Query failed. SQL: ', $sql, '<br />Error # ', mysql_errno(), ' Error msg: ', mysql_error();
exit;
}

<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1">
<tr>
<td width="12%"><b>Rank</b></td>
<td width="25%"><b>Name</b></td>
<td width="10%"><b>PID</b></td>
<td width="10%"><b>Hours</b></td>
</tr>
<?
while ($row = mysql_fetch_row($resultid)) //Don't capitalize what doesn't need to be
{
print "<tr>";
foreach ($row as $field)
{
print "<td>$field</td>";
}
print "</tr>";
}

print "</table>";

mysql_close;
?>
User avatar
Wayne
Forum Contributor
Posts: 339
Joined: Wed Jun 05, 2002 10:59 am

Post by Wayne »

Code: Select all

while ($row = mysql_fetch_row($resultid)) //Don't capitalize what doesn't need to be
should be

Code: Select all

while ($row = mysql_fetch_row($result)) //Don't capitalize what doesn't need to be
nosti
Forum Newbie
Posts: 4
Joined: Thu Dec 02, 2004 7:20 am

Post by nosti »

where did you bring $resultid
the mysql_fetch_row function should get a result resource which is in your case the $result object
so next time just go to the basics and read about the function you are having problems with
EVEN if you think you know what it does
Post Reply