How to connect to mysql in MapReduce temporarily?

How Do i Fix the Error... Warning: mysql_connect(): Can't connect to MySQL server on 'localhost' (10061)?

  • here's my code for "checklogin.php" NOTE: this all works on my local computer but i want to upload it to my website, but when i do it doesn't work, here's the source: <?php $host='localhost:3307'; // Host name $username='xxxxxx; // Mysql username $password='xxxxxx'; // Mysql password $db_name='test'; // Database name $tbl_name='members'; // Table name // Connect to server and select databse. $conn = mysql_connect($host, $username, $password)or die('cannot connect'); mysql_select_db($db_name)or die('cannot select DB'); // username and password sent from form $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; // To protect MySQL injection (more detail about MySQL injection) $myusername = stripslashes($myusername); $mypassword = stripslashes($mypassword); $myusername = mysql_real_escape_string($myusername); $mypassword = mysql_real_escape_string($mypassword); $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1){ // Register $myusername, $mypassword and redirect to file "login_success.php" session_register('myusername'); session_register('mypassword'); header("location:login_success.php"); } else { header("location:login_failure.php"); } ?> please help im excellent with html and css but im really new to php any tips will help !!

  • Answer:

    Just try this part for now: <?php $host='localhost:3307'; // Host name $username='xxxxxx; // Mysql username $password='xxxxxx'; // Mysql password // Connect to server and select databse. $conn = mysql_connect($host, $username, $password)or die('cannot connect'); ?> And make sure your mysql server is running.

Dray Delosier at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

Of course it won't work on your hosting server! You have to do three things: 1. Set-up the database on your hosting (use Cpanel) 2. Set a db user => username, password 3. Replace these variables with the new ones: $host (usually you domain name) $username (the one you defined - could be you cpanel login) $password (") $db_name (the one you defined creating the DB)

just "JR"

When you upload the code to your website, it very well might no longer be "localhost". Try setting "$host = 'the.website.com:3307"; Or contact your website company's Customer Service and ask them what it's supposed to be -- they could have changed all sorts of things, including the port number.

Unca Alby

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.