Jump to content

Warning: mysql_connect() [function.mysql-connect]: Can't connect to MySQL server


jtjtjthey

Recommended Posts

Hi guys! I'm having a new problem regarding posting an edited record in edit_form.php where the page contains mysql update functionality. For me, I seems to have no problem for mysql database connection in conncection.php dunno what to do with my coding as I have no idea regarding the problem shown as below:

 

Warning: mysql_connect() [function.mysql-connect]: Can't connect to MySQL server on 'localhost' (10048) in C:\Program Files\xampp\htdocs\notification_system\connection\connection.php on line 8

Could not connect: Can't connect to MySQL server on 'localhost' (10048)

 

The Update form coding is shown in below:

 

include("../connection/connection.php");

 

$error0=$_GET['error0'];

$checkbox[$i]=$_POST['ID'];

$error1=$_GET['error1'];

 

 

$edit=$_POST['edit'];

$cancel=$_POST['cancel'];

 

if($cancel)

{

header("Location:admin_main_page.php");

}

else

{

if($checkbox[$i])

{

$sql0="SELECT * FROM directory WHERE id = '$checkbox[$i]'";

$result0=mysql_query($sql0,$con);

$num=mysql_fetch_array($result0);

?>

 

 

 

 

  <?

}

else

{

header("Location:edit_form.php?error3=1");

}

?>

And the contents of connection.php are?

 

Hi thorpe thanks for reading my post. The connection.php code is shown in below:

 

<?php

// connect to database

$server_name = "localhost";

$host_name = "root";

$password = "";

$database = "notification_sys";

 

$con = mysql_connect($server_name,$host_name,$password);

if (!$con)

{

  die('Could not connect: ' . mysql_error());

}

 

mysql_select_db($database, $con);

?>

 

 

  • 1 year later...

What is your exact error message because your problem might or might not be the same?

 

The error message in the first post in the thread means that there is no mysql server running on the localhost computer or it is not listening on the default port number.

 

Are you doing this on your localhost computer and your know that you have a mysql server installed, it is running, and it is listening on the default port number 3306?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.