It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming PHP and MySQL Forum

Parse Error!!?

Moderator: Malcolm

Parse Error!!?

Postby Johnathan on Fri Mar 28, 2008 5:21 pm

Anyone know what's wrong with this? I get this error... Parse error: syntax error, unexpected ';' in /Applications/xampp/xamppfiles/htdocs/insert.php on line 19. I followed the steps on here and just changed the stuff in there to suit me. But it isn't working, I tried it the other night on an online DB and I though that was the problem but it isn't any ideas? The form works and it connects ok it' just that error.

Code: Select all
<!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=UTF-8" />
<title>Untitled Document</title>
</head>

<body>
<?php
$con = mysql_connect("localhost","TestUser","admin");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
// some code
mysql_select_db("TESTDB", $con);
mysql_query("INSERT INTO User (username, password, email, mobi_user)
VALUES
('$_POST[username]','$_POST[password]','$_POST[email]','$_POST[mobi])";
if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
mysql_close($con)

?>

</body>
</html>


Thanks in advance everyone.
Johnathan
1000+ Club
 
Posts: 1207
Joined: Thu May 31, 2007 3:28 pm
Location: Belfast, Northen Ireland

Postby flabbyrabbit on Fri Mar 28, 2008 6:32 pm

First off you missing a ' and a )
Code: Select all
mysql_query("INSERT INTO User (username, password, email, mobi_user)
VALUES
('$_POST[username]','$_POST[password]','$_POST[email]','$_POST[mobi])";

should be
Code: Select all
mysql_query("INSERT INTO User (username, password, email, mobi_user)
VALUES
('$_POST[username]','$_POST[password]','$_POST[email]','$_POST[mobi]')");


Flabby Rabbit
Image
User avatar
flabbyrabbit
500+ Club
 
Posts: 706
Joined: Thu Jan 25, 2007 1:10 pm
Location: Midlands, England

Postby Johnathan on Fri Mar 28, 2008 6:39 pm

Ok thanks for that but now I'm getting Error: Query was empty
Johnathan
1000+ Club
 
Posts: 1207
Joined: Thu May 31, 2007 3:28 pm
Location: Belfast, Northen Ireland

Postby flabbyrabbit on Fri Mar 28, 2008 6:48 pm

Well you havent actually set anything to $sql in if (!mysql_query($sql,$con))
And this is pretty much useless as long as you know that you code is working so just try deleting:
Code: Select all
if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }

Should work fine now.

Flabby Rabbit
Image
User avatar
flabbyrabbit
500+ Club
 
Posts: 706
Joined: Thu Jan 25, 2007 1:10 pm
Location: Midlands, England


Who is online

Users browsing this forum: No registered users and 0 guests