In the following php query but it does not allow me to remove this [GS] that is between square brackets inside the table as a record (NOTE: Below I leave a small SQL Capture Photo of my question, I appreciate answers. I think the image explains better.)
$result3 = mssql_query(' UPDATE Ps_GameData.dbo.Chars
SET CharName = replace (CharName,\'' **[GS]** '\' ,'' ) ');
The error I get is the following:
Parse error: syntax error, unexpected [ in line 60
I want it to remove " [GS] " and leave the name empty.
Example:
The SQL query:
UPDATE PS_GameData.dbo.Chars SET CharName = replace (CharName, '**[GS]**' ,'')
You get this result:
[GS]Juan
In this case, I want to make "John" just without the content inside the bracket.
The SQL query works fine but I need to adapt this functionality using php.
Example:
$result3 = mssql_query(' UPDATE Ps_GameData.dbo.Chars
SET CharName = \'**[**\'+\'**GS**\'+\'**]**\' + CharName ');
It works excellent, but now I want to remove it and I can't find the way I know that replace is used but I can't place the character configuration so that the bracket is part of the SQL php query
I want to remove the [ character before GS as such synthesis would be:
$result3 = mssql_query("UPDATE Ps_GameData.dbo.Chars
SET CharName = replace (CharName,'\'[ '\','')
You are escaping the character in the wrong quote. Instead of being like this
\''
:It should be like this otherwise
'\'
:You can see that the code editor colors the string correctly now.
Also, as I put in a comment, you could make it all easier if instead of wrapping everything with single quotes, you used a combination of single and double quotes, so you wouldn't have to worry about escaping things inside your string: