GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 17-Apr-2007, 21:02
sgi sgi is offline
Awaiting Email Confirmation
 
Join Date: Apr 2007
Location: Ft Lauderdale, FL
Posts: 1
sgi is on a distinguished road
Question

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>&nbsp;</td></tr>          <tr>            <td align="center"><input type="hidden" name="Clicked!!!" value="formapp1" />              <input name="register" type="button" value="Register your business" />            &nbsp;&nbsp;&nbsp;            <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?
  #2  
Old 18-Apr-2007, 23:54
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 5,309
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: Parse error: unexpected ';' in /home/content/s/c/g/scgadbois/html/formap


Quote:
Originally Posted by sgi
Line 65 starts with:
PHP Code:

GetSQLValueString($_POST['fa_username'], "text"); // "" 



So: what is just before line 65?

PHP Code:

$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"); // "" 


You need a closing parenthesis for the sprintf():

PHP Code:

GetSQLValueString($_POST['fa_username'], "text")); 



Regards,

Dave
 
 

Recent GIDBlogInstall Adobe Flash - Without Administrator Rights by LocalTech

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' darkdante MySQL / PHP Forum 1 17-Apr-2007 16:08
Parse error: parse error, unexpected '}' in online 19 pembomassive MySQL / PHP Forum 4 27-Mar-2007 08:16
Apologies In Advance Parse error: parse error, unexpected T_STRING, expecting T_VARI sph2005 MySQL / PHP Forum 11 17-Jul-2006 09:28
Parse Error vigilantweather MySQL / PHP Forum 3 21-Feb-2006 12:24
Parse Error vigilantweather MySQL / PHP Forum 6 04-Feb-2006 13:15

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 09:47.


vBulletin, Copyright © 2000 - 2010, Jelsoft Enterprises Ltd.