Can someone help me with this code. I have been trying to switch over to the mysqli for php5 and I'm hoping I just missed a couple of quotes or something. Here is the code which is just inserting data into mysql.
<?php
//form not yet submitted
if (!$submit)
{
?>
<html>
<head>
<title>Add a Company</title>
</head>
<SCRIPT LANGUAGE="JavaScript">
function toForm() {
document.company.company_name.focus();
}
</script>
<body onLoad="toForm()" BGCOLOR=#FFFFFF topmargin="0" leftmargin="0" marginheight=0 marginwidth=0 rightmargin=0 bottommargin=0>
<center>
<table border=0 cellpadding=3 cellspacing=0 width=100% vailn=top>
<!-- server side include leftside nav table -->
<table border=0 cellpadding=3 cellspacing=0 width=99%>
<form name=company method="post" action="<?php echo $PHP_SELF; ?>">
<input type="hidden" name="comp_id" value="<?php echo "$comp_id"; ?>">
<tr>
<td width=100%><div align="center"><br>
<table width="345" border="0">
<tr>
<td bgcolor="#000066"><div align="center"><font color="#FFFFFF" size="4"><strong><em>Add
a company</em></strong></font></div></td>
</tr>
</table>
<br>
</div>
<table cellspacing=3 cellpadding=5 align="center" bgcolor='#e7f6b9'>
<tr>
<td> <p><strong>Name:</strong><br>
<input type="text" name="company_name" size=50 maxlength=75>
</p>
<p><strong>Address:</strong><br>
<input type="text" name="company_address" size=50 maxlength=75>
</p>
<p><strong>City:</strong><br>
<input type="text" name="company_city" size=50 maxlength=75>
</p>
<p><strong>State:</strong><br>
<input type="text" name="company_state" size=50 maxlength=75>
</p>
<p><strong>Zip:</strong><br>
<input type="text" name="company_zip" size=50 maxlength=75>
</p>
<p><strong>Company Phone (main number):</strong><br>
<input type="text" name="company_phone" size=50 maxlength=75>
</p>
<p><strong>Company Fax (main number):</strong><br>
<input type="text" name="company_fax" size=50 maxlength=75>
</p>
<p><strong>Company Website:</strong><br>
<input type="text" name="company_website" size=50 maxlength=75>
</p></td>
</tr>
<tr>
<td align="center"> <p>
<input type="submit" name="submit" value="Submit Company">
</p></td>
</tr>
<tr> </tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<?
}
else
{
/ mysql hostname /
$hostname = 'localhost';
/ mysql username /
$username = 'user';
/ mysql password /
$password = 'password';
/ mysql database name /
$dbname = 'test';
/ create a new mysqli object with default database/
$mysqli = @new mysqli($hostname, $username, $password, $dbname);
/ check connection /
if(!mysqli_connect_errno())
{
/ if we are successful /
echo 'Connected Successfully<br />';
/*** sql to INSERT a new record ***/
$sql = "INSERT INTO elements set
comp_name = '$company_name',
comp_address = '$company_address',
comp_city = '$company_city',
comp_state = '$company_state',
comp_zip = '$company_zip',
comp_phone = '$company_phone',
comp_fax = '$company_fax',
comp_website = '$company_website'";
if($mysqli->query($sql) === TRUE)
{
echo 'New record created successfully<br />';
}
else
{
echo $sql.'<br />' . $mysqli->error;
}
/*** close connection ***/
$mysqli->close();
}
else
{
/ if we are unable to connect /
echo 'Unable to connect';
exit();
}
}
?>
I keep getting an Parse error: parse error, unexpected $end in - which usually is about a missing bracket or something. I can't seem to find it. Any help would be greatly appreciated and will keep me from going bald. Thanks.
A