Jump to content

easy - cant figure out how to put a url in the database without error


jwk811

Recommended Posts

		$thumbnail = "http://www.sportquadchat.com/images/avatars/" . $thumbnail;

$sql   = "UPDATE chat_users 
          SET picture_url = '$thumbnail'
		  WHERE id = $userId";  

 

the thumbnail itself will submit just fine. its when i add the url to the beginning and i get this error

 

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'b1aafd32d4c8cdaf02ad8bc47365d4b9.jpg'' WHERE id = 33' at line 2

 

i tried changing it around but i cant figure out why it wont work.

Why has no-one suggested urlencode() yet?

 

http://uk.php.net/urlencode

 

Then when pulling it from the database use urldecode()

 

http://uk.php.net/manual/en/function.urldecode.php

 

VARCHAR is perfectly fine - just make sure it is set long enough to hold a decent URL.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.