View Single Post
Old 01-12-2013, 06:54 PM   PM User | #1
Remix919
Regular Coder

 
Join Date: Jan 2006
Posts: 193
Thanks: 29
Thanked 0 Times in 0 Posts
Remix919 is an unknown quantity at this point
Very Weird Problem with mysql_fetch_assoc()?

Ok, so I have absolutely no idea what is going on, but it seems that my code is refusing to parse a simple mysql_fetch_assoc() when I use a certain variable.

First off, here's the code, i'm using php html dom to scrape a small amount of text and put it into the $info array:

PHP Code:
$info $html->find('span[class=value]');

echo 
"
<b>Year:</b> $info[0]<br>
<b>Make:</b> $info[1]<br>
<b>Model:</b> $info[2]<br>
<b>Trim:</b> $info[3]<br>
<b>Gas Mileage:</b> $info[8]/$info[9]<br>
<b>Combined:</b> $info[10]<br>
"
;

$catquery mysql_query("SELECT * FROM categories WHERE name = '$info[2]'");
$getcat mysql_fetch_assoc($catquery);

echo 
"Category ID: $getcat[category_id]"
Problem is, $getcat keeps coming up empty if I use the $info[2] variable, but if I put in the actual name, such as "Silverado 1500", it works fine so I know it's connecting and finding the name just fine, just comes up empty when using the $info[2] variable.
Remix919 is offline   Reply With Quote