I've looked at this until I can't see straight. I'm missing something and just can't track it down. When I copy/past the sql below in phpMyAdmin, it selects the records, so I don't think it's the sql statement. I also am locking the db before I try the select, so I think the connection is okay.
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /web/apache/htdocs/xx/xx/addrecord.php on line 13
sql: SELECT * FROM speaker WHERE lastname= 'smith' AND firstname = 'john' AND code = 'xx20'
Here's the PHP:
$locksql = "LOCK TABLES speaker READ";
$lockreq= mysql_query($locksql) ||
die(mysql_errno().":".mysql_error()."
<br>QUERY FAILED:<br>$locksql\n");
$num = 0;
$Plast = $_POST['lastname'];
$Pfirst = $_POST['firstname'];
$Pcode = $_POST['code'];
$sql = "SELECT * FROM speaker
WHERE lastname= '".$Plast."'
AND firstname = '".$Pfirst."'
AND code = '".$Pcode."'";
$result = mysql_query($sql,$dblink) ||
die(mysql_errno().":".mysql_error()."
<br>QUERY FAILED:<br>$sql\n");
while ($row = mysql_fetch_array($result)) {
$sidIN = "";
$sidIN = $row['sid'];
$num++;
}
echo "<br>sql: ".$sql."<br>";
$locksql = "UNLOCK TABLES";
$lockreq = mysql_query($locksql) ||
die(mysql_errno().":".mysql_error()."
<br>QUERY FAILED:<br>$locksql\n");
If someone can pick out the error, I'd sure appreciate it. I'm going to eat dinner now. Maybe when I get back to work, someone will have spotted it.
Thanks a Bunch 🙂