Forum Moderators: coopster
I'm trying to follow this tutorial:
[devshed.com...]
and am getting an error message:
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in FILENAME on line 25
I've posted the code at the bottom of this email - line 25 is the line which begins:
while ($myrow = mysql_fetch_row($result))
If anyone has any thoughts, I'd really appreciate it. The connection to the database appears fine. When I 'print-error' it's telling me that it's a PARSE error - but I'm not sure if that's the real problem or whether I've implemented the 'print-error' bit of the code wrong!
Anyway, as you can tell, I'm a bit of a novice at this, so any help would be really appreciated. Many thanks,
David
<?php
$db = mysql_pconnect("localhost", "USERNAME", "PASSWORD");
// This establishes a link to MySQL
mysql_select_db("extranet",$db);
// The database is specified
$sql = "SELECT
p.person_id,
s.person_id,
CONCAT(last_name,', ',first_name) AS name,
skill_id ";
$sql .= "FROM
personnel p,
person_skill s
WHERE
p.person_id = s.person_id
ORDER BY
skill_id, name";
$result = mysql_query($sql);
$type = "";
$number2 = "0";
while ($myrow = mysql_fetch_row($result))
{
if ($myrow[3]!= $type) {
if ($number2!= NULL) {
$newnumber2 = ($number2 + "1");
print ("ar[$number2] = new Array();\n");
$number2 = $newnumber2;
$type = $myrow[3];
$number = "0";
}
}
print "ar[" . ($number2 - "1") . "]";
if ($number!= NULL) {
$newnumber = ($number + "1");
print ("[$number]");
$number = $newnumber;
}
print (" = new makeOption(\"$myrow[2]\", \"$myrow[1]$myrow[3]\");\n");
}
?>
if ($result = mysql_query($query)) {
do stuff;
}else{
don't do stuff;
}
In your case, though, your JS arrays would be empty which, I'm guessing, would be bad.