SQL query help

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
Georgezx9
New php-forum User
New php-forum User
Posts: 13
Joined: Mon Mar 31, 2014 1:15 pm

Sat Apr 12, 2014 2:24 pm

I have the following code which is giving the following error:

( ! ) Parse error: syntax error, unexpected ';' in C:\wamp\www\process-6.php on line 18 (the select from line)

Its a simple code, Name comes from a posted form field, user-name is the field name in the table.

Clearly simple but not simple enough for me. Any help gratefully appreciated.

Code: Select all

mysql_select_db($database) or die("Error connecting to database: ".mysql_error());
    	$username = $_POST['Name'];
	$query = ("SELECT * FROM Users WHERE User-Name = '$username'";
	$result mysql_query($query);

seandisanti
php-forum Fan User
php-forum Fan User
Posts: 973
Joined: Mon Oct 01, 2012 12:32 pm

Sat Apr 12, 2014 8:11 pm

also, User-Name is a bad field name. if you're going to do compound words use underscore. Otherwise, you have to quote the names so that it's not interpreted to be user minus name.

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 8 guests