gtridez Posted May 14, 2006 Share Posted May 14, 2006 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 gettingWarning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/gtridez/public_html/GTRider/ride_displayer.php on line 37does anyone know what this problem is and how to fix it? Quote Link to comment https://forums.phpfreaks.com/topic/9665-how-to-select-unique-id-such-as-345fgdf4df54-solved/ Share on other sites More sharing options...
_will Posted May 14, 2006 Share Posted May 14, 2006 [!--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 gettingWarning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/gtridez/public_html/GTRider/ride_displayer.php on line 37does 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. Quote Link to comment https://forums.phpfreaks.com/topic/9665-how-to-select-unique-id-such-as-345fgdf4df54-solved/#findComment-35759 Share on other sites More sharing options...
gtridez Posted May 14, 2006 Author Share Posted May 14, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/9665-how-to-select-unique-id-such-as-345fgdf4df54-solved/#findComment-35761 Share on other sites More sharing options...
toplay Posted May 14, 2006 Share Posted May 14, 2006 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 Link to comment https://forums.phpfreaks.com/topic/9665-how-to-select-unique-id-such-as-345fgdf4df54-solved/#findComment-35762 Share on other sites More sharing options...
gtridez Posted May 14, 2006 Author Share Posted May 14, 2006 [!--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 againand oh...sorry about the double post...first post had sum stuff i didnt want in my post....but wasnt sure how they got there... Quote Link to comment https://forums.phpfreaks.com/topic/9665-how-to-select-unique-id-such-as-345fgdf4df54-solved/#findComment-35766 Share on other sites More sharing options...
_will Posted May 14, 2006 Share Posted May 14, 2006 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] Quote Link to comment https://forums.phpfreaks.com/topic/9665-how-to-select-unique-id-such-as-345fgdf4df54-solved/#findComment-35767 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.