Jump to content

fread() and quotes


rubing

Recommended Posts

I am writing a simple php autoresponder (email) script, which reads in email using fread().

 

#!/usr/bin/php -q
<?php
$fd = fopen("php://stdin", "r");
$email = "";
while (!feof($fd)) {
$email .= fread($fd, 1024);
}
fclose($fd);

 

I want to know if php can handle the use of quotation marks ' or " when assigned to a variable?  Does it automatically escape these and other bad characters (eg ; ) ??? 

Link to comment
https://forums.phpfreaks.com/topic/97794-fread-and-quotes/
Share on other sites

You didn't say anything about writing into mysql. To write a string properly in a database you have to do the following:

 

$str = 'This is " a test with \' Quotes';
mysql_query("INSERT INTO `table` SET `column` = '" . mysql_real_escape_string($str) . "'");

Link to comment
https://forums.phpfreaks.com/topic/97794-fread-and-quotes/#findComment-501226
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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