Page 1 of 1

msql_fetch_row(Invalid SQL Command?)

Posted: Thu Dec 02, 2004 1:47 am
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;
?>

Posted: Thu Dec 02, 2004 3:44 am
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

Posted: Thu Dec 02, 2004 7:37 am
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