Parse error too! PLz Help!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
examprep
Forum Newbie
Posts: 3
Joined: Wed Mar 24, 2004 11:18 pm
Location: Montreal
Contact:

Parse error too! PLz Help!

Post by examprep »

I am getting the same error too.... but abit more

Warning: Unexpected character in input: ''' (ASCII=92) state=1 in E:\Websites\examprep.ca\writedata.php on line 7

Warning: Unexpected character in input: ''' (ASCII=92) state=1 in E:\Websites\examprep.ca\writedata.php on line 8

Parse error: parse error, unexpected T_INCLUDE in E:\Websites\examprep.ca\writedata.php on line 9


<FORM ACTION="/writedata.php" method = "post" name = "myform">
<p>Last Name:
<input name="lname" type="text" id="lname">
First Name:
<input name="fname" type="text" id="fname">
</p>
<p>Student #:
<input name="studentnum" type="text" id="studentnum">
</p>
<p>Email:
<input name="email" type="text" id="email">
</p>
<p>Phone:
<input name="phone1" type="text" id="phone1">
(daytime)</p>
<p>
Phone:
<input name="phone2" type="text" id="phone2">
(Nightime)</p>
<p>Courses: (Please check off the courses you would like to pre-register for)</p>
<p>
<input name="MATH203" type="checkbox" id="MATH203" value="checkbox">
MATH 203 (Calculus I) </p>
<p>
<input name="MATH205" type="checkbox" id="MATH205" value="checkbox">
MATH 205 (Calculus II)</p>
<p>
<input name="EMAT213" type="checkbox" id="EMAT213" value="checkbox">
EMAT 213 (Differential Equations) </p>
<p>
<input name="EMAT233" type="checkbox" id="EMAT233" value="checkbox">
EMAT 233 (Advanced Calculus)</p>
<p>
<input name="ECON201" type="checkbox" id="ECON201" value="checkbox">
ECON 201 (MicroEconomics)</p>
<p>
<input name="CHEM205" type="checkbox" id="CHEM205" value="checkbox">
CHEM 205 (General Chemistry I)</p>
<p>
<input name="COMM210" type="checkbox" id="COMM210" value="checkbox">
COMM 210 (Contemporary Business Thinking)</p>
<p>
<input name="COMM215" type="checkbox" id="COMM215" value="checkbox">
COMM 215 (Business Statistics)</p>
<p>
<input name="COMM217" type="checkbox" id="COMM217" value="checkbox">
COMM 217 (Financial Accounting)</p>
<p>
<input type="submit" value="Submit">
</p>
</form>


There's a bunch of form validation stuff not to worry about

--->config.cfg

$writefile = "email";
$outfile = "emails.txt";
$writestring =
//$_POST["lname"].",".$_POST["fname"].",".$_POST["studentnum"].",".$_POST["email"].",".$_POST["phone1"].",".$_POST["phone2"].",".$_POST["MATH203"].",".$_POST["MATH205"].",".$_POST["EMAT213"].",".$_POST["EMAT233"].",".$_POST["ECON201"].",".$_POST["CHEM205"].",".$_POST["COMM210"].",".$_POST["COMM215"].",".$_POST["COMM217"]."\n";

?>

--> writedata.php
<?php

include("config.cfg");

// Open file for APPENDING! NO DATA LOST!!!
if(!$fd = fopen($outfile, "a")) {
echo("Error opening file.");
exit;}

// Write the string to the file.
if(!fwrite($fd, $writestring)) {
echo("Error writing to file.");
exit;}

fclose($fd);

include("thankyou.htm");
?>

Please Please help would appreciate it.
examprep
Forum Newbie
Posts: 3
Joined: Wed Mar 24, 2004 11:18 pm
Location: Montreal
Contact:

Post by examprep »

the // before the post was unintentional...
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

(You can edit your own posts after making it, so you change mistakes.)

A general rule I use is that if you are mixing a line with both variables (in an array) and text, use single quotes for the array variables and double quotes for the line. It makes things that much less confusing, and it's easier to spot your parse errors.
examprep
Forum Newbie
Posts: 3
Joined: Wed Mar 24, 2004 11:18 pm
Location: Montreal
Contact:

Post by examprep »

so sth like:
$_POST['lname'].",".$_POST['fname']. .......
Post Reply