Jump to content

Recommended Posts

Hi guys,

 

Got a problem with selecting, adding updation and deleting from my database using php with a specific record which has a quote in it....

 

"Invercargill City Council - EIL In'gill"

 

Now when i select it or try add it etc it comes up with "Line 1: Incorrect syntax near 'gill'."

 

When i display what its actually trying to select it has escape characters

 

"Invercargill City Council - EIL In\\\'gill"

 

i think its getting confused with this quote, how do i check if the string is like the one above and then change it it to the right value. what is syntax?  is it somethin like...

 

"Invercargill City Council - EIL In\'gill"

 

please help!

 

 

And no i cant change the value of the record inside the database.

Link to comment
https://forums.phpfreaks.com/topic/69703-quote-within-a-quote/
Share on other sites

http://us2.php.net/manual/en/function.stripslashes.php

 

I'll elaborate.  Certain characters like Quotes, $, @, * etc are special characters that have functions/operations in php thus they are escaped with a slash before.  You just need to mind em in/out of the database and you'll be find.

Link to comment
https://forums.phpfreaks.com/topic/69703-quote-within-a-quote/#findComment-350231
Share on other sites

I am wondering why it got 3 slashes. I am not sure if the replies addressed this fully or not.

When inserting, you want to use mysql_real_escape_string() (assuming you're using MySQL).

When displaying (after a select), use stripslashes().

I do not use magic_quotes, and do not ever plan to (so, I do not know all the details of it).

However, if yours is on, you should to read this:

http://us2.php.net/magic_quotes

 

Hopefully one of us hit it.

 

If you are having further trouble, post the relevent code.

Link to comment
https://forums.phpfreaks.com/topic/69703-quote-within-a-quote/#findComment-350244
Share on other sites

Is this a field that gets updated,  Odds are you inputted it once normal, then you tried editing off a form and the output had slashes thus you got this down river affect of slashes.  Just recreate the DB entry and see how it looks.  Also as said check magic quotes

Link to comment
https://forums.phpfreaks.com/topic/69703-quote-within-a-quote/#findComment-350261
Share on other sites

im using mssql.  do i have to turn magic quotes off or something.  I havent got one to updating yet, what im doing at the moment is selecting the value from a combo box which submits the for i then take that value and reload my form with the query based on that value.

 

$opt = $_GET['option'];

$val = stripslashes($_GET['val']);

$v = stripslashes($val);

 

echo $v;

if ($opt == 'l') {

 

 

$query = "SELECT * FROM X_LightOwner WHERE [Light Owner] = '$v'";

}

else {

$query = "SELECT * FROM X_LightOwner";

}

 

 

Every other option works except for this specific 1

Link to comment
https://forums.phpfreaks.com/topic/69703-quote-within-a-quote/#findComment-350264
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.