justlukeyou Posted June 25, 2012 Share Posted June 25, 2012 Hi, Following peoples advise I have tried to add a str_replace to add a hyphen to the keyword in 'name' column. However, when I enter a hyphen it returns a "Resource id #3" error. As far as I can tell the query needs to run through a loop to add the hyphen. Is that correct, Im a bit confused at this stage. if (isset($_GET['name'])) { $pretty_url = strtolower(str_replace(' ', '-', $_GET['name'])); header("Location: ?linkname=$pretty_url"); } $name = mysql_real_escape_string($_GET['linkname']); $query = mysql_query(" SELECT name, product_id, rrp, discount, image_link FROM productdbase p INNER JOIN furniture_groups f ON f.long_name = p.furniture_group WHERE name LIKE '%{$name}%' LIMIT 15"); echo $query, '<br>', mysql_error(); while ($query_row = mysql_fetch_assoc($query)) { Link to comment https://forums.phpfreaks.com/topic/264731-resource-id-3-error-requires-loop/ Share on other sites More sharing options...
silkfire Posted June 25, 2012 Share Posted June 25, 2012 As I'm telling you, mysql_fetch_assoc($query)) You can't run _assoc on a string, it needs a resource returned by mysql_query =D Link to comment https://forums.phpfreaks.com/topic/264731-resource-id-3-error-requires-loop/#findComment-1356795 Share on other sites More sharing options...
scootstah Posted June 25, 2012 Share Posted June 25, 2012 It is not an error, you are echo'ing $query which is a resource. If you want to know more about the resource you can use var_dump. Link to comment https://forums.phpfreaks.com/topic/264731-resource-id-3-error-requires-loop/#findComment-1356808 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.