worldcomingtoanend Posted September 11, 2009 Share Posted September 11, 2009 now i just signed up for my remote mysql database after which i created the code below: <?php $mysql_host = "ipadress"; $mysql_database = "name"; $mysql_user = "user"; $mysql_password = "wowowow"; $connection = mysql_connect($mysql_host, $mysql_user, $mysql_password, $mysql_database); $link = mysql_select_db($mysql_database,$connection) or die(mysql_error()); switch ($link) { case TRUE: echo "Connected ThankYou..."; break; case FALSE: echo "Not Connected"; } ?> surprisingly if i run my server and run the script nothing happens at all. Not even an error message is displayed. it just displays a blank page. where can i be going wrong. thank u. Quote Link to comment Share on other sites More sharing options...
Adam Posted September 11, 2009 Share Posted September 11, 2009 Not that this would be causing the problem, but the 4th parameter for mysql_connect isn't the database name; read the manual for more info. The methods you've used for connecting are a little unorthodox, but I can't see any reason why this wouldn't at least display an error. Ensure all error reporting is on and that the connection values are all correct... Perhaps then debug the code line by line to find the point where the code beaks. Quote Link to comment Share on other sites More sharing options...
gr1zzly Posted September 11, 2009 Share Posted September 11, 2009 Assuming that your connection data is correct for your specific server i.e. host name, user name etc. Try using an if condtional instead of a switch statement. Something like: if ($link) { echo "<h1>Connection successful</h1>\n"; } else { echo "<h1>Connection failed!</h1><br/>Debug: " . mysql_error($link) . "<br/>\n"; } Quote Link to comment Share on other sites More sharing options...
Adam Posted September 11, 2009 Share Posted September 11, 2009 Assuming that your connection data is correct for your specific server i.e. host name, user name etc. Try using an if condtional instead of a switch statement. Something like: if ($link) { echo "<h1>Connection successful</h1>\n"; } else { echo "<h1>Connection failed!</h1><br/>Debug: " . mysql_error($link) . "<br/>\n"; } Shouldn't matter as switch's based on loose comparison. Quote Link to comment Share on other sites More sharing options...
worldcomingtoanend Posted September 12, 2009 Author Share Posted September 12, 2009 Assuming that your connection data is correct for your specific server i.e. host name, user name etc. Try using an if condtional instead of a switch statement. Something like: if ($link) { echo "<h1>Connection successful</h1>\n"; } else { echo "<h1>Connection failed!</h1><br/>Debug: " . mysql_error($link) . "<br/>\n"; } Shouldn't matter as switch's based on loose comparison. guys i hv tried all i can but nothing seems to work...its strange really at least if an error message was shown i could work it around but its just silent...other php scripts work fine and dispay errors, etc but this one is just silent Quote Link to comment Share on other sites More sharing options...
ldb358 Posted September 12, 2009 Share Posted September 12, 2009 why is it that you use and "or die" stament then check if its true? this seems slightly counter prductive as you check it twice try adding: or trigger_error("error:" . mysql_error(), E_USER_ERROR to your first mysql statment Quote Link to comment Share on other sites More sharing options...
gr1zzly Posted September 15, 2009 Share Posted September 15, 2009 I would actually point to the first response from MrAdam. It seems to me like your assigning the database name twice! Passing your $mysql_database variable once as a parameter in the mysql_connect() statement should be enough. Only if you're connecting with just the host, user_name, password would you then need a separate mysql_select_db() statement AFAIN. I can post an example of the script I use to connect if that will help? 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.