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:
$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.
$catquery = mysql_query("SELECT * FROM categories WHERE name = '{$info[2]}'");
__________________
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Validate your HTML and CSS
And that's what you are comparing to.
Don't know what simple_html_dom_node class is, but I'd presume it has a way to fetch the value. I can see it there nested a couple of down, but you'll need to consult the documentation for the simple_html_dom_node class to see how to fetch out out of there.
And that's what you are comparing to.
Don't know what simple_html_dom_node class is, but I'd presume it has a way to fetch the value. I can see it there nested a couple of down, but you'll need to consult the documentation for the simple_html_dom_node class to see how to fetch out out of there.
Is there anyway to pull the value from $info[2] to another variable and then query the new variable?
This way seems to work:
PHP Code:
$test = "{$info[2]}"; var_dump($test);
Well...no, it didn't, the var_dump shows the right variable, but when I plug $test into the query, still pops up nothing :\
$info = array();
foreach($html->find('span[class=value]') as $e){
$info[] = $e->plaintext;
}
__________________
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Validate your HTML and CSS
I don't really see the need to pull out the offset to a different variable. The problem here is you are trying to pass an object to the sql string which doesn't appear to have a way to interpret it properly. My expectation is that the echo also will not work, but PHP's toString is flaky over different versions for where it is interpreted. If it shows properly within the echo, you can force the __toString() call on it to return the string representation.
Consult the documentation for the simple_html_dom_node to see what you need to do to extract it out of there.