NilsC
Jan 14 2005, 01:42 AM
I get this error message when I try to view a small webpage. QUOTE Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in /home/nilsc/public_html/bobs/processorder.php on line 27 Line 27 is in this php part: CODE <?php echo '<p>Order processed.</p>'; echo $tireqty. ' tires<br />'; echo $oilqty. ' bottles of oil<br />'; echo $sparkqty. ' spark plugs<br />'; $totalqty = 0; $totalqty = $tireqty + $oilqty + $spakqty; echo 'Items ordered: ' .$totalqty.'<br />; $totalamount = 0.00; define('TIREPRICE', 100); define('OILPRICE', 10); define('SPARKPRICE', 4); $totalamount = $tireqty * TIREPRICE + $oilqty * OILPRICE + $sparkqty * SPARKPRICE; echo 'Subtotal: $'.number_format($totalamount,2).'<br />; $taxrate = 0.10; // local tax is 10% $totalamount = $totalamount * (1 + $taxrate); echo 'Total including tax: $'.number_format(stotalamount,2).'<br /> ?> Line 27 is define['TIREPRICE', 100); The book seems to be using PHP5 and mySQL5 is the "define" something that is new to PHP5? Thanks Nils
Reply
ChronicLoser
Jan 14 2005, 02:34 AM
whenever it says QUOTE expecting ',' or ';' in /home/nilsc/public_html/bobs/processorder.php it means that you simply forgot a semicolon. And after a quick runthrough, i found that you forgot a semicolon here: CODE echo 'Total including tax: $'.number_format(stotalamount,2).'<br />
so add a (;) and you're done ^_^
Reply
NilsC
Jan 14 2005, 02:00 PM
I changed the ' in the define statement to ". I think I was defining an array instead of a constant. Now the error moved down to the echo 'Subtotal: $' line and I tried 2 different ways of formatting the $totalamount and I still get the same error different line: CODE define("TIREPRICE", 100); define("OILPRICE", 10); define("SPARKPRICE", 4); $totalamount = $tireqty * TIREPRICE + $oilqty * OILPRICE + $sparkqty * SPARKPRICE; echo 'Subtotal: $' .number_format($totalamount, 2, '.', ',').'<br />; $taxrate = 0.10; // local tax is 10% $totalamount = $totalamount * (1 + $taxrate); echo 'Total including tax: $' .number_format($totalamount, 2).'<br />; What am I overlooking here. I know I can pop the disk in that came with the book to get the code ready made but that will not teach me how to find errors in the code. I think I learn more by hacking it until I figure it out or.... Thanks for any pointers Nils
Reply
NilsC
Jan 14 2005, 11:20 PM
I found my error so anyone else who encounters the same problem... cross your t's and dot your i's  I had forgotten a ' after the <br /> CODE echo 'Items ordered: $'.$totalqty.'<br />'; $totalamount = 0.00; define('TIREPRICE', 100); define('OILPRICE', 10); define('SPARKPRICE', 4); $totalamount = $tireqty * TIREPRICE + $oilqty * OILPRICE + $sparkqty * SPARKPRICE; echo 'Subtotal: $'.$totalamount.'<br />'; $taxrate = 0.10; // local tax is 10% $totalamount = $totalamount * (1 + $taxrate); echo 'Total including tax: $'.number_format($totalamount,2).'<br />'; Here is the updated code that worked. Nils
Reply
ChronicLoser
Jan 15 2005, 12:07 AM
lol, sorry i didn't catch that for ya. I just saw a missing semicolon and decided that it was the problem so i didn't look through the rest =P glad you fixed it up though ^_^
Reply
NilsC
Jan 15 2005, 12:16 AM
I guess I have to be less sloppy while working on this. The biggest problem for me are missing the semicolons and use a capital S instead of $  It's killing me... but in order for me to learn I have to do the hack job... copying from the disc don't help me any. I'm learning! Nils
Reply
mastercomputers
Jan 15 2005, 12:08 PM
Hey, define is not new at all, this is how you can create constants in PHP, variables that can not be altered by your code. Say you defined MAX_FILE_SIZE: <?php if(!defined('MAX_FILE_SIZE')) // checks whether we've already set MAX_FILE_SIZE [/tab]define('MAX_FILE_SIZE', 8192); // sets MAX_FILE_SIZE to 8192 if(constant('MAX_FILE_SIZE')) // checks whether MAX_FILE_SIZE is a constant [tab]echo constant('MAX_FILE_SIZE'); // prints the constant MAX_FILE_SIZE if(defined('MAX_FILE_SIZE')) // checks whether MAX_FILE_SIZE is set MAX_FILE_SIZE++; // add 1 to MAX_FILE_SIZE (cannot do, error on this line) ?> Since I try altering MAX_FILE_SIZE by increasing it by 1, I would get a parse error on this line. You will encounter parse errors quite a lot and usually the message will help you find the problem, missing semi-colons or commas, etc. Although this message doesn't really help understand the problem, you should have a style that constants are all in capital letters, you may also like to prefix it with an underscore _ so it won't conflict with reserved keywords, not likely PHP but C/C++ you would. Cheers, MC
Reply
matty_023
Jan 31 2005, 05:04 AM
I find a good way to prevent missing apostrophes and other such things is to do sets together. When you implement your first ‘ implement your second straight away ‘’ then add the text inside ‘hello world’. As in SGML I build inwards. Doing so is just simple and prevents so many simple errors popping up later, though watch that insert button write over all your work lol. 1) <name></name> 2) <name>Matthew</name>
Reply
mastercomputers
Jan 31 2005, 05:28 AM
The text editor you use can also help you prevent such problems with syntax hilighting, colour coding, etc. This will allow you to pick up the problems more easily. I use UltraEdit under Windows, but you'll find there's quite a lot of others out there. On Linux anjuta for C/C++, Perl, etc, can be configured for any other languages too, but sometimes it's easier just using the provided text editor like kwrite. Again it's really personal preference in what you choose. I usually do most things in console anyways. Cheers, MC
Reply
NilsC
Jan 31 2005, 01:50 PM
I'm using first page 2000 for my php and html edits and EditPad Lite for the css code. Is there a css editor out there (that high lights syntax?) 1'st page 2000 works good for me and my needs right now. Does UltraEdit highlight the syntax on css sheets? or is that not possible. Working inwards, I'm doing that but not on a regular bases yet. I'm still memorizing the syntaxes and learning the basics. When I can write one simple page without going into the book looking at the syntax, then I'll graduate myself to the next level  I'm using 3 books to get the basics down, and web resources on w3schools and sitepoint and a few others. One of the books are CSS only, the second and third is php & mySQL (Introductory and intermediate). The basic template for the site is 80% done so I'm working on the css, html and php right now. Then when that is done I'll build the mySQL db for the dynamic data that is going onto the pages and the forms to use for populating the tables. Nils
Reply
Recent Queries:--
php missing semicolon no error-message - 339.78 hr back. (1)
-
max_file_size hack - 444.70 hr back. (1)
Similar Topics
Keywords : php error message working- How To Make A PM (Personal Message) System?
- (Should I Store The Data In A Database?) (5)
Hey! I just wanted to know, if I want to make a PM system, should I store the PMs in a database or
how should I do it? And if I should store them in a database, how do I do that. Because I have
acctually no idea, if I should create 50 tables to store 50 messages /tongue.gif"
style="vertical-align:middle" emoid=":P" border="0" alt="tongue.gif" /> (And a little OT question
). How can i change the timestamp into real date?...
Php Configuration Error?
- (6)
Cant Find The Error
- (2)
In this code I want to retrieve the energy and max energy of a players account, then add 8% to
energy of maxenergy, hen if energy is bigger than maxenergy, energy is then made equal to maxenergy.
Then the database is updated. I don't understand why it's not working.
$query=mysql_query("SELECT MAX(id) as maxid FROM `accounts` LIMIT 1"); $row =
mysql_fetch_assoc($query); $id = $row ; $query = "SELECT * FROM `accounts`";
$result=mysql_query($query); while ($row=mysql_fetch_assoc($result)) { $energy = $row ; $maxenergy
= $row ; } for($i=1; $i $query = "SELECT...
Can't Make This Query Working.
- (2)
Hi again. I am trying to make a new Register script. But now, there is only one thing that is not
working.. I can't make the following query work. CODE mysql_query("INSERT INTO
members(username, password, email, register_date) VALUES
('$user','$pass','$email', '$reg_date')") or die("Failed to
register. Error:".mysql_error()); this is the current date variable, that is causing the
error. (if I remove it from the query, it works just fine) CODE $reg_date=date("Y/m/d");
this is the error I am getting: QUOTE Error:...
Php Error-where To Put "?>"
- (2)
lol....lately i have many problems in writing my scripts and i dont know if i should create post
only for purpose so ppl can help me or should i create many post like i am doing right now...i am
NOT making this to get many credits...i am doing it because i need help and many people here help
me! CODE if ($_GET !='race'){ Who do you wanna race? Derbi Senda 50
Honda NS 50 R Suzuki ZR 50 Yamaha DT 50 MX Aprilia RS 50 - ?
} i have this code...if i put after it i get QUOTE Parse error: syntax...
Warning: Mysql_num_rows()
- What is the error :S (1)
Hey! I've made a register script.. Some time ago it worked. And I ain't sure if I changed
something since then.. The error I am getting is this: Warning: mysql_num_rows(): supplied argument
is not a valid MySQL result resource in /home/feelay/public_html/regcheck.php on line 31 Here is
the code on theese lines: CODE $sqlCheckForDuplicate = "SELECT username FROM user WHERE username
= '". $username ."'"; if( mysql_num_rows( mysql_query(
$sqlCheckForDuplicate ) ) == 0 ) { $sqlRegUser = "INSERT INTO ...
Php Math Error
- (4)
I cant get php to do simple math. Anyway
I need to run a math problem from the mysql database (dont ask why). So lets say I have an entrie: 5
+5. I get it from my db then eval it but nothing happens? How could I make it so that it runs the 5+
5 rather then just displaying it? Thanks, Sparkx Also: I have no clue if it is just my browser or
what but my post breaks to boarder for some odd reason?...
Unexpected Error
- Undefined variable??? (2)
Is this script correct? index.php : CODE if (isset($_COOKIE )) $_GET =
$_COOKIE ; else setcookie("disp_name", Anonymous, date()+99); ?>
Display Name - DZN
Dislpay Name: name="name" />
proccess.php : CODE Proccessing Request... Please wait...
setcookie("disp_name", $_GET , date()+99); ?> main.php : CODE function customErr...
Error On Submit Page
- (10)
I am writing a new submit page for one of my sites and am doing a few things to stretch my
experience. I am getting an error (naturally.) Here is part pf the page where the error might be:
CODE //Check to see if the web page called itself if (strtoupper($action) == "CHECK") {
//The web page called itself, so run the error checking code //Declare a variable to
hold the error messages $error = ''; // variable names: name, cat, sub_cat, url,
date, status, email, other, area_code, city $name = $_POST ; $cat = $_P...
Installed A PR Checker Script - But Not Working Correctly
- (6)
I'm new to PHP and still have much to learn. I came across a free script to check google PR.
You place a file called pagerank.php and then have an includes. So I did this: CODE ?>
Then I have my HTML (the page header and so forth), and added a form where they can input their URL.
The form action is CODE " method="post" name="checkpr" id="checkpr"> First of all ... I
seem to be missing something completely basic. My page isn't displaying at ALL as I expected.
No graphic header and no form. It's actually showing all my HTML code in...
Got A Wee Error - Can You Help?
- (13)
I'm taking a PHP course at college and am working on an assignment. There's no database
involved. I've declared my variables from a submit form on another page, and on the page
I'm working on I'm trying to bring them up in a table. But my start-table command is
outputting an error. Here's the code relating to where the error is: CODE //Get First
Item if (isset($_GET )) { $item_1_product = $_GET ; } else {
$item_1_product = ""; //Default value if data missing } if (isset($_GET ))
{ ...
E-mail List Error
- (4)
I just coded this e-mail list, it works well for entering data into database, but if user leaves
the field blank or adds an already exist e-mail it gives him the error message and stops loading the
rest of the page. CODE // Connects to your Database mysql_connect("localhost", "my_username",
"mypassword") or die(mysql_error()); mysql_select_db("Database name") or die(mysql_error()); //This
code runs if the form has been submitted if (isset($_POST )) { //This makes sure they did not leave
any fields blank if (!$_POST ) {die(' No e-mail added '); } ...
Coding A Private Message System
- would like assistance (4)
I am (trying) to code a private message system for my one website (the one I pay big bucks in... ok,
not big bucks, but a chunk of income). As being the first major script that I've ever coded, I
would like some assistance on the side. I've never tried anything such as this and the fact that
this is revolving around the core of my member's system (if I would have installed some
pre-built script, I could have easily intergraded my member's area) makes it a bit difficult as
it has to work off of my already existing database and user's table. I really...
Php Wget
- Its not working!!! (3)
A while ago I posted a thread asking if anyone knew anything about wget, and I was given the code
below: CODE $foo = system('wget http://www.whatever.com/file.html ~',$output); ?>
Which has been working fine, since the panda server failure a while ago. Since then, whenever I try
to use it , it comes up with QUOTE $foo = system('wget
http://www.gallifreyone.com/forum/customav...avatar646_8.gif ~',$output); ?> Has this been
disabled by the administrators, or is there a way I can sort it out?...
In Php, How To Not Display Mysql Connection Error?
- Don't want mysql_connect() message (4)
In PHP, if the mysql database server cannot be connected, for example database server is handed or
turned off, an error message will be displayed: Warning: mysql_connect(): Unknown MySQL Server Host
"mysql.example.com" ... My question is how to not display this warning message? or can I customise
the error message? if so, how? Thank you....
Mail() Not Working
- (4)
I'm trying to use the mail() function in a script. But it doesnt work. It keeps returning false.
It's a premade script The code is: CODE function SendPassword($userName) { global
$db,$db_tables;//config.php // set password for username to a random value // return the new
password or false on failure $new_password = mt_rand(); $qry = "UPDATE $db_tables SET
password=password('$new_password') WHERE user_name='$userName'";
$db->db_query($qry); // send notification email $from = "From: $from_email\r\n"; $msg = "You or
someone pretendi...
A Php Gallery Commenting Script Question...
- i am working on a php script... (2)
Hi all, i am working on a Gallery commenting script for myself and i got stuck at a part of it. I
would like each new comment added to an image to be a number as the text file name like 1, 2, 3.
everytime they add a comment the next file name is incremented (+1) and so on for example; if there
was a text file names '1' then the next would be named '2'. I know how to create
the file and the rest of it, but i would like to know how to do this. I should probably store the
last file name somehow and then add 1 to it to create the next file but i do not know...
Php Problem - Unique Counter
- my script isn't working correctly (4)
alright here's what I want to do: I made a counter to count unique visitors without a mysql. But
the problem is that the '.dat' file I'm writing on (unique.dat) tends to become too big
when I have too many visitors. Thus, I tried to add an if/then statement. Kay, now here's the
problem: even though this code successfully runs, it's not a hundred-percent accurate. Sometimes
it rewrites a user's IP even though it is already on the '.dat' file. Even though it
doesn't actually affect the $hits, I'd still like to know what I did w...
PHP paFileDB error
- an error relating to admin login. (2)
does any body know how to over come an error in paFileDB which says Warning: Cannot modify header
information - headers already sent by (output started at
/home/paltalkh/public_html/pafiledb/includes/mysql.php:86) in
/home/paltalkh/public_html/pafiledb/includes/admin/login.php on line 36 Warning: Cannot modify
header information - headers already sent by (output started at
/home/paltalkh/public_html/pafiledb/includes/mysql.php:86) in
/home/paltalkh/public_html/pafiledb/includes/admin/login.php on line 38 i have downloaded the php
from phparena.net directly. Any he...
script to send SMS message
- (6)
On my webiste (once I get hosted), I'd like to give users capability to SMS me. But the problem
is that, I don't know how to do it. So what I'm looking for is some script to send SMS
messages over the web. Any scripting language that astahost supports would do. Thanks in advance...
PHP paFileDB error
- an error relating to admin login (0)
does any body know how to over come an error in paFileDB which says Warning: Cannot modify header
information - headers already sent by (output started at
/home/paltalkh/public_html/pafiledb/includes/mysql.php:86) in
/home/paltalkh/public_html/pafiledb/includes/admin/login.php on line 36 Warning: Cannot modify
header information - headers already sent by (output started at
/home/paltalkh/public_html/pafiledb/includes/mysql.php:86) in
/home/paltalkh/public_html/pafiledb/includes/admin/login.php on line 38 i have downloaded the php
from phparena.net directly. Any hel...
Looking for php, problem, error, message, im, working, book
|
*SIMILAR VIDEOS*
Searching Video's for php, problem, error, message, im, working, book
|
advertisement
|
|