By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,807 Members | 1,492 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,807 IT Pros & Developers. It's quick & easy.

Parse Error

P: n/a
Rob
It's been driving me crazy...why is this returning a parse error? It says
the error is on the last line, I thought I was following the syntax....

<?php

$link = mysql_connect("localhost");
if(! $link)
die("Could not connect to MySQL");

$database = "PC_Store";
mysql_select_db($database)
or die ("could not open $database: ".mysql_error() );

$Choice = $_POST['myradio'];

$db = mysql_connect("localhost", "root");
mysql_select_db("PC_Store",$db);

if ($Choice = 'Sales Data') {
?>
<BR>
Enter The Fields For Entry Into SalesData Table
<form action="<?echo $PHP_SELF?>" method=POST>
<input type="text" name="TransID"size=10>TransID
<BR><input type="text" name="ProductID"size=10>ProductID
<BR><input type="text" name="TransCode"size=10>TransCode
<BR><input type="text" name="Date"size=10>Date
<BR><input type="text" name="UnitsSold"size=10>UnitsSold
<input type="submit" name="submit" value="Submit Data">
</form>
<?php
$result = mysql_query("INSERT INTO salesdata VALUES
($ProductID,$TransCode,$Date,$UnitsSold.)",$db)

}
Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Rob

Got it working....but it won't save to the database...

<HTML>
<HEAD>
<TITLE>PC_Store</TITLE>
</HEAD>
<BODY BGCOLOR=RED>
<?php

$link = mysql_connect("localhost");
if(! $link)
die("Could not connect to MySQL");

$database = "PC_Store";
mysql_select_db($database)
or die ("could not open $database: ".mysql_error() );

$Choice = $_POST['myradio'];

echo "<BR> you picked " . $_POST['myradio'] . "\n";

$db = mysql_connect("localhost", "root");
mysql_select_db("PC_Store",$db);

if ($Choice = 'Sales Data') {
?>
<BR>
Enter The Fields For Entry Into SalesData Table
<form action="<?echo $PHP_SELF?>" method=POST>
<input type="text" name="ProductID"size=10>ProductID
<BR><input type="text" name="TransCode"size=10>TransCode
<BR><input type="text" name="Date"size=10>Date (YYYY-MM-DD)
<BR><input type="text" name="UnitsSold"size=10>UnitsSold
<input type="submit" name="submit" value="Submit Data">
</form>
<?php
$result = mysql_query("INSERT INTO salesdata VALUES

('$ProductID','$TransCode','$Date','$UnitsSold')") ;

}

?>
<BR>
<FORM METHOD=POST ACTION = "PC_Store1.php">
<INPUT TYPE = "submit" VALUE ="Return To Main Menu">
</FORM>
Jul 17 '05 #2

P: n/a
"Rob" a écrit le 24/11/2003 :
It's been driving me crazy...why is this returning a parse error? It says
the error is on the last line, I thought I was following the syntax....


You forgot the final ; !
Last line becomes :
$result = mysql_query("INSERT INTO salesdata VALUES
($ProductID,$TransCode,$Date,$UnitsSold.)",$db);
Jul 17 '05 #3

P: n/a
> if ($Choice = 'Sales Data') {

More than likely, you probably want this to be

if ($Choice == 'Sales Data') {

(note the double equals). Your original code was setting $Choice to equal
'Sales Data', always returning true.

Chris Finke
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.