Jump to content

Select * from users where email = 123@abc.com


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='123@123.com'' 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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.