Search the Community
Showing results for tags 'brackets'.
-
function send_msg($sender , $message){ if(!empty($sender) && !empty($message)){ $sender = mysql_real_escape_string($sender); $message= mysql_real_escape_string($message); $query = "INSERT INTO `chat`.`chat` VALUES (null , '{$sender}' , '$message')"; // Difficulty on THIS LINE !!!! if($run = mysql_query($query)){ return true; }else{ return false; } } why is '{$sender}' given the curley brakets ????? and why is message not given the same brackets ? also why is this function used ? i.e. mysql_real_escape_string , i know what it does , but is it to prevent SQL injection.
-
I am coding a series of preg_replace expressions to try and strip unnecessary html/css code from text that was originally created using FCKEditor and is being copied programatically into CKEditor. All works well until I try to do a search/replace on a string that ends with a ">". No matter what I try this does not work, it either appears to do nothing or it errors and my resulting text is empty. In this case, if a table definition does not have a width defined, I want to add a width of 100%. The old/new strings and replace expression (str_replace in this case) are below. $oldstring = 'cellspacing="0">'; $newstring = 'cellspacing="0" width="100%">'; $textstring = str_replace($oldstring, $newstring, $textstring); It seems that the problem is related to the ">". If I take this out, it works ok. However I want to be sure that "cellspacing" is the last tag for a table definition (the tags were added automatically by FCKEditor and are always in the same order). Thanks for any help. I have been tearing my hair out for hours over this.
- 5 replies
-
- string
- expression
-
(and 2 more)
Tagged with: