[thelist] PHP, querystring question
Sean Preston
razorwise at yahoo.com
Fri May 25 12:24:27 CDT 2001
My code, relating to this q, is shown below. I'm new at PHP and MySql and I was running through
the WEBMONKEY TUTORIAL -->http://hotwired.lycos.com/webmonkey/99/21/index3a.html<-- and replacing
it with my own database and whatnot. However, when I'm trying to do the query with this variable,
$id (below) it gives me this error-->Warning: Supplied argument is not a valid MySQL result
resource...<-- however, should I replace it with a literal value, id ='whatever', it pulls the
query fine.
I've been trying to figure this out for some time this morning and am at a loss. I've even done a
printf on the $id. My understanding is that the name=value pair is automatically created here,
that's what the tutorial said. I will appreciate any/all help on the understanding of what I
thought should be a simple thing. *L*
Sincerely,
Sean
(Remembering the simple days, when everyone had green screens...*g*)
CODE FOLLOWS:
if ($id) {
$result = mysql_query("SELECT * FROM cars2 where id= $id" ,$db);
$myrow = mysql_fetch_array($result);
printf("Owner:%s\n<br>", $myrow["id"]);
printf("Make: %s\n<br>", $myrow["make"]);
printf("Model: %s\n<br>", $myrow["model"]);
printf("Year: %s\n<br>", $myrow["year"]);
printf($id);
} else {
// show car list
$result = mysql_query("SELECT * FROM cars2",$db);
if ($myrow = mysql_fetch_array($result)) {
// display list if there are records to display
do {
printf("<center><br><br><a href=\"%s?id=%s\">%s %s %s</a><br><br></center>\n",
$PHP_SELF,$myrow["id"],$myrow["make"], $myrow["model"], $myrow["year"]);
} while ($myrow = mysql_fetch_array($result));
} else {
// no records to display
echo "Sorry, no records were found!";
}
}
?>
__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/
More information about the thelist
mailing list