Page 1 of 1

problem with mysqli r/n

Posted: Wed Sep 05, 2012 5:14 am
by mekha
hi guys...when i insert some text in the database...
i get it like this:

r/n my texttttttt/r/n/

...
i tryedd to use:

$string = $mysqli->real_escape_string($string2);

and nothing happen :S...any help please ?

Re: problem with mysqli r/n

Posted: Wed Sep 05, 2012 5:54 am
by Celauran
I don't see anything in that string that needs escaping, so I don't see a problem.

Re: problem with mysqli r/n

Posted: Wed Sep 05, 2012 6:30 am
by mekha
right..no need...but what with the r/n// ... i tryed to remove the escaping...i still get /r/n// ... and tryed to update...the same problem...no clean results :S....still with /r/n//

Re: problem with mysqli r/n

Posted: Wed Sep 05, 2012 6:54 am
by s.dot
If you don't escape it and still get \r\n in your string then it's in your original string. That or you're manipulating it when pulling it from the database and printing it. Show us more of your code.

Re: problem with mysqli r/n

Posted: Wed Sep 05, 2012 7:00 am
by mekha
this is my code :

Code: Select all

$sqlm = getPageById();
					if ($resultm = $mysqli->prepare($sqlm)) 
					{
						$mypageid = 216;
						$resultm -> bind_param("i",$mypageid); 
						$resultm->execute();	
						$resultm->store_result();
						$rowsm = $resultm->num_rows;
					}
					if($rowsm > 0)
					{
						$rowm = fetch($resultm);
						$pagetitle = $mysqli->real_escape_string($rowm[0]["page_title"]);
						$pageContent = $rowm[0]["page_content"];
						$pageurlname = $mysqli->real_escape_string($rowm[0]["page_name_url"]);
						
					}
and this is the "echo":

Code: Select all

<?=$pageContent?>

Re: problem with mysqli r/n

Posted: Wed Sep 05, 2012 7:01 am
by mekha
and this is my query:

Code: Select all

function getPageById()
	{
		$sqlStr = "select * from tbl_pages where page_id = ?";
		return $sqlStr;
	}

Re: problem with mysqli r/n

Posted: Wed Sep 05, 2012 7:02 am
by mekha
and this is what i send in post:

Code: Select all

$mysqli->real_escape_string ($_POST["page_content"]);

Re: problem with mysqli r/n

Posted: Thu Sep 06, 2012 11:33 pm
by mekha
ok thank u guys... i solved it :D....
this is the solution:
i removed real_escape_string from $_POST["somename"];
....
and sure from the row.....in the row no need....

now when using a prepared statement in the query(insert,update,delete,select)...you do not need to use the real_escape_string in mysqli...because the prepared statement "makes the job"..
thank you every one ;) :D :!: