Forum Moderators: coopster
I have it set up like this:
$host="xx.xx.xx.xx";
$user = "user";
$password = "xxxx";
$dbname = "bosp";
$tablename = "spread";
$link = mysql_connect ($host, $user, $password);
$query = "SELECT * from $tablename where(sindex='$array[index]' or scase='$array[case]' or sorder='$array[order]')";
$result = mysql_db_query ($dbname, $query, $link);
// create table
print ("<table border=1 width=\"75%\" cellspacing=2 cellpadding=2 align=center>\n");
print ("<tr align=center valign=top>\n");
print ("<td align=center valign=top>Reference</td>\n");
print ("<td align=center valign=top>Case</td>\n");
print ("<td align=center valign=top>Order/Dispatch</td>\n");
print ("</tr>\n");
// fetch results
while ($row = mysql_fetch_array ($result)) {
print ("<tr align=center valign=top>\n");
print ("<td align=center valign=top>$row[index]</td>\n");
print ("<td align=center valign=top>$row[case]</td>\n");
print ("<td align=center valign=top>$row[order]</td>\n");
print ("</tr>");
}
mysql_close ($link);
print ("</table>\n");
?>
if($result && mysql_num_rows($result)) {
// fetch results
}
else {
// no matches
}
would i be correct in assuming that this
while ($row = mysql_fetch_array ($result))
is line 37?
I would guess that the query syntax is wrong. Do you try them through telnet/ssh first to ensure proper syntax? I think this
SELECT * from $tablename where(sindex='$array[index]' or scase='$array[case]' or sorder='$array[order]')
should be
SELECT * from $tablename where sindex='$array[index]' or scase='$array[case]' or sorder='$array[order]'
no parentheses around the where clause. Another tip is you can use this syntax
$result = mysql_db_query($dbname,$query,$link) or die (mysql_errno().": ".mysql_error()."<BR>");
it will show you the error from mysql if the query fails.
<added>and what DrDoc said, it seems he's faster than me ;)