473,320 Members | 1,991 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Parse Error

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
3 2835
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
"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
> 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Steven | last post by:
I got a "Parse error: parse error in ..." in this line: if(empty($_POST){ ..... But if I fist assign $ssn=$_POST; and then if(empty($ssn){ ... it is working. Any advice? Thanks in advance.
1
by: H.L Bai | last post by:
hi, everybody i meet a parse error when i used the xml4c. any proposal is helpful. The error is following .../XMLRegionHandler.h:59 parse error before '*' .../XMLRegionHandler.h:60 parse...
2
by: Vittal | last post by:
Hello All, I am trying to compile my application on Red Hat Linux 8 against gcc 3.2.2. Very first file in application is failing to compile. I tried compiling my application on Linux 7.2...
21
by: BWIGLEY | last post by:
Basically I've just started making a game. So far it makes an array 25 by 20 and tries to make five rooms within it. In scr_make_room() there's parse errors: 20 C:\c\Rooms\Untitled1.c parse error...
6
by: trevor | last post by:
Incorrect values when using float.Parse(string) I have discovered a problem with float.Parse(string) not getting values exactly correct in some circumstances(CSV file source) but in very similar...
5
AdrianH
by: AdrianH | last post by:
Assumptions I am assuming that you know or are capable of looking up the functions I am to describe here and have some remedial understanding of C++ programming. FYI Although I have called...
1
AdrianH
by: AdrianH | last post by:
Assumptions I am assuming that you know or are capable of looking up the functions I am to describe here and have some remedial understanding of C programming. FYI Although I have called this...
1
by: Phaelle | last post by:
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' What does that error mean? I can´t find the mistake!! In another script, I have got another kind of mistake : parse...
2
by: Lawrence Krubner | last post by:
Imagine a template system that works by getting a file, as a string, and then putting it through eval(), something like this: $formAsString = $controller->command("readFileAndReturnString",...
5
by: goldtech | last post by:
SAX XML Parse Python error message Hi, My first attempt at SAX, but have an error message I need help with. I cite the error message, code, and xml below. Be grateful if anyone can tell me...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.