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='[email protected]' Address= 'User Name <[email protected]>,' ' 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
https://forums.phpfreaks.com/topic/129418-solved-update-sytax-probly-easy/
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.

 

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.