Jump to content

Recommended Posts

I got the following files that give me an error when I go to signup.php

 

config.php

<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$dbname = 'busu';
?> 

 

closedb.php

<?php
mysql_close($conn);
?>

 

opendb.php

<?php
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die                      ('Error connecting to mysql');
mysql_select_db($dbname);
?> 

 

insert.php

<?php
include 'config.php';
include 'opendb.php';

$sql="INSERT INTO members (name, password, email, location)
VALUES
('$_POST[name]','$_POST[password]','$_POST[email]', '$_POST[location]')";

if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "1 record added";

include 'closedb.php';
?>

 

signup.php

<html>
<body>

<form action="insert.php" method="post">
Name: <input type="text" name="name" />
Password: <input type="text" name="password" />
Email: <input type="text" name="email" />
Location: <input type="text" name="location" />
<input type="submit" />
</form>

</body>
</html> 

Running signup.php leads to the following error when submitting the form:

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root'@'localhost' (using password: NO) in D:\Test Server\EasyPHP 3.0\www\opendb.php on line 2

Error connecting to mysql

 

Opening files seperate leads to these errors:

 

opendb.php

Notice: Undefined variable: dbhost in D:\Test Server\EasyPHP 3.0\www\opendb.php on line 2

 

Notice: Undefined variable: dbuser in D:\Test Server\EasyPHP 3.0\www\opendb.php on line 2

 

Notice: Undefined variable: dbpass in D:\Test Server\EasyPHP 3.0\www\opendb.php on line 2

 

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'ODBC'@'localhost' (using password: NO) in D:\Test Server\EasyPHP 3.0\www\opendb.php on line 2

Error connecting to mysql

 

insert.php

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root'@'localhost' (using password: NO) in D:\Test Server\EasyPHP 3.0\www\opendb.php on line 2

Error connecting to mysql

 

closedb.php

Notice: Undefined variable: conn in D:\Test Server\EasyPHP 3.0\www\closedb.php on line 2

 

Warning: mysql_close(): supplied argument is not a valid MySQL-Link resource in D:\Test Server\EasyPHP 3.0\www\closedb.php on line 2

config.php gives no errors at all. Does someone have a clue what could be wrong here?

Link to comment
https://forums.phpfreaks.com/topic/164430-anyone-see-what-is-wrong-here/
Share on other sites

Try not to include the closedb.php, try typing only

mysql_close($conn);

instead of

 <?php
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
mysql_select_db($dbname);
?> 

then run signup.php.

 

Running your closedb.php and opendb.php would definitely ahve an error because you would need your config.php with that. ;)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.