|
|
|
Question :
========
i want to replace special characters like " ' " with " \' ".
my script is barfing whenever i do a read from the database with a " ' " in it.
i use javascript to insert the backslash into the hidden input of my form so i
can execute an insert with no problem
its on the read i need to reinsert the backslash from php
Answer :
======
You are on the wrong track here. This problem is inherently solved by
PHP.
First, you don't need to use JavaScript to escape the quotes. By default,
PHP's magic_quotes_gpc option is turned on. This means that all data
going trhough a FORM GET, FORM POST or a Cookie will be automatically
escaped.
Second, when you read things back from the database, if
magic_quotes_runtime is enabled, your quote characters will be escaped as
well. This can get confusing, so this option is off by default. PHP has
two built-in functions that let you do this yourself quickly.
AddSlashes() will add slashes in the appropriate places to a string, and
StripSlashes() will remove them. So, there is no need to start trying to
do this yourself with regular expressions. However, for future reference,
you will want to have a log at the ereg_replace() function.
|
|
| Point and Click Interface ala MS Access for creating SQL statements. Categories : MySQL, Complete Programs, General SQL, PHP, Databases | | | Is there some possibility to link a database to an htaccess file, so that instead of having a passwd file you would have a database with DES-crypted password and username fields? Categories : Authentication, PHP, General SQL, Databases | | | phpEasySQL - Easily connect to your MySQL database with just 1 php file and 3 easy steps! Categories : Databases, PHP, MySQL, General SQL | | | Logs hits to any page which includes it. Automatically utilises page access information left behind by PHP/FI2.0. Categories : Databases, PHP, mSQL, Databases | | | This function will populate the options in a drop down HTML select list
in a form from a database query.
Categories : MySQL, General SQL, PHP, HTML and PHP, Databases | | | I`d like to use the mysql_fetch_row function along with a "randomizer"
function that would give me a random result from a mySQL table. Categories : General SQL, MySQL, PHP, Databases | | | Sql Builder Categories : PHP, HTML and PHP, Databases, General SQL, Form Processing | | | This is a class with functions that are taken from simple SQL statements.
I made it to have an easier connection between PHP3 and DBase files. Categories : General SQL, PHP, PHP Classes, Databases | | | google like search function with bolded search terms Categories : PHP, Search, Databases, General SQL | | | This program allows you to upload an ODBC ressource - i.e. an MS-Access database to a MySQL server. Categories : Databases, MySQL, Complete Programs, PHP, Databases | | | Dynamic WHERE CLAUSE depending on number of FORM FIELDS Categories : ODBC, General SQL, PHP, Complete Programs, Databases | | | Persistent connections - General information. Categories : General SQL, PHP, Databases | | | ADODB Database Wrapper Abstraction Library for PHP: MySQL, MSSQL,
Oracle, Interbase,ODBC, Microsoft Access and FoxPro. Categories : PHP Classes, Databases, PHP, General SQL, ODBC | | | Multiple Search using PHP and Mysql Categories : PHP, Databases, General SQL, MySQL | | | explode() and SQL blobs Categories : General SQL, Strings, PHP, Databases | |
|
|
|