Parse error: unexpected ';' in /home/content/s/c/g/scgadbois/html/formap
Hi there ~
I'm trying to populate a dB with a simple HTML form and my PHP code is on the same page as my HTML just above the < doc type >
If line 65 ends with a semicolon ";" then I get the parse error shown in the title; however, if I take it out, it gives me the parse error, unexpected T_STRING in /home/content/s/c/g/scgadbois/html/formapp1/login.php on line 66
Here is my code:
PHP Code:
<?php require_once('Connections/conn_formapp1.php');//replace with your connection ?><?php/*from line 6 to line 41 its a function called "getSQLValueString" that correctlyformats and identifies all the variables, because they have to match their kind on the mySQL database */if (!function_exists("GetSQLValueString")) {function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue;}}// *** Redirect if username existsif (isset($_POST['Clicked!!!'])) { $loginUsername = $_POST['fa_username']; $LoginRS__query = sprintf("SELECT fa_username FROM tbl_formapp1 WHERE fa_username=%s", GetSQLValueString($loginUsername, "text")); mysql_select_db($database_conn_formapp1, $conn_formapp1); $LoginRS=mysql_query($LoginRS__query, $conn_formapp1); $loginFoundUser = mysql_num_rows($LoginRS); //if there is a row in the database, the username was found - can not add the requested username and will ask user to login (redirected to login.php) if($loginFoundUser){ //if this variable has ANY value == checking to see if userId is unique header ("Location:login.php"); // header = take me to existing page (reset) exit; }}if ((isset($_POST["Clicked!!!"])) && ($_POST["Clicked!!!"] == "formapp1")) {//if the form was submitted and it's the right form then $insertSQL = sprintf("INSERT INTO tbl_formapp1 (fa_bname, fa_baddress1, fa_bcity, fa_bstate, fa_bzip, fa_bphone, fa_username) VALUES (%s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['fa_bname'], "text"), // "" GetSQLValueString($_POST['fa_baddress1'], "text"), // "" GetSQLValueString($_POST['fa_bcity'], "text"), // "" GetSQLValueString($_POST['fa_bstate'], "text"), // "" GetSQLValueString($_POST['fa_bzip'], "text"), // "" GetSQLValueString($_POST['fa_phone'], "text"), // "" GetSQLValueString($_POST['fa_username'], "text"); // "" mysql_select_db($database_conn_formapp1, $conn_formapp1); $Result1 = mysql_query($insertSQL, $conn_formapp1) or die(mysql_error()); //go to the loginpageheader("Location: login.php"); //url if registration succeeded (this page takes me to ...)}?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>PHP w/Flash dB (formapp1)</title><style type="text/css"><!--.style1 {color: #990000;}#borderstyle { border: 1px groove #990000; width:44%;}--></style><script type="text/JavaScript"><!--function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x;}function MM_validateForm() { //v4.0 var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments; for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]); if (val) { nm=val.name; if ((val=val.value)!="") { if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@'); if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n'; } else if (test!='R') { num = parseFloat(val); if (isNaN(val)) errors+='- '+nm+' must contain a number.\n'; if (test.indexOf('inRange') != -1) { p=test.indexOf(':'); min=test.substring(8,p); max=test.substring(p+1); if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n'; } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; } } if (errors) alert('The following error(s) occurred:\n'+errors); document.MM_returnValue = (errors == '');}//--></script></head><body><table onfocus="MM_validateForm('fa_bname','','R','fa_baddress','','R','fa_bcity','','R','fa_bstate','','R','fa_bzip','','R','fa_bphone','','R','fa_username','','RisEmail');return document.MM_returnValue"> <tr colspan="3"> <td class="style1">Please complete the form to register your business with us.</td> </tr> <tr> <td><form id="formapp1" name="formapp1" method="post" action=""> <table> <tr> <td><label>Business Name: <input name="fa_bname" type="text" id="fa_bname" size="52" maxlength="50" /> </label> </td> </tr> <tr> <td><label>Business Address: <input name="fa_baddress" type="text" id="fa_baddress" size="48" maxlength="100" /> </label> </td> </tr> <tr> <td><label>City: <input name="fa_bcity" type="text" id="fa_bcity" size="23" maxlength="35" /> </label> State: <input name="fa_bstate" type="text" value="FL" id="fa_bstate" size="4" maxlength="2" /> Zip: <input name="fa_bzip" type="text" id="fa_bzip" size="13" maxlength="10" /> </td> </tr> <tr> <td><label>Tel: <input name="fa_bphone" type="text" id="fa_bphone" size="17" maxlength="14" /> </label> <label>Email: <input name="fa_username" type="text" id="fa_username" size="37" maxlength="255" /> </label></td> </tr> <tr><td> </td></tr> <tr> <td align="center"><input type="hidden" name="Clicked!!!" value="formapp1" /> <input name="register" type="button" value="Register your business" /> <input name="clear" type="reset" id="clear" value="Clear form" /></td> </tr> </table> </form></td> </tr></table></div></body></html>
Line 65 starts with:
GetSQLValueString($_POST['fa_username'], "text"); // ""
can anyone help me out?
|