Jump to content

[SOLVED] Can't connect to local MySQL server through socket


Petrushka

Recommended Posts

I created a test web form, that successfully input the data into my test database. However, today I created a second form, added the layout code, putting the layout and mysql connection details into a php include code.

 

These are the only changes I have made, apart from field names etc, but today, I get the following error message:

 

Warning: mysql_query(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/fhlinux177/f/further-flight.co.uk/user/htdocs/napsters/enter.php on line 50

 

Warning: mysql_query(): A link to the server could not be established in /home/fhlinux177/f/further-flight.co.uk/user/htdocs/napsters/enter.php on line 50

Your nap has been added to the database. Good Luck!

 

I checked, but the nap hasn't been added to the database.

 

I use the code I found on phpmac.com. It currently looks like this:

 

<?php
include("http://www.further-flight.co.uk/items/000183834.php");
?>

<?php
include("http://www.further-flight.co.uk/items/04545387.php");
?>

<body>

<div id="main">
<?php
if (!isset($_POST['submit'])) {
?>
<form action="" method="post">

<table border="0" cellpadding="5" cellspacing="0" width="100%">
   <tr>
       <td width="33%">Stable:</td>
       <td width="33%"><input type="text" name="stable"></td>
       <td width="33%"> </td>
   </tr>
   <tr>
       <td width="33%">Time:</td>
       <td width="33%"><input type="text" name="time"></td>
       <td width="33%">Please use 24 format i.e. 14:25</td>
   </tr>
   <tr>
       <td width="33%">Track:</td>
       <td width="33%"><input type="text" name="track"></td>
       <td width="33%"> </td>
   </tr>
   <tr>
       <td width="33%">Horse:</td>
       <td width="33%"><input type="text" name="horse"></td>
       <td width="33%">Please ensure names are spelt correctly!</td>
   </tr>
</table>

<input type="submit" name="submit" value="Submit!">
</form>


<?php
} else {

$stable 	= 	$_POST['stable'];
$time 		= 	$_POST['time'];
$track 		= 	$_POST['track'];
$horse 		= 	$_POST['horse'];

mysql_query("INSERT INTO `napster` (stable, time, track, horse) VALUES ('$stable', '$time','$track', '$horse')");

echo "Your nap has been added to the database.  Good Luck!";
}
?>

</div>
</body>
</html>

 

Any assistance in correcting this, and improving the code, would be very much appreciated.

 

Here is a screenshot of the code with line numbers: http://www.further-flight.co.uk/napsters/withlinenumbers.jpg

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.