By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,827 Members | 2,244 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,827 IT Pros & Developers. It's quick & easy.

error when posting to mysql w/ php

P: n/a
If someone can help me out with this i would really appreciate it. I'm kind of new so don't bash my code too bad!!

This is the error:
Parse error: parse error, unexpected T_VARIABLE in /srv/www/htdocs/sendinfo.php on line 45

This is the code:
<?php
$fname=$_POST['fname'];
$lname=$_POST['lname'];
$address=$_POST['address'];
$address2=$_POST['address2'];
$address3=$_POST['address3'];
$citye=$_POST['city'];
$state=$_POST['state'];
$zip=$_POST['zip'];
$phone=$_POST['phone'];
$email=$_POST['email'];
$subject="Data Added";
$f*******@YYY.com;
$ipaddress = $_SERVER['REMOTE_ADDR'];

mail("XX*@XXX.com",$subject, "Street Address: $address\r\nCity:$city\r\nZip: $zip\r\nIP: $ipaddress", "FROM: $from\r\n");
echo "Your IP address is: $ipaddress";
?>

<?php
$username="XXX";
$password="XXXX";
$database="XXXX";
$localhost="localhost";
$fname= mysql_escape_string($_POST['fname']);
$lname= mysql_escape_string($_POST['lname']);
$address= mysql_escape_string($_POST['address']);
$address2= mysql_escape_string($_POST['address2']);
$address3= mysql_escape_string($_POST['address3']);
$city= mysql_escape_string($_POST['city']);
$state= mysql_escape_string($_POST['state']);
$zip= mysql_escape_string($_POST['zip']);
$phone= mysql_escape_string($_POST['phone']);
$email= mysql_escape_string($_POST['email']);
$ipaddress=mysql_escape_string($_SERVER['REMOTE_ADDR']
$conn=mysql_connect($localhost, $username, $password) or die("Unable to setup connection"); //This is the line the error is referencing
mysql_select_db($database,$conn) or die( "Unable to select database");
$query = "INSERT INTO leads VALUES('$fname','$lname','$address','$address2','$ address3','$city','$state','$zip','$phone','$email ',$ipaddress)";
echo $query;
mysql_query($query) or die("Error: ".mysql_error());
mysql_close();
?>
Jul 17 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
SuSe newbie wrote:
If someone can help me out with this i would really appreciate it. I'm
kind of new so don't bash my code too bad!!

<code snip>

Missing semicolon on line above one with the error

~Cameron
Jul 17 '05 #2

P: n/a
thanks Cameron,
now i'm getting an error on that line for
Parse error: parse error, unexpected ';' in /srv/www/htdocs/sendinfo.php on
line 43
any ideas??
"Cameron" <fo*@bar.invalid> wrote in message
news:bv**********@news5.svr.pol.co.uk...
SuSe newbie wrote:
If someone can help me out with this i would really appreciate it. I'm
kind of new so don't bash my code too bad!!

<code snip>

Missing semicolon on line above one with the error

~Cameron

Jul 17 '05 #3

P: n/a
SuSe newbie wrote:
thanks Cameron,
now i'm getting an error on that line for
Parse error: parse error, unexpected ';' in /srv/www/htdocs/sendinfo.php on
line 43
any ideas??
"Cameron" <fo*@bar.invalid> wrote in message
news:bv**********@news5.svr.pol.co.uk...
SuSe newbie wrote:
If someone can help me out with this i would really appreciate it. I'm
kind of new so don't bash my code too bad!!


<code snip>

Missing semicolon on line above one with the error

~Cameron



ah yes sorry, on the same line that had the missing semicolon there is
also a missing ) so it should end with );
Jul 17 '05 #4

P: n/a
Missing closing parentheses on that line.

--
Chris Dingman
Webmaster
Cabaret Theatre
http://www.cabarettheatre.org

Now selling officially licensed Cabaret Theatre merchandise
"SuSe newbie" <jk******@sc.rr.com> wrote in message
news:rz*********************@twister.southeast.rr. com...
thanks Cameron,
now i'm getting an error on that line for
Parse error: parse error, unexpected ';' in /srv/www/htdocs/sendinfo.php on line 43
any ideas??
"Cameron" <fo*@bar.invalid> wrote in message
news:bv**********@news5.svr.pol.co.uk...
SuSe newbie wrote:
If someone can help me out with this i would really appreciate it. I'm kind of new so don't bash my code too bad!!

<code snip>

Missing semicolon on line above one with the error

~Cameron


Jul 17 '05 #5

P: n/a
Thanks guys, i've gotten rid of those bugs now. I figured it was something
stupid. I hope this is the last time i'll ask, but i'm getting a new error
now. Check this out and let me know what you think:
Your IP address is: XX.XX.XX.XX INSERT INTO leads
VALUES('test','test','test','test','test','test',' sc','55555','5555555555','
an**@anon.com',XX.XX.XX.XX)Error: You have an error in your SQL syntax near
'.148.78)' at line 1
"Chris Dingman" <di****@cabarettheatre.org> wrote in message
news:rD******************@nwrdny03.gnilink.net...
Missing closing parentheses on that line.

--
Chris Dingman
Webmaster
Cabaret Theatre
http://www.cabarettheatre.org

Now selling officially licensed Cabaret Theatre merchandise
"SuSe newbie" <jk******@sc.rr.com> wrote in message
news:rz*********************@twister.southeast.rr. com...
thanks Cameron,
now i'm getting an error on that line for
Parse error: parse error, unexpected ';' in /srv/www/htdocs/sendinfo.php

on
line 43
any ideas??
"Cameron" <fo*@bar.invalid> wrote in message
news:bv**********@news5.svr.pol.co.uk...
SuSe newbie wrote:
> If someone can help me out with this i would really appreciate it. I'm > kind of new so don't bash my code too bad!!
>
<code snip>

Missing semicolon on line above one with the error

~Cameron



Jul 17 '05 #6

P: n/a
I got it, Thanks!!
"SuSe newbie" <jk******@sc.rr.com> wrote in message news:Tp*********************@twister.southeast.rr. com...
If someone can help me out with this i would really appreciate it. I'm kind of new so don't bash my code too bad!!

This is the error:
Parse error: parse error, unexpected T_VARIABLE in /srv/www/htdocs/sendinfo.php on line 45

This is the code:
<?php
$fname=$_POST['fname'];
$lname=$_POST['lname'];
$address=$_POST['address'];
$address2=$_POST['address2'];
$address3=$_POST['address3'];
$citye=$_POST['city'];
$state=$_POST['state'];
$zip=$_POST['zip'];
$phone=$_POST['phone'];
$email=$_POST['email'];
$subject="Data Added";
$f*******@YYY.com;
$ipaddress = $_SERVER['REMOTE_ADDR'];

mail("XX*@XXX.com",$subject, "Street Address: $address\r\nCity:$city\r\nZip: $zip\r\nIP: $ipaddress", "FROM: $from\r\n");
echo "Your IP address is: $ipaddress";
?>

<?php
$username="XXX";
$password="XXXX";
$database="XXXX";
$localhost="localhost";
$fname= mysql_escape_string($_POST['fname']);
$lname= mysql_escape_string($_POST['lname']);
$address= mysql_escape_string($_POST['address']);
$address2= mysql_escape_string($_POST['address2']);
$address3= mysql_escape_string($_POST['address3']);
$city= mysql_escape_string($_POST['city']);
$state= mysql_escape_string($_POST['state']);
$zip= mysql_escape_string($_POST['zip']);
$phone= mysql_escape_string($_POST['phone']);
$email= mysql_escape_string($_POST['email']);
$ipaddress=mysql_escape_string($_SERVER['REMOTE_ADDR']
$conn=mysql_connect($localhost, $username, $password) or die("Unable to setup connection"); //This is the line the error is referencing
mysql_select_db($database,$conn) or die( "Unable to select database");
$query = "INSERT INTO leads VALUES('$fname','$lname','$address','$address2','$ address3','$city','$state','$zip','$phone','$email ',$ipaddress)";
echo $query;
mysql_query($query) or die("Error: ".mysql_error());
mysql_close();
?>
Jul 17 '05 #7

P: n/a

$citye=$_POST['city'];

I dont know if you have noticed but the varible here has an e on the end of
city but everywhere else it does not
Jul 17 '05 #8

P: n/a
SuSe newbie wrote:
Thanks guys, i've gotten rid of those bugs now. I figured it was
something stupid. I hope this is the last time i'll ask, but i'm
getting a new error now. Check this out and let me know what you
think: Your IP address is: XX.XX.XX.XX INSERT INTO leads
VALUES('test','test','test','test','test','test',' sc','55555','5555555555','
an**@anon.com',XX.XX.XX.XX)Error: You have an error in your SQL syntax
near
'.148.78)' at line 1


Everything in the values section is quoted (surrounded by single quotes)
except the IP address.
--
I won't rise to the occaasion, but I'll slide over to it.
Jul 17 '05 #9

P: n/a
On Tue, 27 Jan 2004 05:21:27 +0000, SuSe newbie wrote:
thanks Cameron,
now i'm getting an error on that line for Parse error: parse error,
unexpected ';' in /srv/www/htdocs/sendinfo.php on line 43
any ideas??

<snip!>
Parse Error *always* means "syntax error". Meaning that you have a missing
semicolon, curly brace, unclosed double-quote, extra parentheses, etc.

Basically, a typo. Syntax errors can be very hard to find.

--
-------------------------
| Jeffrey Silverman |
| jeffrey-AT-jhu-DOT-edu|
-------------------------

Jul 17 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.