Jump to content


Photo

code error.


  • Please log in to reply
2 replies to this topic

#1 eyehawk78

eyehawk78
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 07 February 2006 - 05:20 PM

hello, when i try to execute this script i get the error code
Parse error: syntax error, unexpected $end in C:\wamp\www\directory\test2.php on line 117
basically i just want the submitted form data to be passed into a database. could some offer another set of eyes to look over my code plz?

<HTML>
<HEAD>

<?php
function dbInsert(){

if(IsSet($_POST['submit'])){

$dbUser="99hawker";
$dbHost="localhost";
$dbName="tprint";
$dbPass="wdh240288";


$dbc=mysql_connect($dbHost,$dbUser,$dbPass);
$selected=mysql_select_db($dbName,$dbc);

$title=$_POST['Title'];
$firstname=$_POST['first_name'];
$lastname=$_POST['last_name'];
$address1=$_POST['address1'];
$address2=$_POST['address2'];
$towncity=$_POST['towncity'];
$countystate=$_POST['countystate'];
$country=$_POST['country'];
$postcodezip=$_POST['postcodezip'];
$emailaddress=$_POST['EmailAddress'];


$query1="INSERT INTO Customer_Info VALUES('$title', '$firstname', '$lastname', '$address1', '$address2', '$towncity', '$countystate', '$country', '$postcodezip', '$emailaddress')";

if(mysql_query($query1)){
print("succesful");
}
else{
print("Failed");
}

}

?>
</HEAD>
<BODY>



<FORM ACTION="<?php echo $_SERVER['PHP_SELF']; ?>" METHOD="POST">
<table align="center" border="0" cellpadding="0" cellspacing="0" width="600"><tr valign="top"><tr>
<td class="topSpacer" width="190"><img alt="" border="0" height="1" width="190"></td>
<td class="topSpacer" width="6"><img alt="" border="0" height="1" width="6"></td>
<td class="topSpacer" width="100%"><img alt="" border="0" height="1" width="1"></td>
</tr>
<tr>
<td class="label"><label for="Title">Title:</label></td>
<td width="6"><img alt="" border="0" height="1" width="6" name="Title"></td>
<td align="left"><select>
<option value="Mr">Mr</option>
<option value="Mrs">Mrs</option>
<option value="Miss">Miss</option>
<option value="Dr">Dr</option></select>
</tr>
<tr>
<td class="label"><label for="first_name">First Name:</label></td>
<td width="6"><img alt="" border="0" height="1" width="6"></td>
<td align="left"><input type="text" class="textLong" size="25" maxlength="32" name="first_name" value=""></td>
</tr>
<tr>
<td class="label"><label for="last_name">Last Name:</label></td>
<td width="6"><img alt="" border="0" height="1" width="6"></td>
<td align="left"><input type="text" id="last_name" class="textLong" size="25" maxlength="64" name="last_name" value=""></td>
</tr>
<tr>
<td class="label"><label for="address1">Address Line 1:</label></td>
<td width="6"><img alt="" border="0" height="1" width="6"></td>
<td align="left"><input type="text" id="address1" class="textLong" size="25" maxlength="100" name="address1" value=""></td>
</tr>
<tr>
<td class="label"><label for="address1">Address Line 2:</label></td>
<td width="6"><img alt="" border="0" height="1" width="6"></td>
<td align="left"><input type="text" id="address2" class="textLong" size="25" maxlength="100" name="address2" value=""></td>
</tr>
<tr>
<td class="label"><label for="Town/City">Town/City:</label></td>
<td width="6"><img alt="" border="0" height="1" width="6"></td>
<td align="left"><input type="text" id="Town/City" class="textLong" size="25" maxlength="100" name="towncity" value=""></td>
</tr>
<tr>
<td class="label"><label for="County/State">County/State:</label></td>
<td width="6"><img alt="" border="0" height="1" width="6"></td>
<td align="left"><input type="text" id="County/State" class="textLong" size="25" maxlength="100" name="countystate" value=""></td>
</tr>
<tr>
<td class="label"><label for="Postcode/ZIP">Postcode/ZIP Code:</label></td>
<td width="6"><img alt="" border="0" height="1" width="6"></td>
<td align="left"><input type="text" id="Postcode/ZIP" class="textLong" size="25" maxlength="100" name="postcodezip" value=""></td>
</tr>
<tr>
<td class="label"><label for="Country">Country:</label></td>
<td width="6"><img alt="" border="0" height="1" width="6"></td>
<td align="left"><select name="country" size="1">
(lots of countries)
</select></td>
</tr>
<tr>
<td class="label"><label for="EmailAddress">Email Address:</label></td>
<td width="6"><img alt="" border="0" height="1" width="6"></td>
<td align="left"><input type="text" id="EmailAddress" class="textLong" size="25" maxlength="100" name="EmailAddress" value=""></td>
</tr>
<tr>
<td class="label"><label for="EmailAddress">Repeat Email Address:</label></td>

line 117 <td width="6"><img alt="" border="0" height="1" width="6"></td>

<td align="left"><input type="text" id="EmailAddress2" class="textLong" size="25" maxlength="100" name="EmailAddress2" value=""></td>
</table>
<input TYPE="submit" NAME="submit" VALUE="Proceed" STYLE="font-size:13pt; background-color:#3399FF; color:#000000" onClick="php dbInsert()">

</FORM>
</BODY>
</HTML>

n e help would be greatly appreiciated, cheers

#2 wickning1

wickning1
  • Members
  • PipPipPip
  • Advanced Member
  • 405 posts

Posted 07 February 2006 - 05:55 PM

It looks like you're a little confused about the difference between Javascript and PHP.

Delete the line that says "function dbInsert(){", and remove the onClick="php dbInsert()" from your submit button, and I think you should be fine.

#3 eyehawk78

eyehawk78
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 07 February 2006 - 06:10 PM

thanks alot wickning1 that seems to of worked
cheers agen




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users