Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Starting out!

Status
Not open for further replies.

TrueJoker

Technical User
Jun 14, 2006
115
GB
Hi i'm new to PHP and MySQL and im using the php&mysql for dummies book! ive installed mysql 5 and im trying to test it with the code give in the book! I've copied to code word for word but this error appears:
Parse error: parse error, expecting `')'' in /home/httpd/vhosts/cpacreative.com/httpdocs/allan/mysql_up.php on line 24

the line of code it is refering to is as follows:

for ($i = 0; $i < mysql_num_rows($result); $i++ {

help please!
 
I guess a ) is mising here:
for ($i = 0; $i < mysql_num_rows($result); $i++) {
 
You missed out closing bracket in for loop .

Code:
for ($i = 0; $i < mysql_num_rows($result); $i++[b])[/b] {

--------------------------------------------------------------------------
I never set a goal because u never know whats going to happen tommorow.
 
Doh! thank you for pointing that out! im going blind i think.

hmmm now i get warning messages!

Warning: mysql_connect(): Access denied for user: 'root@localhost' (Using password: YES) in /home/httpd/vhosts/cpacreative.com/httpdocs/allan/mysql_up.php on line 10

line 10 = mysql_connect($host,$user,$password);

Warning: mysql_query(): Access denied for user: 'apache@localhost' (Using password: NO) in /home/httpd/vhosts/cpacreative.com/httpdocs/allan/mysql_up.php on line 12

line 12 = $result = mysql_query($sql);

Warning: mysql_query(): A link to the server could not be established in /home/httpd/vhosts/cpacreative.com/httpdocs/allan/mysql_up.php on line 12
Error 1045: Access denied for user: 'apache@localhost' (Using password: NO)

I have no idea i've checked the username and password and they are correct!
 
It's telling you the users "root" and "apache" do not have the proper permissions to access the tables.

Just so you know, PHP will attempot to connect to mysql using the provided credentials user and password in this case "root", if it can't it will then use a default set of credentials "apache" ands no password.

Either way it can't connect to mysql.

I suggest you check your mysql admin, and see if your user root@localhost is allowed access. And just so we are clear, root and root@localhost are 2 different things for mysql.



----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top