Jump to content

Me and this syntax issue


dlyles

Recommended Posts

I swear I'm going to get this together and eliminate the need for simple post.  In the meantime, can someone tell me what's wrong with this?

[code]
$mygroup=$_COOKIE['group'];
$partname=mysql_real_escape_string($_POST['partname']);
$newquery="select * from parts where PartName = '" . $partname . "'";
$newresult=mysql_query($newquery);
$balance = $row['balance'] - mysql_real_escape_string($_POST['amountreceived'])';


$sql = "insert into parts (GroupID, ModelID, PartName, Cost, balance)
          VALUES ('" . $mygroup .
                      "', '" . $mymodel .
                      "', '" . mysql_real_escape_string($_POST['partname']) .
                      "', '" . mysql_real_escape_string($_POST['cost']) .
                      "', '" . $balance . "')";
$nresult = mysql_query($nsql) or die("Error 2: query: $nsql<br>" . mysql_error());
[/code]
the error is in the $mygroup value.
Link to comment
https://forums.phpfreaks.com/topic/29138-me-and-this-syntax-issue/
Share on other sites

wight want to try it like this
[code] $sql = "insert into parts (GroupID, ModelID, PartName, Cost, balance)
          VALUES ('".$mygroup."',
                      '".$mymodel."',
                      '".mysql_real_escape_string($_POST['partname'])."',
                      '".mysql_real_escape_string($_POST['cost'])."',
                      '".$balance."')";[/code]

Same think but why would you enter right in the middle of the insert??
echo your sql statement and see if $mygroup is there

[code] $sql = "insert into parts (GroupID, ModelID, PartName, Cost, balance)
          VALUES ('" . $mygroup .
                      "', '" . $mymodel .
                      "', '" . mysql_real_escape_string($_POST['partname']) .
                      "', '" . mysql_real_escape_string($_POST['cost']) .
                      "', '" . $balance . "')";

echo $sql;
// $nresult = mysql_query($nsql) or die("Error 2: query: $nsql<br>" . mysql_error());[/code]

Ray

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.