homepage Welcome to WebmasterWorld Guest from 54.226.180.223
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Syntax Error
near 'from email = 'someone@somewhere.com'' at line 1
icorange




msg:3639902
 10:56 pm on May 1, 2008 (gmt 0)

I'm sorry to bother you all again ... I wrote a email subscription using the new mysqli language (had it working beautifully on my computer) ... was given some wrong advice (elsewhere) and I changed everything to mysql ... after the help here (yay!), I found what I thought was my last error ... but now when I use the form, after uploading to GoDaddy (database 4.1) I get this error ... did I miss something in the conversion or perhaps went back too far with the coding? Please, please help ... I would REALLY, REALLY appreciate it! I'm just too new at this ... thank you

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'from email = 'someone@somewhere.com'' at line 1

Here is my complete code:

<?php

function doDB() {
global $conn;

$conn = mysql_connect(someserver.net', 'username', 'password')
or die(mysql_error());

mysql_select_db("database") or die(mysql_error());

}
function emailChecker($email) {
global $conn, $check_result;

$check = "select id from subscription from email = '$email'";
$check_result = mysql_query($check,$conn) or die(mysql_error());
}

if ($_POST[op] !="ds") {

$display_block = "
<form method=POST action=\"$_SERVER[PHP_SELF]\">

<p><strong>Your E-Mail Address:</strong><br>
<input type=text name=\"email\" size=40 maxlength=150>

<p><strong>Action:</strong><br>
<input type=radio name=\"action\" value=\"sub\" checked> subscribe
<input type=radio name=\"action\" value=\"unsub\"> unsubscribe

<input type=hidden name=op value=ds>

<p><input type=submit name=\"submit\" value=\"Submit Form\"></p>
</form>";

} else if (($_POST[op] == "ds") && ($_POST[action] == "sub")) {

if ($_POST[email] == "") {
header("Location: form.php");
exit;
}
doDB();

emailChecker($_POST[email]);

if (mysql_num_rows($check_results) < 1) {

$sql = "insert into subscription values('', '$_POST[email]')";
$result = mysql_query($sql,$conn) or die(mysql_error());
$display_block = "<p>Thanks for signing up!</p>";
} else {
$display_block = "<>You're already subscribed!</P>";
}
} else if (($_POST[op] == "ds") && ($_POST[action] == "unsub")) {
if ($_POST[email] == "") {
header("Location: form.php");
exit;
}
doDB();

emailChecker($_POST[email]);

if (mysql_num_rows($check_result) < 1) {

$display_block = "<p>Couldn't find your address!</p>
<p>No action was taken.</p>";
} else {

$id = mysql_result($check_result, 0, "id");
$sql = "delete from subscription where id = '$id'";
$result = mysql_query($sql,$conn) or die(mysql_error());
$display_block = "<p>You're unsubscribed!</p>";
}
}
?>

 

Duskrider




msg:3639910
 11:07 pm on May 1, 2008 (gmt 0)

$check = "select id from subscription from email = '$email'";

Shouldn't that be:
"select id from subscription where email = '$email'

icorange




msg:3639958
 12:02 am on May 2, 2008 (gmt 0)

YOU PEOPLE ARE THE ABSOLUTE BEST! Can't say enough THANKS!

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved