5 Replies - 489 Views - Last Post: 10 October 2013 - 04:22 PM Rate Topic: -----

#1 IntelligentTurtle  Icon User is offline

  • D.I.C Head

Reputation: -4
  • View blog
  • Posts: 50
  • Joined: 25-July 13

PHP Unexpected variables error?

Posted 10 October 2013 - 11:30 AM

I'm making a file to sign-up to my website which stores the details in a MySQL database, but when I upload it to my website and test it out, it says this:

Parse error: syntax error, unexpected T_VARIABLE in /home/a9288925/public_html/users/sign-up.php on line 8

The code for my file is this:

<?php
$mysql_host = "MY_MYSQL_SERVER";
$mysql_database = "MY_DATABASE";
$mysql_user = "MY_USER";
$mysql_password = "MY_PASSWORD";

$user = $_GET["user"]
$pass = $_GET["pass"]
$email = $_GET["email"]

$con = mysqli_connect($mysql_host,$mysql_database,$mysql_user,$mysql_password);

if (mysqli_connect_errno($con)) {
  echo "Oh Noes! An Error: " . mysqli_connect_error();
}

if (mysqli_query($con,"CREATE TABLE".$user."(Password CHAR(30),Email CHAR(30))";)/>)
{
  mysqli_query($con,"INSERT INTO".$user."(Password, Email)VALUES (".$pass.",".$email.")");
}
else
{
  echo "Error creating table: " . mysqli_error($con);
}

mysqli_close($con);
?>



If anyone can debug the code and give me a fix, Thanks in advance.

Is This A Good Question/Topic? 0
  • +

Replies To: PHP Unexpected variables error?

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9579
  • View blog
  • Posts: 36,298
  • Joined: 12-June 08

Re: PHP Unexpected variables error?

Posted 10 October 2013 - 11:35 AM

Lines 7-9... they are missing semi-colons.. why?

Moving to PHP.
Was This Post Helpful? 1
  • +
  • -

#3 IntelligentTurtle  Icon User is offline

  • D.I.C Head

Reputation: -4
  • View blog
  • Posts: 50
  • Joined: 25-July 13

Re: PHP Unexpected variables error?

Posted 10 October 2013 - 11:36 AM

ooooooh. I am an idiot.
Was This Post Helpful? 0
  • +
  • -

#4 andrewsw  Icon User is offline

  • It's just been revoked!
  • member icon

Reputation: 3838
  • View blog
  • Posts: 13,589
  • Joined: 12-December 12

Re: PHP Unexpected variables error?

Posted 10 October 2013 - 11:40 AM

You will also need a space between TABLE and your user:

"CREATE TABLE".$user."

The same for "INSERT INTO".
Was This Post Helpful? 0
  • +
  • -

#5 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3577
  • View blog
  • Posts: 10,442
  • Joined: 08-June 10

Re: PHP Unexpected variables error?

Posted 10 October 2013 - 12:30 PM

on a side note, you must never save passwords in plain text. best hash your passwords with password_hash() or (if youíre not on PHP 5.5+) bcrypt (crypt using BLOWFISH) or hash_hmac() (using at least (!!!) the ripemd160 or sha256 algorithms).

PS. donít forget to adjust the DB field size depending on the hash used.
Was This Post Helpful? 0
  • +
  • -

#6 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6111
  • View blog
  • Posts: 23,671
  • Joined: 23-August 08

Re: PHP Unexpected variables error?

Posted 10 October 2013 - 04:22 PM

Wait a minute....you're creating a TABLE for every USER that signs up? And saving cleartext passwords? And not using SQL injection prevention methods?

Someone is totally unclear on the concept.

Check out this tutorial and its comments to get a better understanding of what's required here.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1