Page 1 of 1

Weird Errors

Posted: Fri Feb 20, 2004 3:02 pm
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>";

 }

?>

Posted: Fri Feb 20, 2004 4:14 pm
by ol4pr0
Did you carefully check youre login and password and all other things in youre db connection ?

Posted: Fri Feb 20, 2004 4:48 pm
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.)

Posted: Fri Feb 20, 2004 8:05 pm
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.