Weird Errors

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
rfigley
Forum Commoner
Posts: 70
Joined: Sun Apr 21, 2002 7:10 pm

Weird Errors

Post by rfigley »

I'm using this code to output data from a very simple Newsletter database.

I used this same code from another project I did, but where I have:

['paragraph_2'] . "</td></TR>";

I had ['paragraph_2'] . "</td></TR>" .

With this later I got the error:
Parse error: parse error in /home/ricksi/public_html/newsletter/newsletter-new.php on line 35

Which was fine, was on the curly brase after the dot previous, instead of a semicolonn to end the satatment.

However when I corrected that by putting a semicolon, after the quote, I get an error that it can't access the database:

"Warning: mysql_connect(): Access denied for user: 'ricksi_rfigley@localhost' (Using password: YES) in /home/ricksi/public_html/newsletter/dbconnect.php on line 2
I cannot connect to the database because: Access denied for user: 'ricksi_rfigley@localhost' (Using password: YES)"

Does this make any sense? If it can't aces teh database, should I get that error before the parse error?

Code: Select all

<?


 include('dbconnect.php');
 

$query = ("select * from newsletter_sections");
$result = mysql_query($query) or die("Query fail");

if (mysql_num_rows($result) == 0)
{

} else
{

  echo "<CENTER>";

  echo "<table border=1>";

  while($row = mysql_fetch_array($result))
    {
        //echo "<table><tr><td>";
        //echo "<table border=1>";

        echo "<tr><td> " . "&nbsp" .  $row['newsletter_title'] . "</td></TR>" . 
		"<tr><td> " .   $row['newsletter_title2'] . 
		 "</td><td> " .  $row['paragraph_1'] ."</td></TR>" .
		  "</td><td> " . $row['paragraph_2'] . "</td></TR>";
		  
       }
    echo "</table>";

 }

?>
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post by ol4pr0 »

Did you carefully check youre login and password and all other things in youre db connection ?
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

The reason these errors occured is because PHP parses the file before it even tries to run it. If it finds a parse error, it doesn't run the file. PHP was parsing your file, found the error, then quit. When you fixed the parse error, it was able to run the file and find run-time errors.

As for the error you're getting now, that quite often means the permissions are wonky in the db. One thing I sometimes forget to do is flush the privileges ">flush privileges" after a change is made. (If you do this, make sure you open a second connection to login before you logout of your current connection - just to make sure you didn't remove your ability to login.)
rfigley
Forum Commoner
Posts: 70
Joined: Sun Apr 21, 2002 7:10 pm

Post by rfigley »

OK, didn't realize the sequence of events. Now that that is resolved, don't know why I'm getting a failed query. Basically I wnat it to read the whole database then introduce the conditions wanted.
Post Reply