Jump to content

[SOLVED] Update Sytax (probly easy)


Brian W

Recommended Posts

I have a form that sends the data to this page for processing.

<?php require_once('../../Connections/Epm.php'); ?>
<?php //Check If Internal
$url = $_SERVER['HTTP_REFERER'];
$URLP = (parse_url($url));
if($URLP['host'] <> $Site) { die('This form will not work from an external address.'); }
//$Site is defined in my connection page along with a few other global variables.
?>
<?php include("../includes/functions.php");
check("1 2");//This is a function I built that checks user's access levels... 1 and 2 are both admin levels.
//Variables
$Username = "'".$_POST['Username']."'";
$Email = "'".$_POST['Email']."'";
$Address = "'".$_POST['Username']." <".$_POST['Email'].">,'";
$Level = "'".$_POST['Level']."'";
$ID = $_POST['ID'];

//SQL
mysql_select_db($database_Epm, $Epm);
$sql = "UPDATE `bexusers` SET Username=".$Username." Email=".$Email." Address= ".$Address." Level= ".$Level." Where ID= ".$ID;
$Update = mysql_query($sql, $Epm) or die(mysql_error());

header('Location: .././?P=Users');
?>

 

I get this error:

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 'Email='name@domain.com' Address= 'User Name <name@domain.com>,' ' at line 1

 

I think it has to do with the @ sign, but can't figure out why, how, or what to do. Any input is much appreciated.

 

Link to comment
Share on other sites

That worked, thanks revraz. My dumb @$$ forgot the commas because I'm a newb to hand writing the sql. I used to use Dreamweaver for doing this stuff but I've come to find that DW isn't very efficient and I the code it makes is often hard to read and/or hard to customize to particular needs. Plus, it'll be better in the future if I know by heart the syntax.

I used the ".$Variable." there, which as worked for me in the past... is there any advantage (besides being a shorter way) to placing the variables like you did?

 

Again, thank you.

 

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.