The Daily Click ::. Forums ::. Non-Klik Coding Help ::. PHP coding
 

Post Reply  Post Oekaki 
 

Posted By Message

Chris Burrows



Registered
  9/14/2002
Points
  2396

GOTW WINNER OCT. 2011
17th October, 2011 at 3:31:08 PM -

Hi,

I am trying to create a comment box using PHP code and a mySQL Database following this tutorial:

http://www.youtube.com/watch?v=CS45YAqCgX8

I have completed the whole video and when I view my website I get the following error:

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root'@'localhost' (using password: NO) in /home/whenther/public_html/connect.php on line 3

Warning: mysql_select_db() [function.mysql-select-db]: Access denied for user 'whenther'@'localhost' (using password: NO) in /home/whenther/public_html/connect.php on line 4

Warning: mysql_select_db() [function.mysql-select-db]: A link to the server could not be established in /home/whenther/public_html/connect.php on line 4


Can anybody help me out here? I'm not sure where I would have made my mistake.

Cheers!

Edited by Chris Burrows

 
n/a

-UrbanMonk-

Professor Spectrum

Registered
  7/7/2008
Points
  6121

Has Donated, Thank You!Little Pirate!ARGH SignKliktober Special Award TagPicture Me This Round 33 Winner!The Outlaw!VIP MemberHasslevania 2!I am an April Fool
17th October, 2011 at 4:59:20 PM -

The mistake is on lines 3 and 4.

Make sure you have your database setup correctly.

 
http://www.soapcow.com <- Flash games, featuring MMF made games!
http://www.jsoftgames.com <- Old blog I don't keep up anymore

Fordom

Nordanrikets konung

Registered
  2/12/2009
Points
  190

VIP Member
17th October, 2011 at 7:58:21 PM -


Originally Posted by . : UrbanMonk : .
The mistake is on lines 3 and 4.

Make sure you have your database setup correctly.


No shit,

 
This forum is full of trolls and disinfo agents.

The Cecilizer

You Done Got Cecilized

Registered
  3/19/2005
Points
  1602

Has Donated, Thank You!VIP MemberWeekly Picture Me This Winner!Cardboard BoxGhostbuster!Pokemon Ball!Computer
17th October, 2011 at 8:35:53 PM -


Originally Posted by Fordom

Originally Posted by . : UrbanMonk : .
The mistake is on lines 3 and 4.

Make sure you have your database setup correctly.


No shit,



First of all those are not errors, they are warnings. most "errors" in php are fatal and would kill the script unless handled.

Learn to use warning/error messages. They tell you everything you need.

Warnings in file connect.php on lines 3, 4, and 4 again.
Describes the first 2 warnings as database access denied. therefore you provided the wrong user information and password to be passed to the database, or your database is not set up correctly for the user information you provided.
The third Warning is just informing you that because of the other warnings, it couldnt connect to the database.

At this point no one can really help you without access to your website, code, and database.

 
Image

>> http://www.cecilectomy.com <<

The Cecilizer

You Done Got Cecilized

Registered
  3/19/2005
Points
  1602

Has Donated, Thank You!VIP MemberWeekly Picture Me This Winner!Cardboard BoxGhostbuster!Pokemon Ball!Computer
17th October, 2011 at 8:45:20 PM -

btw, that was one of the worst tutorials i have ever watched.

 
Image

>> http://www.cecilectomy.com <<

Chris Burrows



Registered
  9/14/2002
Points
  2396

GOTW WINNER OCT. 2011
18th October, 2011 at 1:16:18 AM -


It is the only one I could find for coding a message box from scratch. I am new to PHP. But yeah it is terrible!

Ok so it has a problem connecting to my database. I may not have set it up properly.

Here is the code for connect.php, the script that connects to my database:

<?php

mysql_connect("localhost","root","");
mysql_select_db("comment");

?>



and here is my website code that calls that script:


<?php
require('connect.php');
$name=$_POST['name'];
$comment=$_POST['comment'];
$submit=$_POST['sumbit'];

if($submit)
{

if($name&&$comment)
{
$query=mysql_query("INSERT INTO comment (id,name,comment) VALUES ('','$name','$comment')");
}
else
{
echo "Please fill out all the fields.";
}

}
?>


this is the url if to see the errors in action: http://www.whenthereisnoroominhellthedeadwalktheearth.com/test.php

i am pretty sure the local host part i made bold is a problem.

if anybody who has expereince in this field would like to check my database to see if it has been set up correctly I am happy to give you access to my website.

 
n/a

Jon Lambert

Administrator
Vaporware Master

Registered
  12/19/2004
Points
  8224

VIP MemberWii OwnerTDC Chat Super UserI am an April FoolSSBB 3265-4741-0937ACCF 3051-1173-8012360 Owner
18th October, 2011 at 2:09:07 AM -

Shouldn't root have a password?

 
Sandwich Time!Whoo!

JoyCheck & KeyCheck Widgets
For easy implementation of customizable joystick and keyboard controls.
http://www.create-games.com/download.asp?id=8364

Chris Burrows



Registered
  9/14/2002
Points
  2396

GOTW WINNER OCT. 2011
18th October, 2011 at 2:34:11 AM -

Pretty sure it doesn't need one.

Part of the error message includes: (using password: NO) which suggests that I'm not using one, as opposed to an incorrect one.

Go to: http://www.whenthereisnoroominhellthedeadwalktheearth.com/test.php for the full error message.

 
n/a

Chris Burrows



Registered
  9/14/2002
Points
  2396

GOTW WINNER OCT. 2011
18th October, 2011 at 2:57:09 AM -

actually i've got it connecting now. i hadn't made a user or password for my database. but now it just doesn't seem to be sending the comments to my database...

 
n/a

Jon Lambert

Administrator
Vaporware Master

Registered
  12/19/2004
Points
  8224

VIP MemberWii OwnerTDC Chat Super UserI am an April FoolSSBB 3265-4741-0937ACCF 3051-1173-8012360 Owner
18th October, 2011 at 4:20:31 AM -


Originally Posted by Chris Burrows
Pretty sure it doesn't need one.

Part of the error message includes: (using password: NO) which suggests that I'm not using one, as opposed to an incorrect one.

Well that's because you aren't using one. "" isn't a password, so that counts as not using a password just as much as not having included the parameter at all. Since it said that you weren't using a password, the only possibilities I can think of for the source of that error are either you not using a password for root when you need one (the super likeliest) or there not being a root user at all (not likely).

That is to say that it telling you that you aren't using a password is telling you just that, that you didn't give it a password. That is different from telling you that you're using the wrong password (in which case it would have said "using password: YES".)

 
Sandwich Time!Whoo!

JoyCheck & KeyCheck Widgets
For easy implementation of customizable joystick and keyboard controls.
http://www.create-games.com/download.asp?id=8364

The Cecilizer

You Done Got Cecilized

Registered
  3/19/2005
Points
  1602

Has Donated, Thank You!VIP MemberWeekly Picture Me This Winner!Cardboard BoxGhostbuster!Pokemon Ball!Computer
18th October, 2011 at 4:29:15 AM -

id should not be in your insert query. id is a key and is autoincrement.

"INSERT INTO comment (id,name,comment) VALUES ('','$name','$comment')"

should be

"INSERT INTO comment (name,comment) VALUES ('$name','$comment')"

 
Image

>> http://www.cecilectomy.com <<

The Cecilizer

You Done Got Cecilized

Registered
  3/19/2005
Points
  1602

Has Donated, Thank You!VIP MemberWeekly Picture Me This Winner!Cardboard BoxGhostbuster!Pokemon Ball!Computer
18th October, 2011 at 4:30:14 AM -

also id is a keyword in sql so when using it you need to surround it with graves `id`. iirc anyways.

 
Image

>> http://www.cecilectomy.com <<

Jon Lambert

Administrator
Vaporware Master

Registered
  12/19/2004
Points
  8224

VIP MemberWii OwnerTDC Chat Super UserI am an April FoolSSBB 3265-4741-0937ACCF 3051-1173-8012360 Owner
18th October, 2011 at 4:37:22 PM -


Originally Posted by The Cecilizer
also id is a keyword in sql so when using it you need to surround it with graves `id`. iirc anyways.

I usually call it something like c_id for comments, so *_id, where * is a letter representing the content.

 
Sandwich Time!Whoo!

JoyCheck & KeyCheck Widgets
For easy implementation of customizable joystick and keyboard controls.
http://www.create-games.com/download.asp?id=8364

Chris Burrows



Registered
  9/14/2002
Points
  2396

GOTW WINNER OCT. 2011
19th October, 2011 at 5:52:41 AM -


Hello again,

Ok so I've been up for 2 days straight working on this

http://www.whenthereisnoroominhellthedeadwalktheearth.com/test.php

It is complete except for 1 thing: When you click "Post Comment" it takes you to an ugly page telling you that you have posted a comment. I want it to just refresh the current page and display the new comment, and empty the text fields.

Anybody know how to do this?

Thank you again!

Chris




 
n/a

Chris Burrows



Registered
  9/14/2002
Points
  2396

GOTW WINNER OCT. 2011
19th October, 2011 at 7:53:10 AM -

Never mind. Fixed it. Thanks anyway though everybody

 
n/a

Chris Burrows



Registered
  9/14/2002
Points
  2396

GOTW WINNER OCT. 2011
19th October, 2011 at 7:56:56 AM -

Never mind. Fixed it. Thanks anyway though everybody

 
n/a
   

Post Reply



 



Advertisement

Worth A Click