Jump to content

Select question


Leeder

Recommended Posts

$query = mysql_query("SELECT con, verified FROM `table` WHERE email='".$_POST['email']."'");

 

Can someone find the problem with this code, I've run through and edited my script a fewe times and the above line seems to be the problem.

Link to comment
Share on other sites

<?php
$query = mysql_query("SELECT con, verified FROM `table` WHERE email='".$_POST['email']."'");
?>

 

In and of itself, there is apparently nothing wrong with the code, but there are sooo many more variables than simply debugging parse errors. Besides the fact that this query is wide open to SQL injection, there are several things that we need to know: what are you attempting to do? Are you doing any checks on the email variable to assure that it contains what you think it contains? Have you run any debugging options on the query itself? Is your table really named "table" as your query implies?

 

I would recommend you try something like this for starters:

<?php
$sql   = "SELECT con, varified FROM `table` WHERE email = '{$_POST['email']}'";
$query = mysql_query($sql) or die(mysql_error() . "<br />\n<b>SQL:</b> $sql");
?>

Link to comment
Share on other sites

Aren't these different?

 

$query = mysql_query("SELECT con, verified FROM `table` WHERE email='".$_POST['email']."'");
$query = mysql_query("SELECT con, varified FROM `table` WHERE email = '{$_POST['email']}'");

 

?

 

email='".$_POST['email']."'
email = '{$_POST['email']}'

Link to comment
Share on other sites

Aren't these different?

 

email='".$_POST['email']."'
email = '{$_POST['email']}'

 

As fenway stated, the first two evaluate the same, but those two are very different. Consider the following:

<?php
$_POST['email'] = 'test@test.com';

// These will all echo "test@test.com"
echo $_POST['email'];
echo "$_POST[email]";
echo "{$_POST['email']}";

// This will echo "$_POST[email]"
echo '$_POST[email]';

// This will echo "{$_POST['email']}"
echo '{$_POST[\'email\']}';
?>

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.