Re: Hello
| From: | Chris | Date: | Tue, 15 Dec 2009 02:41:37 +0000 |
| Subject: | Re: Hello | ||
| References: | 1 2 3 4 5 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-46697@lists.php.net to get a copy of this message | ||
Karl DeSaulniers wrote:
Hi Chris, On Dec 14, 2009, at 8:09 PM, Chris wrote:Did you try names with single quotes? (Tim O'Reilly is a common example to try).At one point I did have the mysql_real_escape_string() and it worked the same as without as far as populating the database.Problem 1 is sql injection. Wrap each variable in a mysql_real_escape_string call: insert into table (...) values ('" . mysql_real_escape_string($username) . "' ....
But when I would view results, it didnt read anything from the database.Sure it went in? Did you see the data when you viewed the table in phpmyadmin or some other tool?
I realise that. mysql_real_escape_string is used for data in your query, and may cause problems if used in limit clauses. If you end up with this for example: select * from table limit mysql_real_escape_string('blah'); of course it's not going work. Hence the check to make sure $min and $max_results are int's before passing them to the query so if anyone messes with them it won't break your queries. if (!is_int($min)) { $min = 0; } if (!is_int($max_results)) { $max_results = 5; }Again you need to escape all your data (except $min, $max_results - just make sure they are always integers).Those are so I can control the number of items shown per page.
Basically the result page would not show anything in the database unless it was inserted in the database using the $_POST method.That still suggests an error with the insert. -- Postgresql & php tutorials http://www.designmagick.com/