Jump to content

Archived

This topic is now archived and is closed to further replies.

gtridez

how to select unique id such as "345fgdf4df54"? *SOLVED*

Recommended Posts

How do I select a unique id such as "gh4543hg3354h" from a table?

I'm trying to select a unique id such as "gh4543hg3354h" from a database table...
however i keep getting

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/gtridez/public_html/GTRider/ride_displayer.php on line 37

does anyone know what this problem is and how to fix it?

Share this post


Link to post
Share on other sites
[!--quoteo(post=373794:date=May 14 2006, 01:42 PM:name=gtridez)--][div class=\'quotetop\']QUOTE(gtridez @ May 14 2006, 01:42 PM) [snapback]373794[/snapback][/div][div class=\'quotemain\'][!--quotec--]
How do I select a unique id such as "gh4543hg3354h" from a table?

I'm trying to select a unique id such as "gh4543hg3354h" from a database table...
however i keep getting

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/gtridez/public_html/GTRider/ride_displayer.php on line 37

does anyone know what this problem is and how to fix it?
[/quote]

that error could be appearing for any number of reasons. Either the SQL statement that you passed didn't work, or you may not be connected to the mysql server. If you post the SQL query you are using we can be of more help.

Share this post


Link to post
Share on other sites
this is the query i'm using...
where $unid = "W34fddf3433324fd";
..

$sql = "SELECT * ".
"FROM images ".
"WHERE unique_image_id = $unid";
$result = mysql_query ($sql);
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {

$caption = $row["image_caption"];
$image = $row["image_src"];
$year = $row["ride_year"];
$rnum = $row["ride_number"];
$rid = $row["ride_id"];
$uid = $row["user_id"];

}
..

i know i'm connected because if i try to select an id that has jus numbers like 454435 it returns the results i need...but its not returning anything but the previously posted errors when i use numbers and letters in the unique id.

Share this post


Link to post
Share on other sites
You probably have a syntax error in your SQL and you're not checking for errors before doing the fetch.

Click on the [a href=\"http://www.phpfreaks.com/forums/index.php?showtopic=31047&view=findpost&p=153359\" target=\"_blank\"]PHP F.A.Q.[/a] link. Find and read the [b]MySQL Data Retrieval[/b] section for example code of getting data from MySQL with error checking after every MySQL command.

Also search that topic for "supplied argument is not a valid" for more info.

Please be careful not to double post. I delete your other duplicate post.


EDIT:

I see you posted the SQL. Put quotes around the $unid value.

"WHERE unique_image_id = '$unid'";

Share this post


Link to post
Share on other sites
[!--quoteo(post=373798:date=May 14 2006, 01:51 PM:name=toplay)--][div class=\'quotetop\']QUOTE(toplay @ May 14 2006, 01:51 PM) [snapback]373798[/snapback][/div][div class=\'quotemain\'][!--quotec--]
You probably have a syntax error in your SQL and you're not checking for errors before doing the fetch.

Click on the [a href=\"http://www.phpfreaks.com/forums/index.php?showtopic=31047&view=findpost&p=153359\" target=\"_blank\"]PHP F.A.Q.[/a] link. Find and read the [b]MySQL Data Retrieval[/b] section for example code of getting data from MySQL with error checking after every MySQL command.

Also search that topic for "supplied argument is not a valid" for more info.

Please be careful not to double post. I delete your other duplicate post.
EDIT:

I see you posted the SQL. Put quotes around the $unid value.

"WHERE unique_image_id = '$unid'";
[/quote]


heyyy...
thanx alooot man...
damn i don't know how come i didnt tink of something so simple...
it works fine now and my problem is solved...
thanx a whole lot again

and oh...sorry about the double post...first post had sum stuff i didnt want in my post....but wasnt sure how they got there...

Share this post


Link to post
Share on other sites
suggestion: use single quotes when you are not concatenating with a variable in your expression.

[!--quoteo(post=373797:date=May 14 2006, 01:51 PM:name=gtridez)--][div class=\'quotetop\']QUOTE(gtridez @ May 14 2006, 01:51 PM) [snapback]373797[/snapback][/div][div class=\'quotemain\'][!--quotec--]
$sql = "SELECT * ".
"FROM images ".
"WHERE unique_image_id = $unid";
$result = mysql_query ($sql);
[/quote]

to

[code]
$sql = 'SELECT * '.
     'FROM images '.
     "WHERE unique_image_id = $unid";
$result = mysql_query ($sql);
[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.