famous58 Posted March 8, 2006 Share Posted March 8, 2006 OK, I'm really close to hurting something.Can someone take a look at this script and tell me if I have done anything wrong? It will not work, it returns a blank page. If nothing is wrong, is there some kind of php setting that could be causing this? For some reason the php set up on this server seems wacky.[code]<?php$Host = "localhost";$User = "user";$Password = "password";$DBName = "database";$TableName = "users";$Link = mysql_connect ($Host,$User,$Password);$Query = "SELECT * from $TableName";$Result = mysql_db_query ($DBName, $Query, $Link);while ($Row = mysql_fetch_array ($Result)) { print ("hello"); } ?>[/code]T.I.A. Quote Link to comment Share on other sites More sharing options...
php_b34st Posted March 8, 2006 Share Posted March 8, 2006 Try checking that you are connected, then check if your queryy worked:[code]<?php$Host = "localhost";$User = "user";$Password = "password";$DBName = "database";$TableName = "users";$Link = mysql_connect ($Host,$User,$Password); or die ("Couldn't connect to server.");$Query = "SELECT * from $TableName";$Result = mysql_db_query ($DBName, $Query, $Link);if ($result){ echo 'db connection';}else{ echo 'problem connecting to db';}while ($Row = mysql_fetch_array ($Result)) { print ("hello"); } ?> [/code] Quote Link to comment Share on other sites More sharing options...
famous58 Posted March 8, 2006 Author Share Posted March 8, 2006 [!--quoteo(post=352691:date=Mar 7 2006, 04:22 PM:name=php_b34st)--][div class=\'quotetop\']QUOTE(php_b34st @ Mar 7 2006, 04:22 PM) [snapback]352691[/snapback][/div][div class=\'quotemain\'][!--quotec--]Try checking that you are connected, then check if your queryy worked:[code]<?php$Host = "localhost";$User = "user";$Password = "password";$DBName = "database";$TableName = "users";$Link = mysql_connect ($Host,$User,$Password); or die ("Couldn't connect to server.");$Query = "SELECT * from $TableName";$Result = mysql_db_query ($DBName, $Query, $Link);if ($result){ echo 'db connection';}else{ echo 'problem connecting to db';}while ($Row = mysql_fetch_array ($Result)) { print ("hello"); } ?> [/code][/quote]Well, I have a problem connecting, but I've triple checked all the variables. How can I see where the connection problem lies?Edit: Nevermind, I'm retarded. Had the incorrect username Quote Link to comment Share on other sites More sharing options...
TylerL Posted March 8, 2006 Share Posted March 8, 2006 [code]$Link = mysql_connect ($Host,$User,$Password); or die (mysql_error());[/code]That should tell you your issues.I believe theres a query function as well that allows you to set a specific database...I think it's:bool mysql_select_db ( string database_name [, resource link_identifier] )[a href=\"http://us2.php.net/manual/en/function.mysql-select-db.php\" target=\"_blank\"]http://us2.php.net/manual/en/function.mysql-select-db.php[/a]Make sure you are using the proper database name. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.