Jump to content

Select * from users where email = [email protected]


kittrellbj

Recommended Posts

What I am trying to do is see if a email address exists in the database.  So, the database has field 'email' in the 'users' table.  I keep getting an error:

 

"Couldn't connect. 2You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''users' WHERE email='[email protected]'' at line 1"

 

The query looks like this:

 

$usertable = "users";
$regemail = $_POST['email'];

$reg_query = "SELECT * FROM '$usertable' WHERE email='$regemail'";
$reg_result = mysql_query($reg_query) or die("Couldn't connect. 2" . mysql_error());

 

Any ideas?  I've tried searching about a bit for an answer to this, but I don't quite see where the problem is.  It's not a complicated query, and the one right above it runs just fine (at least, it hasn't shot back any error code).  So, I'm thinking it has something to do with an @ symbol in a WHERE clause, but not sure how to repair it.

Link to comment
https://forums.phpfreaks.com/topic/172214-select-from-users-where-email-123abccom/
Share on other sites

or die("Couldn't connect. 2" . mysql_error());

 

I'm curious why you have the number 2 in there... :confused:

 

It's an internal coding system that I use in order to track my errors a little closer.  Each line that outputs an error shoots out an error code (in this case, "2") so that I know where it is coming from specifically in the program.

 

Edit: I know it is kinda redundant, but it helps me.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.