Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Graarhahrgh Mysql And Php Won't Work
beeseven
post Jun 21 2005, 11:53 PM
Post #1


Privileged Member
*********

Group: Members
Posts: 629
Joined: 26-February 05
Member No.: 3,995



I have this code that I've tried everything to fix it, but it still won't work. I'm hoping someone here will be able to help.

First, the open database file:
CODE
<?php
function opendatabase()
{
$hostname = "localhost";
$username = "beeseven";
$password = "**REMOVED**";
$database = "beeseven_**REMOVED**";
mysql_connect($hostname,$username,$password) or die("Could not connect to database");
mysql_select_db($database) or die("Could not select to database");
}
?>

I have that included in the register file:
CODE
//variables and whatnot
include 'opendatabase.php';
opendatabase();
$mysql_query = mysql_query("INSERT INTO users (name, password, concode, confirmed, email, joined, job, level, exp, moves, weapon) VALUES ($name, $password, $concode, $confirmed, $email, $joined, $job, $level, $exp, $moves, $weapon)"); //here's where my problem is
if($mysql_query === false) //this checks if the username is taken
{
 $err = mysql_errno();
 if($err == 1062) //1062 is the duplicate entry for unique field error
 {
  echo "<div class=\"err\">Error: Username taken.</div>";
  die("</body></html>");
 }
}
mysql_close();
My problem is with the query. I can't think of any reason why it wouldn't work- everything is stripslashes()'d, and I even have it echo the variables at the end and there's nothing that should cause any problems.
Go to the top of the page
 
+Quote Post
hype
post Jun 22 2005, 09:16 AM
Post #2


Legend Killer
*********

Group: Members
Posts: 678
Joined: 15-April 05
From: Singapore
Member No.: 5,697



If you're using trap17 host, I think you use the wrong username, cause all trap17 username is prefix with your cpanel username... and your prefix is beeseven, and so if your username you entered is beeseven, then your $username = "beeseven_beeseven";
Go to the top of the page
 
+Quote Post
tariqrf
post Jun 22 2005, 02:12 PM
Post #3


Member [Level 1]
****

Group: Members
Posts: 70
Joined: 14-April 05
Member No.: 5,653



its def on your side... you need to get some error info here... wat exactly is your report saying?
Go to the top of the page
 
+Quote Post
beeseven
post Jun 22 2005, 09:03 PM
Post #4


Privileged Member
*********

Group: Members
Posts: 629
Joined: 26-February 05
Member No.: 3,995



QUOTE(hype @ Jun 22 2005, 04:16 AM)
If you're using trap17 host, I think you use the wrong username, cause all trap17 username is prefix with your cpanel username... and your prefix is beeseven, and so if your username you entered is beeseven, then your $username = "beeseven_beeseven";
*


I though about that, but for my forum I just used "beeseven" and that worked fine.

QUOTE(tariqrf @ Jun 22 2005, 09:12 AM)
its def on your side... you need to get some error info here... wat exactly is your report saying?
*


There is no report, it just won't submit it. I got it to echo all the variables, then I copied the query into PHPmyAdmin and it worked fine.
Go to the top of the page
 
+Quote Post
hype
post Jun 22 2005, 11:30 PM
Post #5


Legend Killer
*********

Group: Members
Posts: 678
Joined: 15-April 05
From: Singapore
Member No.: 5,697



ok, go to mysql database through your cpanel, then copy and paste your sql database name and your sql username... I'll check it out as the thing is funny...
Go to the top of the page
 
+Quote Post
beeseven
post Jun 27 2005, 07:24 PM
Post #6


Privileged Member
*********

Group: Members
Posts: 629
Joined: 26-February 05
Member No.: 3,995



Okay, now that finals are over (my school gets out so late >_<), I've been trying to fix this. I made a database account and gave it all privileges, then I changed opendatabase, but now I get this error:

QUOTE
Warning: mysql_connect(): Access denied for user: 'beeseven_ammin@localhost' (Using password: YES) in /home/beeseven/public_html/gaem/opendatabase.php on line 8
Could not connect to database
Go to the top of the page
 
+Quote Post
bjrn
post Jun 29 2005, 05:52 PM
Post #7


Super Member
*********

Group: Members
Posts: 378
Joined: 8-January 05
Member No.: 3,174



Are you sure your username and password are really right? Perhaps you've typoed "ammin" when you meant "admin"?
Go to the top of the page
 
+Quote Post
beeseven
post Jun 29 2005, 06:54 PM
Post #8


Privileged Member
*********

Group: Members
Posts: 629
Joined: 26-February 05
Member No.: 3,995



No, I'm sure I made it "ammin."

As for the password, I just copied the file from my forum, which it works for.
Go to the top of the page
 
+Quote Post
hype
post Jun 30 2005, 07:09 AM
Post #9


Legend Killer
*********

Group: Members
Posts: 678
Joined: 15-April 05
From: Singapore
Member No.: 5,697



ok, use that rial sql account and give us the username and password and other required information, we'll try to help you sort it out...
Go to the top of the page
 
+Quote Post