Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

magic quotes

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

magic quotes

Postby Georgezx9 » Sat Apr 26, 2014 9:13 am

I have two different php files, that use the standard routine to sort out characters, one works one does not, one is used in reading data from an sql database, there other is in support of writing data, its this one that does not work. The standard routine is:

Code: Select all
function quote_smart($value, $handle) {

   if (get_magic_quotes_gpc()) {
       $value = stripslashes($value);
      echo 1;

   if (!is_numeric($value)) {
      $value = "'" . mysql_real_escape_string($value, $handle) . "'";
      echo 0;
   return $value;

Both use the following to call the function:
Code: Select all
$uname = quote_smart($uname, $db_handle);

I have interupted the code and printed out the variable.

One as an example gives and answer of work, whereas the other one to write to SQL gives and answer of 'work', with the apostrophes.

Both go to different tables in the same database, clearly the work one wont write to the database.

I f I don't call them, then I get an error with $num_rows

any suggestions gratefully recieved.

New php-forum User
New php-forum User
Posts: 9
Joined: Mon Mar 31, 2014 1:15 pm

Re: magic quotes

Postby seandisanti » Sat Apr 26, 2014 9:22 am

You're working from old example code, using deprecated functions. Switch to PDO and use pdo->quote()
php-forum Fan User
php-forum Fan User
Posts: 838
Joined: Mon Oct 01, 2012 12:32 pm

Return to PHP coding => General

Who is online

Users browsing this forum: Google [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.