mySQL error?????

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
lparnau
Forum Newbie
Posts: 15
Joined: Tue Aug 12, 2003 3:31 pm

mySQL error?????

Post by lparnau »

feyd | Please use

Code: Select all

tags when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]


I do not understand why I keep getting this warning. The script works fine if I DO NOT include "?id=abcd", but as soon as I add an id I get this error.



Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/xxxxxx/xxxxxxxx/success-1.php on line 36
.  

I have tried both fetch_array or fetch_row here?

Code: Select all

if(!$id) {
	
		$result = mysql_query("Select username FROM dreamteam_db WHERE num_joined < 2 limit 1",$link);[b] [u]//This works fine[/u][/b]


}else{
 
 	$result = mysql_query("SELECT * FROM dreamteam_db WHERE username = $id",$link);     
	
} 
 	
	$myrow = mysql_fetch_array($result);	[b][u]//(This is line 36)[/u][/b]	
	
    
    $username = $myrow["username"];

    $id = $myrow["LKey"];

    $fname = $myrow["fname"];

feyd | Please use

Code: Select all

tags when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

you know its wise to use ' ' to surround your vars


Code: Select all

<?php
$result = mysql_query("SELECT * FROM dreamteam_db WHERE username ='$id'",$link); 
?>
its also wise to use mysql_error() to troubleshoot errors

Code: Select all

<?php
$result = mysql_query("SELECT * FROM dreamteam_db WHERE username = $id",$link) or die (mysql_error)); 
?>
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

oh its another "wise" things is use php tags to surround your code.

Its much easier for others to help :wink:

[syntax=php]code here[/syntax]
Post Reply