Hi guys, I tried to load content to my host. It successfully uploaded, but I get a white page when I try to view the site. I can access the games on the site (it's basically a game site) by adding an extension on the end of the web address, so the site is active, but the front main landing page of the site is totally white, with nothing on it. When I tried to create an SQL database on my host, this is the finished product that was created(on the 4th line down, I replaced "your password" with my actual password) and I uploaded what you see as the config php file to my host; <?php //Connect To Database $hostname='p41mysql181.secureserver.net'; $username='wintersdan'; $password='your password'; $dbname='wintersdan'; $usertable='your_tablename'; $yourfield = 'your_field'; mysql_connect($hostname,$username, $password) OR DIE ('Unable to connect to database! Please try again later.'); mysql_select_db($dbname); $query = 'SELECT * FROM $usertable'; $result = mysql_query($query); if($result) { while($row = mysql_fetch_array($result)){ $name = $row['$yourfield']; echo 'Name: '.$name; } } ?> I see the middle blue section of the script indicates "for die" and also "unable to connect to database" I don't understand what would cause that, but it certainly does seem to indicate a problem.....any ideas? thanks..!
code looks correct. regarding ... OR die(..) construction, php calculates logical operator 'xxx OR yyy' in the following way: - calculate xxx - if xxx is true (or can be converted to true), then stop calculation, entire OR construction is true - if not, calculate next opeand yyy so, if mysql_connect returns true, die will not be run you can convert this OR to if operator if(!mysql_connect (...)) { die(...); }
You certainly have a better grasp than I do, as I'm a novice..... are you suggesting I make any specific change? It was difficult for me to discern if you were...........but I did catch that you said "the code looks correct" any other suggestions if that is the case? I don't know how to proceed...
If the die() is executing. It means that the MySQL connection isn't being established. Usually this means either the hostname, username, or password being used is wrong.
Try changing that blue line to this: mysql_connect($hostname,$username, $password) OR DIE (mysql_error()); PHP: I replaced the string in die() with mysql_error(), which returns a MySQL error if one is registered. Do that and it will let you know the reason you can't connect.
Thanks Shoro, the username and password I've verified...my host company verified the host name was correct Equaite, thanks for the suggestion. I did as you said, and this error was return on the main web page, instead of the previous blank or white display, the following was displayed; Parse error: parse error, unexpected '[' in /home/content/d/a/n/dannyboy1/html/config.php on line 10 dannyboy1 is my username to access this specific hosting account