mysql-real-escape-string

mysql_real_escape_string stopped working when I moved my code to another server

你。 提交于 2019-12-02 05:43:48
The following code works perfectly fine in my local xampp installation (Windows 7), but when I ported it over to a Win2K8 R2 server, the mysql_real_escape_string piece does not work. When I comment it out, it works fine. I am pretty sure this has something to do with the php.ini file but cannot pinpoint what it is. Perhaps my code should have been written differently to begin with. function add_asset($asset_type_ID, $org_ID, $asset_desc, $asset_cost, $asset_value, $purchase_date) { global $db; $asset_desc = mysql_real_escape_string($asset_desc); $query = "INSERT INTO assets (asset_ID, asset

Validating user input?

醉酒当歌 提交于 2019-12-01 18:19:30
问题 I am very confused over something and was wondering if someone could explain. In PHP i validate user input so htmlentitiies, mysql_real_escape_string is used before inserting into database, not on everything as i do prefer to use regular expressions when i can although i find them hard to work with. Now obviously i will use mysql_real_escape_string as the data is going into the database but not sure should i be using htmlentities() only when getting data from database and displaying it on a

Validating user input?

爱⌒轻易说出口 提交于 2019-12-01 18:10:26
I am very confused over something and was wondering if someone could explain. In PHP i validate user input so htmlentitiies, mysql_real_escape_string is used before inserting into database, not on everything as i do prefer to use regular expressions when i can although i find them hard to work with. Now obviously i will use mysql_real_escape_string as the data is going into the database but not sure should i be using htmlentities() only when getting data from database and displaying it on a webpage as doing so before hand is altering the data entered by a person which is not keeping it's

mysql_real_escape_string with Zend

安稳与你 提交于 2019-12-01 17:54:33
问题 I am developing a web application using zend framework. For select statements I have used following way. Ex: public function getData($name) { $sql = "SELECT * from customer where Customer_Name = '$name'"; return $this->objDB->getAdapter()->fetchAll ($sql); } This works fine. But If I send customer name as : colvin's place , The query fail. And I know it's because of the single quote. Earlier I used addslashes PHP function. But I saw it is not a good way to do this. This time I used mysql_real

insert XML data into mysql with php

拥有回忆 提交于 2019-12-01 14:42:51
Portion of xml file that represents the problem (the xml file has hundreds of customers record) <?xml version="1.0" encoding="utf-8"?> <test> <customer> <name>customer 1</name> <address>address 1</address> <city>city 1</city> <state>state 1</state> <zip>zip 1</zip> <phone>phone 1</phone> <buyerinfo> <shippingaddress> <name>ship to</name> <address>Ship address1</address> </shippingaddress> </buyerinfo> <shippingDetail> <saletax> <saletaxamount>2</saletaxamount> </saletax> </shippingDetail> </customer>... Below is my code //Xml string is parsed and creates a DOM Document object $responseDoc =

Sanitizing PHP/SQL $_POST, $_GET, etc…?

假装没事ソ 提交于 2019-12-01 11:31:47
Ok, this subject is a hotbed I understand that. I also understand that this situation is dependent on what you are using as code. I have three situations that need to be resolved. I have a form in where we need to allow people to make comments and statements that use commas, tildes, etc... but still remain safe from attacks. I have people entering in dates like this: 10/13/11 mm/dd/yy in English, can this be sanitized? How do I understand how to use htmlspecialchars() , htmlentities() and real_escape_string() correctly? I've read the php.net site and some posts here but this seems to me to be

Using mysql_real_escape_string with PDO (no connection to localhost server)

依然范特西╮ 提交于 2019-12-01 10:54:04
So I'm fairly paranoid and use mysql_real_escape_string() with PDO. I actually don't use prepared statements in PDO, so I do have to sanitize the inputs. When hosting on my own server, I'd create an unprivileged user on the local machine so mysql_real_escape_string() wouldn't fail and empty my variable (heh, now that's sanitization!). I realize this is a pretty fail solution, since if the db's don't have matching charsets, then there's no point to the sanitizing at all, but it worked for the interim. Now at my new host, I can't create an unpassworded, unprivileged user for the database... and

PHP's mysql_real_escape_string and MySQL Injection

佐手、 提交于 2019-11-30 23:19:06
I have been trying to figure out how exactly \x00, \n, \r, \, or \x1a can cause an SQL Injection (as it is mentioned at http://nl3.php.net/manual/en/function.mysql-real-escape-string.php ) I understand the idea of single quote and double quotes, but how and why I need to take care of the other items to make my query safe? I was wondering about the same question and I found the answer in the C API documentation of MySQL , it states: Characters encoded are “\”, “'”, “"”, NUL (ASCII 0), “\n”, “\r”, and Control+Z (\x1a). Strictly speaking, MySQL requires only that backslash and the quote character

mysql_real_escape_string() just makes an empty string?

徘徊边缘 提交于 2019-11-30 18:57:03
I am using a jQuery AJAX request to a page called like.php that connects to my database and inserts a row. This is the like.php code: <?php // Some config stuff define(DB_HOST, 'localhost'); define(DB_USER, 'root'); define(DB_PASS, ''); define(DB_NAME, 'quicklike'); $link = mysql_connect(DB_HOST, DB_USER, DB_PASS) or die('ERROR: ' . mysql_error()); $sel = mysql_select_db(DB_NAME, $link) or die('ERROR: ' . mysql_error()); $likeMsg = mysql_real_escape_string(trim($_POST['likeMsg'])); $timeStamp = time(); if(empty($likeMsg)) die('ERROR: Message is empty'); $sql = "INSERT INTO `likes` (like

Should I use mysqli_real_escape_string or should I use prepared statements? [duplicate]

偶尔善良 提交于 2019-11-30 18:01:06
问题 This question already has answers here : How can I prevent SQL injection in PHP? (28 answers) Closed 6 years ago . Should I use mysqli_real_escape_string or should I use prepared statements? I've seen a tutorial now explaining prepared statements but I've seen them do the same thing as mysqli_real_escape_string but it uses more lines Are there any benefits for prepared statements? What do you think is the best method to use? 回答1: Prepared statements only. Because nowhere escaping is the same