• Howdy! Welcome to our community of more than 130.000 members devoted to web hosting. This is a great place to get special offers from web hosts and post your own requests or ads. To start posting sign up here. Cheers! /Peo, FreeWebSpace.net
managed wordpress hosting

PHP/MySQL and URL data.

Dynash

It gets better.
NLC
Hey,

First time I've encountered this problem. Basically, I want to insert URL data into a field in my database. I get the URL from a form using $_POST.

When the form is submitted it just returns an 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 'http%3A%2F%2Fwww.antsta.com%2F')' at line 1

I've tried addshasles, urlencode (hence the %3A etc). I've google'd for a while, can't get why. It's submitted normally as text. Anyone care to help?
 
Try hex encoding the data before using form post(dechex is the function precisely).

Also keep it encoded even while entering it in the database.
Later when you want to use the url from the database, just add hex decoding to it at that point to recover the exact sequence .
That's the simplest it can get...

Best Regards...
 
Last edited:
Nope, same error, just encoded.

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 'aHR0cDovL3d3dy50ZXN0LmNvbQ%3D%3D')' at line 1
 
Try this
PHP:
?function change ($change,$to,$url){$url=str_replace($change,$to,$url);
return $url;}

$original_url='http://www.numbhost.com/';
$original_url = change('.','_dot_',$original_url);
$original_url = change('/','_slash_',$original_url);
$original_url = change(':','_colon_',$original_url);
echo $original_url;

Using the above code , just edit the $original_url with your required url .

And make sure in the table you set varchar to 90 or more , coz this is supposed to give out really long output .

Of course you can set it to give out smaller output . Eg- use change(':','_',$original_url); will make it shorter . But you will have to find out which characters you would want to use to replace the '/' and the '.' with .

Good luck , and don't hesitate to get back to me if you need any help .

Best Regards,
Aloycasmir
 
Last edited:
I haven't done any PHP/MySQL in a few years but couldn't the issue be with:

')'

At the end of the string. Seems like the common part in the two you posted. If not, the error is somewhere else since the encoded string should work just fine.
 
oh my god. I knew it would be something SO simple. I didn't notice on the third value, there was a missing '. I had it like this:

'$post_t, '$post_u'

Thanks! I'll /facepalm now!
 
Heh , no problems .
Shi@ happens sometimes .

Anyways , if you have any simple php/mysql jobs for me , let me know , I'd gladly do them .
And if some paid ones , all the better ;)

Anyways , have a good day .
Best Regards,
Aloycasmir
 
Back
Top