Webmaster Forum

Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.


Reply
 
Thread Tools Display Modes
Share |
  #1  
Old 05-30-2004, 05:52 AM
robpicken robpicken is offline
Member
 
Join Date: 02-03-04
Location: Wales (for a while)
Posts: 81
iTrader: 0 / 0%
parse error at bottom of page

Hi,

I've just set up a series of functions in a php script (there are going to be a few bugs to work out when i can get the page up), but i'm getting up a parse error at the bottom of the page, under the last line of code. I've spent ages trying to id the cause but can't find it. Anybody ideas why cause there to be a parse error on this particular line?

Thanks,
 
Reply With Quote

Advertisement

Advertisement

  #2  
Old 05-30-2004, 08:54 AM
hatchet's Avatar
hatchet hatchet is offline
Senior Member
 
Join Date: 10-11-03
Posts: 833
iTrader: 0 / 0%
Double and triple check your brackets.. there is probably one unbalanced.. the parse error comes up there because PHP is looking for it but can't find it.
 
Reply With Quote
  #3  
Old 05-30-2004, 10:21 AM
kwvarga's Avatar
kwvarga kwvarga is offline
v7n Mentor
 
Join Date: 10-13-03
Location: Tuscaloosa, AL or Atlanta
Posts: 2,522
iTrader: 0 / 0%
or maybe a missing ; on the last function call
 
Reply With Quote
  #4  
Old 05-30-2004, 11:17 AM
fishfreek's Avatar
fishfreek fishfreek is offline
Senior Member
 
Join Date: 10-13-03
Location: Virginia
Posts: 844
iTrader: 0 / 0%
or delete any blank lines at the end of the file.

Some editors put junk at the end of the file. It shows up as an empty line but theres something there that screws up the script. Make sure their are no extra lines after your closing php tag.
 
Reply With Quote
  #5  
Old 05-31-2004, 05:31 AM
trevHCS trevHCS is offline
Contributing Member
 
Join Date: 10-14-03
Location: Top left of England, UK
Posts: 169
iTrader: 0 / 0%
Or if non of that works, try cutting each function out and call the script. If eventually it stops producing the error then you've narrowed it down.

As well as those mentioned, I'd also check for ) instead of } as it can be very hard to spot in some fonts.

Trev
 
Reply With Quote
  #6  
Old 05-31-2004, 05:40 AM
robpicken robpicken is offline
Member
 
Join Date: 02-03-04
Location: Wales (for a while)
Posts: 81
iTrader: 0 / 0%
Hi,

Good News - I've fixed one of the pages that i was getting the error on. I had indeed missed out my final } on the very bottom line.

I'm still having problems with the other page though, and will prob do as trevHCS suggested and do a process of elimination until i find the problem.

Thanks for the help guys i'll post back the full results or code (if i can't fix it)
 
Reply With Quote
  #7  
Old 05-31-2004, 12:02 PM
robpicken robpicken is offline
Member
 
Join Date: 02-03-04
Location: Wales (for a while)
Posts: 81
iTrader: 0 / 0%
Ok,

I've ripped the full page of code i did up, and put it all into seperate pages, that seemed to work. There were a few problems which i needed to fix and have done, however there is one problem that i just can't seem to work out.

The code below is identical to another bit of code that works. The problem is this bit doesn't I don't get up an error or a confirmation, i just get up a blank page when i try to delete the entry.

Anybody any ideas?

if (isset($_GET['deletefavourite'])) {
$favourite_id = $_GET['favourite_id'];
$sql = "DELETE FROM favourites WHERE favourite_id=$favourite_id";
if (mysql_query($sql)) {
echo('<p>Establishment has now been deleted from your favourites folder.</p>');
} else {
echo('Error ' . mysql_error() .'');
}
}

Many thanks, in advance
 
Reply With Quote
  #8  
Old 05-31-2004, 12:35 PM
hatchet's Avatar
hatchet hatchet is offline
Senior Member
 
Join Date: 10-11-03
Posts: 833
iTrader: 0 / 0%
[code:1:395938f310]$sql="DELETE FROM favourites WHERE favourite_id = '$favourite_id'";
$result=mysql_query($sql);
if(mysql_errno() != 0){
$msg = mysql_error();
}else{
$msg = urlencode("<p>Establishment has now been deleted from your favourites folder.</p>");
header("Location:index.php?msg=$msg");
}[/code:1:395938f310]
Could try doing it this way. And you wouldn't necessarily need the redirection.
 
Reply With Quote
  #9  
Old 05-31-2004, 12:57 PM
robpicken robpicken is offline
Member
 
Join Date: 02-03-04
Location: Wales (for a while)
Posts: 81
iTrader: 0 / 0%
Hi,

Thanks for that, whilst i can play and rebuild existing php code all day, when it comes to writing something from scratch i'm still kinda new to it so get a bit lost.

I added in your new code, the only problem i had was that i had already sent headers, i can only guess it was with the php session thats running on that page. So i ended up with a Headers Already sent warning.

I removed the header that you added in, but ended up with the same problem, no message, and the listing not getting deleted.
 
Reply With Quote
  #10  
Old 05-31-2004, 01:10 PM
Jazzee Jazzee is offline
No Longer Here
 
Join Date: 09-27-03
Location: State College, PA
Posts: 4,273
iTrader: 0 / 0%
Try using the entire code that hatchet gave you then make sure you have no blank lines at the very end of the pages like fishfreek said above.
 
Reply With Quote
  #11  
Old 05-31-2004, 02:06 PM
robpicken robpicken is offline
Member
 
Join Date: 02-03-04
Location: Wales (for a while)
Posts: 81
iTrader: 0 / 0%
Silly Question do i keep the If (isset... so the code looks like this?

[code:1:3ecf05711d]if (isset($_GET['deletefavourite'])) {
$sql="DELETE FROM favourites WHERE favourite_id = '$favourite_id'";
$result=mysql_query($sql);
if(mysql_errno() != 0){
$msg = mysql_error();
}else{
$msg = urlencode("<p>Establishment has now been deleted from your favourites folder.</p>");
header("Location:index.php?msg=$msg");
}[/code:1:3ecf05711d]

Just incase i've messed up else were (although everything else works, the full code for that entire section is below:

[code:1:3ecf05711d]<?

//Code for viewing favourites

if (isset($_GET['viewfavourites'])) {
$sql_check = mysql_query("SELECT * FROM favourites WHERE username='$username'");
$sql_check_num = mysql_num_rows($sql_check);
if($sql_check_num == 0){
echo "You do not yet have any establishments in your favourite folder.";
} else {
$result = mysql_query("SELECT favourite_id, username, date_added, link_id, link_title FROM favourites WHERE username='$username'");
while ($row = mysql_fetch_array($result) ) {
$favourite_id = $row['favourite_id'];
$username = $row['username'];
$date_added = $row['date_added'];
$link_id = $row['link_id'];
$link_title = $row['link_title'];

// Include link to template

include 'view_favourites.html';
}

// Code to allow members to delete establishments from their favourite folder.

if (isset($_GET['deletefavourite'])) {
$sql="DELETE FROM favourites WHERE favourite_id = '$favourite_id'";
$result=mysql_query($sql);
if(mysql_errno() != 0){
$msg = mysql_error();
}else{
$msg = urlencode("<p>Establishment has now been deleted from your favourites folder.</p>");
header("Location:index.php?msg=$msg");
}
}
}
}
}
?>[/code:1:3ecf05711d]

Thanks the help is really appreciated [/quote]
 
Reply With Quote
  #12  
Old 06-01-2004, 03:21 AM
robpicken robpicken is offline
Member
 
Join Date: 02-03-04
Location: Wales (for a while)
Posts: 81
iTrader: 0 / 0%
Hi Just thought i'd post back that i've fixed the problem. I re-wrote the php this morning, and altered a couple of lines as i was still getting headers already sent.

Thanks to all who helped, i've added the working code below, incase anybody is interested

[code:1:e06a21a168]if (isset($_GET['favouritedelete'])) {
$sql="DELETE FROM favourites WHERE favourite_id = '$favourite_id'";
$result=mysql_query($sql);
if(mysql_errno() != 0){
echo('Error ' . mysql_error() .'');
}else{
echo ('<p>Establishment has now been deleted from your favourites folder.</p>');
}[/code:1:e06a21a168]
 
Reply With Quote
  #13  
Old 06-01-2004, 05:21 AM
hatchet's Avatar
hatchet hatchet is offline
Senior Member
 
Join Date: 10-11-03
Posts: 833
iTrader: 0 / 0%
With header() it needs to be output before anything is rendered to the browser. So you probably have something output before the php is called. You can enclose everything in ob_start() and ob_flush() so it won't display that.
Glad you got it working though
 
Reply With Quote
  #14  
Old 06-01-2004, 06:32 AM
robpicken robpicken is offline
Member
 
Join Date: 02-03-04
Location: Wales (for a while)
Posts: 81
iTrader: 0 / 0%
thanks hatchet,

I think I follow you, the ob_start() and ob_flush are familiar, although not 100% sure how they work even though i've worked with them in the past.

As i said in a previous post, i can re-write code all day long and put new code into existing php scripts, but the code i'd posted was part of a complete members area that i'd written myself, and if i get stuck with my own php creations i get really stuck! What i've created is probably not as good as some you can buy, but it works for me and works well (although i'll need to find a couple of people to test it first), besides it was a decent challenge, 3 days, 5 tables a dozen or so pages and integrated into WorldPay aswell so i'm happy. All i need to do now is create the admin area - but thats for another day...

Thanks for the help it was really appreciated ffom you all.
 
Reply With Quote
  #15  
Old 06-01-2004, 11:06 AM
hatchet's Avatar
hatchet hatchet is offline
Senior Member
 
Join Date: 10-11-03
Posts: 833
iTrader: 0 / 0%
The ob_* functions are output buffers. Where header runs into problems is it tries to interrupt what the browser is outputting already. ob_* saves all the information into a buffer and then can output it all at once while the other information is streaming also... that's as good as I can explain it anyway.. you get the idea.
 
Reply With Quote
  #16  
Old 06-02-2004, 07:47 AM
robpicken robpicken is offline
Member
 
Join Date: 02-03-04
Location: Wales (for a while)
Posts: 81
iTrader: 0 / 0%
Thanks hatchet, i do follow you

Now for the next problem!

[code:1:d526e34e7d]if (isset($_GET['viewreviews'])) {
$sql_check = mysql_query("SELECT * FROM reviews WHERE username='$username' AND status='1'");
$sql_check_num = mysql_num_rows($sql_check);
if($sql_check_num == 0){
echo "Your Reviews folder is currently empty. If you have submitted a review, then it may not yet have been approved by a member of our reviews team.";
}[/code:1:d526e34e7d]

What i'm trying to do with the above code is only call up the reviews submited that have a status of 1 for that username. The way i have it now its calling up reviews that have a status of "0" (not approved) and "1" (approved) Thought i was getting smart with my "AND" statement too

Obviously not, well not yet. Any recommendations anybody?
 
Reply With Quote
  #17  
Old 06-02-2004, 08:07 AM
hatchet's Avatar
hatchet hatchet is offline
Senior Member
 
Join Date: 10-11-03
Posts: 833
iTrader: 0 / 0%
status = 1");
Remove the single quotes from around 1 - I'm sure your database has this field set to INT.
 
Reply With Quote
  #18  
Old 06-02-2004, 08:11 AM
hatchet's Avatar
hatchet hatchet is offline
Senior Member
 
Join Date: 10-11-03
Posts: 833
iTrader: 0 / 0%
You can also get rid of the == 0 by doing
if(!mysql_num_rows($sql_check) {
echo "your empty folder message"; } else {output rows code}
One less line to type
 
Reply With Quote
  #19  
Old 06-02-2004, 08:15 AM
robpicken robpicken is offline
Member
 
Join Date: 02-03-04
Location: Wales (for a while)
Posts: 81
iTrader: 0 / 0%
Thanks again hatchet,

More Short Cuts!!!! lol I wish i'd posted half of this last week then i'd have saved a load of time! but also not had so much fun trying to correct my mistakes.

I'm still getting the same problem though even with the single quotes removed.

This is how my status field is set

status int(11) No 0

Guess that matches what you said
 
Reply With Quote
  #20  
Old 06-02-2004, 12:52 PM
hatchet's Avatar
hatchet hatchet is offline
Senior Member
 
Join Date: 10-11-03
Posts: 833
iTrader: 0 / 0%
Here's a similar function that I have for my affiliates. The only difference is you need to replace function tutcount with your if(isset(
Typically it will work with '' around variables so I don't think it's that.. take those off too just to make it similar.
My first question is.. I'm assuming you are searching for reviews made by a certain user ($username) and then I lose you.. are the reviews approved by you then for each user? So you essentially look for each user and a non-approved review?
If this function helps you any here it is.

[code]function tutcount($cat) {
$sql="SELECT * FROM tutorial WHERE cat = $cat AND status = 1";
$result=mysql_query($sql) or die("Could not connect");
if($tutnums=mysql_num_rows($result)) {
echo $tutnums;
} else {
$tutnums=0;
echo $tutnums;
}
}[\code]
 
Reply With Quote
Go Back   Webmaster Forum > Web Development > Coding Forum

Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Help - Template Parse Error Message photocrats Coding Forum 3 11-20-2007 11:02 PM
Getting Affiliate links to parse page rank joew SEO Forum 5 05-24-2006 04:34 AM
Two Questions {Parse Error and Firefox Compatability} naitsabes Coding Forum 5 11-30-2005 03:03 PM
Parse Error with Wordpress Archives Anataya Coding Forum 0 09-06-2004 08:04 AM
[solved]PHP Code causing Parse error Pipeline-Webdesign Coding Forum 28 06-25-2004 02:59 AM


V7N Network
Get exposure! V7N I Love Photography V7N SEO Blog V7N Directory


All times are GMT -7. The time now is 02:23 AM.
Powered by vBulletin
Copyright 2000-2014 Jelsoft Enterprises Limited.
Copyright © 2003 - 2018 VIX-WomensForum LLC