Portal Home > Knowledgebase > Articles Database > Help with PHP PEAR


Help with PHP PEAR




Posted by pwalters09, 02-09-2010, 11:26 AM
Hi guys, I am stuck on something very simple. I am trying to write my new script using PHP PEAR and MySQL, but for some reason when I test the script and register an account it comes up that the user already exists (there is no data in the SQL table) PEAR is installed on the server and I get no error when including DB.php so PEAR seems to be working... Here is the code: register.php db_connect.php check_login.php Can anyone help me? Thanks

Posted by Driver01, 02-09-2010, 12:04 PM
Stab in the dark as I can't see much wrong. remove the quotes: if ($name_checkk=="1") I presume thats the condition its breaking on?

Posted by pwalters09, 02-09-2010, 12:21 PM
it is where the error is but that is not the error, but i now think it is a problem with the server because it works fine on another server

Posted by mattle, 02-09-2010, 12:48 PM
Try running the query on the db directly... (btw, you should always validate user-submitted data before putting it in a query...what If I logged in as: See manual for mysql_real_escape_string() for more info) Now take the output of that print_r() and cut and paste it into your MySQL command line and examine the results...

Posted by pwalters09, 02-09-2010, 02:01 PM
SQL injections do not work on the script Login script It is definately a server issue because it works on my SQL server, so I just have to reconfigure my other server

Posted by mattle, 02-09-2010, 03:33 PM
Sorry, I overlooked your addslashes() calls. Typically, you would use a DBMS-specific function, however. From the addslashes() manual: Also, Pear:: DB has been superceded by Pear:: MDB2 (http://pear.php.net/package/DB). Furthermore, MDB2 uses old reference assignments ($a =& $b) which raise E_STRICT errors in current versions of PHP, a reporting level that PHP6 will include in E_ALL, btw. I would recommend you modernize and use PDO (http://php.net/manual/en/book.pdo.php) if you need a driver-switchable DB library. You also might want to look into using prepared statements anyway--in which most DB abstraction layers will not only safety any passed variables but DB-depending (including MySQL) can perform query optimization as well. Either way, the meat of my post remains true. Execute the generated query at the DB command line and you'll find out what's going on.



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
123-Reg.co.uk down? (Views: 804)

Language: