[RESOLVED] include & mysql_connect() error.
My website is currently hosted by a free server: **********.com
Error Messages:
Quote:
PHP Error Message
Warning: include() [function.include]: Failed opening '/Includes/database_info.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/a1401476/public_html/adduser.php on line 11
Free Web Hosting
PHP Error Message
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'nobody'@'localhost' (using password: NO) in /home/a1401476/public_html/adduser.php on line 12
Free Web Hosting
Could not connect: Access denied for user 'nobody'@'localhost' (using password: NO)
There is a registration form, when you click the Register (Submit) button it executes adduser.php. (Form action="adduser.php")
The problem is that i need the adduser.php script to send the registration info to a database to log the new user. It is having problems connecting to the database, from the error it gave (above) i am guessing it is because something is wrong with my include. Below i have supplied the file that is being included, with modified values for the variables (security purposes), and the bit of mySQL code on the page adduser.php.
File: /public_html/Includes/database_info.php
Code:
<?php
$sql_servername = "mysql7.**********.com";
$sql_username = "myusername";
$sql_password = "mypassword";
?>
.
File: /public_html/adduser.php
(note * this is just the mySQL part of my code
i replaced the other code ontop and below with comments)
Code:
<?php
//Code here...
//Code here...
//Code here...
//Code here...
include ("/Includes/database_info.php");
$con = mysql_connect($sql_servername,$sql_username,$sql_password);
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db($sql_servername, $con);
$sql="INSERT INTO accounts (Username, Password, Email, SecurityQ, SecurityA)
VALUES ('$_POST[username]','$_POST[password1]','$_POST[email1]','$_POST[securityq]','$_POST[securitya]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo ("Hello " . $_POST["username"] . " , welcome to The School Truck.");
mysql_close($con);
//Code here...
//Code here...
//Code here...
//Code here...
?>
What is the problem? I was also thinking maybe i wrote the include line wrong..
Re: include & mysql_connect() error.
don't root the file on the include.... It's going back up to your root (public_html) folder... that's not where you want to go. remove the leading / from the path, and MAKE sure that the folder is Includes and not includes....
-tg
Re: include & mysql_connect() error.
Oh i will keep that in mind for the future, thank you it works.