error i dont understand

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

Charles256
DevNet Resident
Posts: 1375
Joined: Fri Sep 16, 2005 9:06 pm

Post by Charles256 »

erm.change it to PHP tags?
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

Code: Select all

$post_new = '<a href="http://www.nozhosting.com/forums/posting.php?mode=reply&t='.$topic.'">Post a comment</a>';
            }
           /* '.$news; // THIS IS THE LINE AT FAULT! */
            }else{
               $news1 = $news;
            }
That line looks like it shouldn't be there at all, I have commented it.
gaogier
Forum Contributor
Posts: 391
Joined: Wed Mar 02, 2005 1:02 pm
Location: Portsmouth, UK
Contact:

Post by gaogier »

so how could i fix it?
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

remove the line.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

It's actually quite obvious once highlighting is on... the question is why was it there?

Such a jumble of spaghetti code: you could have at least indented it consistently.
gaogier
Forum Contributor
Posts: 391
Joined: Wed Mar 02, 2005 1:02 pm
Location: Portsmouth, UK
Contact:

Post by gaogier »

if i delete that line i get this error

Parse error: parse error, unexpected T_ELSE in /home/nozhost/public_html/news.inc on line 51
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

and what do you think that error message is telling you?
gaogier
Forum Contributor
Posts: 391
Joined: Wed Mar 02, 2005 1:02 pm
Location: Portsmouth, UK
Contact:

Post by gaogier »

i dont know what it means?

T_ELSE?
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

What is on line 51 that could possibly cause an error with T_ELSE message?

T_ELSE... else.. T_ELSE... else... ;)
gaogier
Forum Contributor
Posts: 391
Joined: Wed Mar 02, 2005 1:02 pm
Location: Portsmouth, UK
Contact:

Post by gaogier »

so i delete that?
gaogier
Forum Contributor
Posts: 391
Joined: Wed Mar 02, 2005 1:02 pm
Location: Portsmouth, UK
Contact:

Post by gaogier »

kk, i deleted that, and now i have this error

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/nozhost/public_html/news.inc on line 13
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

Dude, I don't mean to be rude... but are you even trying to investigate these errors for yourself?

I don't mean to ward you off, I am happy to help, but please.. atleast try to fix them before just posting on here :)
gaogier
Forum Contributor
Posts: 391
Joined: Wed Mar 02, 2005 1:02 pm
Location: Portsmouth, UK
Contact:

Post by gaogier »

sorry, iv new to learning php, and really rusty with errors

is that errror saying its not connecting to the databse?
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

That is a possible cause.

For every mysql command you have, put die(mysql_error()); after it, for example:

Code: Select all

mysql_query("SELECT * FROM table") or die(mysql_error());
Do the same on the mysql_connect.

This will give a descriptive error where things are wrong.
gaogier
Forum Contributor
Posts: 391
Joined: Wed Mar 02, 2005 1:02 pm
Location: Portsmouth, UK
Contact:

Post by gaogier »

it has that

Code: Select all

<?php

$dbcnx = mysql_connect("localhost", "gaming_gaogier", "password")
  or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("gaming_phpbb1");

function escape_data1 ($data){
   global $dbh;
   if (ini_get('magic_quotes_gpc')){
      $data = stripslashes($data);
   }
   return mysql_real_escape_string (trim ($data), $dbh);
}

?>
Post Reply