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)) { Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.