Jump to content

Select question


Leeder

Recommended Posts

<?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
https://forums.phpfreaks.com/topic/51316-select-question/#findComment-252741
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'] = '[email protected]';

// These will all echo "[email protected]"
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
https://forums.phpfreaks.com/topic/51316-select-question/#findComment-253680
Share on other sites

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.