Jump to content

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


gtridez

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?
Link to comment
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.
Link to comment
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.

Link to comment
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'";
Link to comment
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...
Link to comment
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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.