Petrushka Posted June 28, 2007 Share Posted June 28, 2007 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 https://forums.phpfreaks.com/topic/57582-solved-cant-connect-to-local-mysql-server-through-socket/ Share on other sites More sharing options...
chocopi Posted June 28, 2007 Share Posted June 28, 2007 i only ever get that error if i forget to include my sql connection Link to comment https://forums.phpfreaks.com/topic/57582-solved-cant-connect-to-local-mysql-server-through-socket/#findComment-285024 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.