Author Topic: MySQL / PHP help please?  (Read 1201 times)

Ok, every time I connect to my website it says "access denied".
I wonder if any of you can help.

Form
Code: [Select]
<form action="PHPTest.php" method="post">
Username: <input type="text" name="user" />
<br/>
Message: <input type="text" name="msg" />
<br/>
<input type="submit" value="Speak up" />
</form>
<br/>
MySQL Code
Code: [Select]
<?php
$con 
mysql_connect("localhost:3306");
if(!
$con)
 {
  die(
'Failed to conect: ' mysql_error());
 }
 
if(!
mysql_query("CREATE DATABASE testDB",$con))
 {
  echo(
'Failed to create database: ' mysql_error());
 }
 
mysql_select_db("testDB",$con);
$sql "CREATE TABLE Messages ( msgID int NOT NULL AUTO_INCREMENT, PRIMARY KEY(msgID), Message tinytext, User tinytext, )";
mysql_query($sql,$con);

$sqlTwo "INSERT INTO Messages (Message, User) VALUES ('$_POST[msg]','$_POST[user]')";
if(!
mysql_query($sqlTwo,$con))
 {
  die(
'Error: ' mysql_error());
 }

$result mysql_query("SELECT * FROM Messages");

while(
$row mysql_fetch_array($result))
 {
  echo 
$row['User'] . ": " $row['msg'];
  echo 
"<br />";
 }
?>


Off topic: Where the heck are the colors coming from?


Off topic: Where the heck are the colors coming from?

The words, silly.

Tom

lol you need your username and pass.

lol you need your username and pass.

I know my pass, but I never got to enter a username. What would my username be?

Tom

You enter it in the script. Your web hosting has the details.

Ok, I tried that. Result:

Quote from: www.club559.com
Access denied for user

Tom

Can I see the code now? you can replace the password if ***s.

Code: [Select]
$con = mysql_connect("localhost:3306","club559@travisfam4.com","********");

Tom

Are you sure thats the mySQL your host gave you? Try taking out the "@travisfam4.com".

Are you sure thats the mySQL your host gave you? Try taking out the "@travisfam4.com".

Didn't work. I once tried "Wesley" (my real name, my computer account name) but it didnt work.

Tom

You'll have to look for an info page in your cpanel or see if the mySQL username was in any of your confirmation emails. I cannot help you find your mySQL username, all host are different.

see if the mySQL username was in any of your confirmation emails.
I never got any confirmation emails.

Dang, I looked at the MySQL console and got this as the user

root@localhost

I tried putting in "root" since it automatically does @localhost, but it didnt work.

Does your host have a Cpanel?

Does your host have a Cpanel?

I dont know how to access my host, my website runs with my dad's website. He purchased his website and my website.