Forum Moderators: coopster

Message Too Old, No Replies

Resource ID #14

         

norek

6:33 am on Oct 2, 2005 (gmt 0)

10+ Year Member



My original code was below and it would give me error "RESOURCE ID #14".

if ($search_city) {
$sc1 = mysql_query("SELECT sid FROM CITY_TABLE WHERE descript LIKE '%$search_city%'");
$sc2 = $sc1'
}

**************************************************

Then after reading posts on the site, I modified it to what's below, but now the SQL is returning the value $sc2 as "Array"

if ($search_city) {
$sc1 = mysql_query("SELECT sid FROM CITY_TABLE WHERE descript LIKE '%$search_city%'");
$sc2 = mysql_fetch_array($sc1);
$sc3 = $sc2;
}

**************************************************

Or if I user the mysql_fetch_object or mysql_fetch_field, it returns "Object"

if ($search_city) {
$sc1 = mysql_query("SELECT sid FROM CITY_TABLE WHERE descript LIKE '%$search_city%'");
$sc2 = mysql_fetch_object($sc1);
$sc3 = $sc2;
}

**************************************************

I'm have no idea what else might be wrong... any ideas?

dreamcatcher

7:23 am on Oct 2, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



norek, welcome to Webmaster World. :)

You seem a little unclear on how to use the sql syntax.

Try:

if ($search_city) {
$sc1 = mysql_query("SELECT sid FROM CITY_TABLE WHERE descript LIKE '%$search_city%'");
$sc2 = mysql_fetch_array($sc1);
echo $sc2['sid'];
}

or for mysql_fetch_object:

if ($search_city) {
$sc1 = mysql_query("SELECT sid FROM CITY_TABLE WHERE descript LIKE '%$search_city%'");
$sc2 = mysql_fetch_object($sc1);
echo $sc2->sid;
}

dc

norek

3:13 pm on Oct 2, 2005 (gmt 0)

10+ Year Member



Dreamcather, the reason I didn't use the echo command is because there is a lot more to the script then what I posted...

The problem was that I needed $sc2->sid;

You fixed hours of being stumped, I think I'm in love with you :P

THANKS!

ergophobe

3:48 pm on Oct 2, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Look for the thread in the forum library called "The basics of extracting data with MySQL" or some such title. That should help you out.

[webmasterworld.com...]

dreamcatcher

8:50 pm on Oct 2, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You fixed hours of being stumped, I think I'm in love with you :P

You`re welcome. And if you are single, female and Chinese I`ll give you my phone number. LOL!

dc