Inserting values into a SQL Server Database
Posted: Tue Mar 29, 2005 9:47 pm
I am trying to insert some values into a SQL server table when the user submits a form. Below you will see my code, but for some reason I am getting the following error:
Parse error: parse error, unexpected T_VARIABLE in D:\SiteRefresh\www\usta_web\forms\OutsideSubmit\index.php on line 12
Anyone know what I am doing wrong?
feyd | Please review how to post code using
Parse error: parse error, unexpected T_VARIABLE in D:\SiteRefresh\www\usta_web\forms\OutsideSubmit\index.php on line 12
Anyone know what I am doing wrong?
Code: Select all
<?php if ($submitted) {
$name = $first_name . " " . $last_name;
$today = date("F j, Y, g:i a");
global $link;
$host="";
$user="";
$password="";
$database = ""
$first_name=$_POST['first_name'];
$last_name=$_POST['last_name'];
$title=$_POST['title'];
$company=$_POST['company'];
$phone=$_POST['phone'];
$email=$_POST['email'];
$headline=$_POST['headline'];
$url=$_POST['url'];
$link = mssql_connect($host,$user,$password)
or die ("couldn't connect to server");
$db = mssql_select_db($database,$link)
or die ("Couldn't select database");
$query = "INSERT INTO OutsideNewsRelease (FirstName,LastName,Title,Company,Phone,Email,Headline,URL) VALUES ('$first_name','$last_name','$title','$company','$phone','$email','$headline','$url')";
mysql_query($query)
mysql_close();
/* Display text to the browser */
print ("Your submission was successful.");
/* E-mail the administrator the information supplied in form */
mail("delobetc@gmail.com", "News Release Submission from $first_name $last_name",
"The following information was submitted by $name on $today<br><br>
---------------------------<br><br>
<strong>Name:</strong> $name<br>
<strong>Title:</strong> $title<br>
<strong>Company:</strong> $company<br>
<strong>Phone:</strong> $phone<br>
<strong>Email:</strong> $email<br><br>
<strong>Headline:</strong> <a href=$url>$headline</a><br><br>
", "Content-type: text/html; charset=iso-8859-1");
/* E-mail the person who filled out the form a confirmation message */
$message = "Dear $first_name $last_name,\n
Thank you for submitting your News Release to the USTA website.";
$subject = "Your News Release Submission to the USTA website";
mail("$email", $subject, $message, "From:delobetc@gmail.com");
} else {
print ("<form name=\"tlc_reg\" method=\"post\" enctype=\"multipart/form-data\" action=\"$PHP_Self\">");
?>
<table cellspacing="1" cellpadding="0" width="100%" border="0">
<tbody>
<tr>
<td valign="top" colspan="2">Please fill out all the fields below in order to submit your News Release to be published on the USTA website.<br><br><br></td>
</tr>
<tr>
<td><strong>First Name:</strong></td>
<td align="left"><input class="forms" size="35" style="BORDER-RIGHT: #cc0000 1px solid; BORDER-TOP: #cc0000 1px solid; BORDER-LEFT: #cc0000 1px solid; BORDER-BOTTOM: #cc0000 1px solid" name="first_name" value="" /> </td>
</tr>
<tr>
<td><strong>Last Name:</strong></td>
<td align="left"><input class="forms" size="35" style="BORDER-RIGHT: #cc0000 1px solid; BORDER-TOP: #cc0000 1px solid; BORDER-LEFT: #cc0000 1px solid; BORDER-BOTTOM: #cc0000 1px solid" name="last_name" value="" /> </td>
</tr>
<tr>
<td><strong>Title:</strong></td>
<td align="left"><input class="forms" size="35"style="BORDER-RIGHT: #cc0000 1px solid; BORDER-TOP: #cc0000 1px solid; BORDER-LEFT: #cc0000 1px solid; BORDER-BOTTOM: #cc0000 1px solid" name="title" value="" />
</td>
</tr>
<tr>
<td><strong>Company:</strong></td>
<td align="left"><input class="forms" size="35" style="BORDER-RIGHT: #cc0000 1px solid; BORDER-TOP: #cc0000 1px solid; BORDER-LEFT: #cc0000 1px solid; BORDER-BOTTOM: #cc0000 1px solid" name="company" value="" />
</td>
</tr>
<tr>
<td><strong>Phone:</strong></td>
<td align="left"><input class="forms" size="15" style="BORDER-RIGHT: #cc0000 1px solid; BORDER-TOP: #cc0000 1px solid; BORDER-LEFT: #cc0000 1px solid; BORDER-BOTTOM: #cc0000 1px solid" name="phone" value="" /> </td>
</tr>
<tr>
<td><strong>Email:</strong></td>
<td align="left"><input class="forms" size="35" style="BORDER-RIGHT: #cc0000 1px solid; BORDER-TOP: #cc0000 1px solid; BORDER-LEFT: #cc0000 1px solid; BORDER-BOTTOM: #cc0000 1px solid" name="email" value="" /> </td>
</tr>
<tr>
<td><strong>Headline (This is the title of your news release):</strong></td>
<td align="left"><input class="forms" size="35" style="BORDER-RIGHT: #cc0000 1px solid; BORDER-TOP: #cc0000 1px solid; BORDER-LEFT: #cc0000 1px solid; BORDER-BOTTOM: #cc0000 1px solid" name="headline" value="" /> </td>
</tr>
<tr>
<td><strong>News Release URL (ex. http://www.usta.org):</strong></td>
<td align="left"><input class="forms" size="35" style="BORDER-RIGHT: #cc0000 1px solid; BORDER-TOP: #cc0000 1px solid; BORDER-LEFT: #cc0000 1px solid; BORDER-BOTTOM: #cc0000 1px solid" name="url" value="" /> </td>
</tr>
<tr>
<td> </td>
<td align="middle" colspan="2">
<INPUT TYPE=HIDDEN NAME="submitted" VALUE="submitted">
<br />
<input class="mo_submit" type="submit" value="› Submit" onmouseover="style.backgroundColor='#ffffff'; style.cursor='hand';" onmouseout="style.backgroundColor='#FBFBE0';" /> <input class="mo_submit" type="reset" value="› Reset" onmouseover="style.backgroundColor='#ffffff'; style.cursor='hand';" onmouseout="style.backgroundColor='#FBFBE0';" /></td>
</tr>
</tbody>
</table>
</form>
<?php } ?>feyd | Please review how to post code using
Code: Select all
andCode: Select all
tags. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]