I had an HTML form page with static dropdown lists and a results.php page. This worked fine. I then wanted to get the drop down list in the form page from a table and inserted some php code and saved it as a php page.
The table is Industry and the column IndName. (I also have an Industry column in Clients table which is where I want to insert IndName values)
I am now getting these errors:
4i dotCom - New Client Entry
Industry
Warning: Can\\'t connect to local MySQL server through socket \\'/tmp/mysql.sock\\' (111) in /opt/apache/htdocs/newclient.php on line 35
Warning: MySQL Connection Failed: Can\\'t connect to local MySQL server through socket \\'/tmp/mysql.sock\\' (111) in /opt/apache/htdocs/newclient.php on line 35
Warning: MySQL: A link to the server could not be established in /opt/apache/htdocs/newclient.php on line 35
Here is the top 35+ lines of the form page and further down the results page.
<head>
<title>4i dotCom - New Client Entry</title>
<STYLE TYPE=\\"text/css\\">
H1 {
font-weight: bold;
font-size: 12pt;
line-height: 12pt;
font-family: verdana;
font-variant: normal;
font-style: normal;
}
BODY {
color: black;
background-color: white;
background-image:src=\\"manual/images/4i_Logo.gif\\";
background-repeat: no-repeat;
font-family:verdana;
font-variant: normal;
font-style: normal;
font-weight: normal;
font-size: 10pt;
line-height: 11pt;
}
</style>
</head>
<align=\\"left\\"><IMG SRC=\\"manual/images/4i_Logo.gif\\" ALT=\\"4i Logo\\" BORDER=0>
<body>
<h1>4i dotCom - New Client Entry</h1>
<form action=\\"http://localhost/insert_client.php\\" method=\\"post\\">
<table border=0 font-size=8>
<tr><td>Industry</td><td>
<?
$results = mysql_query(\\"SELECT IndName FROM Industry ORDER BY IndName\\");
echo \\'<select name=\\"IndName\\">\\';
while( list($IndName) = mysql_fetch_row($results)){
echo \\"<option value=\\'$IndName\\'>$Ind Name\\";
}
echo \\"</select>\\";
?>
HERE IS RESULTS PAGE
<head>
<title>4i dotCom Entry Results</title>
</head>
<body>
<h1>4i dotCom Entry Results</h1>
<?
if (!$ClientName || !$ClientStNo || !$ClientStName || !$ClientPostCode || !$AreaCode || !$MainPhone || !$MainFax || !$MainEmail || !$MainContact || !$ConsultantID)
{
echo \\"You have not entered all the required details.<br>\\"
.\\"Please go back and try again.\\";
exit;
}
$ClientID = addslashes($ClientID);
$ClientName = addslashes($ClientName);
$ClientBldgName = addslashes($ClientBldgName);
$ClientStNo = addslashes($ClientStNo);
$ClientStName = addslashes($ClientStName);
$ClientStType = addslashes($ClientStType);
$ClientDistName = addslashes($ClientDistName);
$ClientCityName = addslashes($ClientCityName);
$ClientPostCode = addslashes($ClientPostCode);
$ClientCountry = addslashes($ClientCountry);
$AreaCode = addslashes($AreaCode);
$MainPhone = doubleval($MainPhone);
$MainFax = doubleval($MainFax);
$MainEmail = addslashes($MainEmail);
$MainContact = addslashes($MainContact);
$Comments = addslashes($Comments);
$MainContact = addslashes($MainContact);
$ConsultantID = doubleval($ConsultantID);
$db = @mysql_pconnect(\\"localhost.localdomain:3306\\", \\"root\\", \\"password\\");
if (!$db)
{
echo \\"Error: Could not connect to database. Please try again later.\\";
exit;
}
mysql_select_db(\\"4i_dotCom\\");
$query = \\"insert into Clients (ClientID, ClientName, ClientBldgName, ClientStNo, ClientStName,
ClientDistName, ClientCityName, ClientPostCode, ClientCountry, Industry, AreaCode, MainPhone, MainFax,
MainEmail, MainContact, Comments, ConsultantID, ClientStType) values
(\\'\\".ClientID.\\"\\', \\'\\".$ClientName.\\"\\', \\'\\".$ClientBldgName.\\"\\', \\'\\".$ClientStNo.\\"\\', \\'\\".$ClientStName.\\"\\',
\\'\\".$ClientDistName.\\"\\', \\'\\".$ClientCityName.\\"\\', \\'\\".$ClientPostCode.\\"\\', \\'\\".$ClientCountry.\\"\\',
\\'\\".$Industry.\\"\\', \\'\\".$AreaCode.\\"\\', \\'\\".$MainPhone.\\"\\', \\'\\".$MainFax.\\"\\', \\'\\".$MainEmail.\\"\\', \\'\\".$MainContact.\\"\\', \\'\\".$Comments.\\"\\', \\'\\".$ConsultantID.\\"\\', \\'\\".ClientStType.\\"\\')\\";
$result = mysql_query($query) or die(\\"Error: \\".mysql_error());
if ($result)
echo mysql_affected_rows().\\" client inserted into database.\\";
?>
</body>