psychiccyberfreak 0 Report post Posted December 26, 2005 Hey.I'm having a problem with PHP, when I have a script access a database, it comes back blank... I was wondering why this happens and what I could do to fix it or if any of you could fix it. Yes, everything else in PHP works, Yes, I have tested this on multiple computers.Thanks for the help Share this post Link to post Share on other sites
fraudulentpeanut 0 Report post Posted December 27, 2005 I will try to help you out the best I can. What is it that you are trying to run exactly and is it happening with every query or just on one peticular query.It could be a problem as simple as it is not connecting to the database because of a user or pass error. Have you tried simply connecting to the database from a terminal(i dont know if you use linux) but i believe windows has a proggy to do it as well. If you are unable to connect to your database, then there is your problem. That is what it usually means when it spits back blank data. It could also be a problem with the php coding on the page that you are trying to access the sql database with. Please let me know if this helps, if not we can move on to the next troubleshooting. I would help me out a lot however if i could get my hands on the scripts that you are trying to execute that way i could take a look at the code.Thanks,JT Share this post Link to post Share on other sites
fraudulentpeanut 0 Report post Posted December 27, 2005 After writing this I noticed that there are a lot of problems on the forums with SQL downtimes. Just as a secondary though this could be the cause of the problem and it could start working again on its own. Share this post Link to post Share on other sites
psychiccyberfreak 0 Report post Posted December 27, 2005 yeah it would be all over the shoutbox if that were the case. I have tried many php pages, from PHP-nuke, to a simple comment script, nothing works. Share this post Link to post Share on other sites
fraudulentpeanut 0 Report post Posted December 27, 2005 hmmm... pm me your site and tell me how to reproduce it and I will try my hardest to fix it for you. Share this post Link to post Share on other sites
snlildude87 0 Report post Posted December 27, 2005 Are you trying to retrieve stuff from your database and then print it out or are you just using the SELECT query? Share this post Link to post Share on other sites
Tyssen 0 Report post Posted December 27, 2005 Is there any particular reason why you haven't posted the script that's giving you trouble? Pretty hard for people to diagnose accurately the problem when they don't even know what you're working with. Share this post Link to post Share on other sites
rvalkass 5 Report post Posted December 27, 2005 The thing a lot of people seem to get wrong on Trap 17 is that when you enter the database name, you have to prefix it with your username. For example, if you created a database called info the database name would be psychiccyberfreak_info. This only applies for T17. If you're running it on your own PC then you don't need to prefix it. Also, make sure you have done everything in the 'step-by-step' process. Connect to MySQLSelect the databaseCarry out the queryLoads of people miss out one of the first two, or both, and just expect it to intuitively know all your MySQL login data. As many people have said, having a copy of the script would be helpful. Share this post Link to post Share on other sites
DeveloperX 0 Report post Posted January 9, 2006 Also, make sure you have done everything in the 'step-by-step' process. Connect to MySQL Select the database Carry out the query I agree, these 3 points are required!This is example for 1st point: <?php $link = mysql_connect("localhost", "mysql_user", "mysql_password") or die("Could not connect: " . mysql_error()); print ("Connected successfully"); mysql_close($link);?> Where "mysql_user", "mysql_password" U must create in Your myPHPadmin Console. This is example for 2nd point: <?phpmysql_select_db('DB_name', $link);?> This is example for 3rd point: <?php$res = mysql_query("SELECT my_col FROM my_tbl") or die("Invalid query: " . mysql_error());$row = mysql_fetch_array($res);print_r($row); // Result: still return Array()?> And simple code for all points. The following query is not valid as expected: <?php$username = 'dicteworld';$username{4} = '';$sql = "SELECT * FROM `user` WHERE `User` = '$username'";print($sql); // Result: SELECT * FROM `user` WHERE `User` = 'dictworld'$res = mysql_query($query);$row = mysql_fetch_array($res);print_r($row);// Result: still return Array(), supposed that the user 'dictworld' exists.?> Pay more attention that null string '' is equivalent to '\0',therefore SQL statement above is equivalent to SELECT * FROM `user` WHERE `User` = 'dict\0world',though printing string is right. I find this on http://php.net/ Share this post Link to post Share on other sites