Jump to content

MySql Connect [ERROR]


JustinMs66@hotmail.com

Recommended Posts

MySql error:
[quote]Fatal error: Call to undefined function: mysql_connect() in /website/create.php on line 18[/quote]
and "Line 18" is this:
[code]$db = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');[/code]

now i followed a tutorial exactly, and i still get this error.
also, i have specified the uname, pass, and host, and database and all, and trippple checked it all, and it's correct.

here is all my code:
[code]<?php
if(isset($_POST['add']))
{
$dbhost = '(my host goes here)';
$dbuser = '(my username goes here)';
$dbpass = '(my pass goes here)';
$dbname = '(my database name goes here)';

$db = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
mysql_select_db($dbname);

$username = $_POST['username'];
$password = $_POST['password'];

$query = "INSERT INTO user (host, user, password, select_priv, insert_priv, update_ priv) VALUES ('localhost', '$username', PASSWORD('$password'), 'Y', 'Y', 'Y')";
mysql_query($query) or die('Error, insert query failed');

$query = "FLUSH PRIVILEGES";
mysql_query($query) or die('Error, insert query failed');

mysql_close($db);
echo "New MySQL user added";
}
else
{
?>

<form method="post">
<input name="username" type="text" id="username">
<input name="password" type="text" id="password">
<input name="add" type="submit" id="add" value="Add New User">
<?php
}
?>[/code]

little help?
Link to comment
https://forums.phpfreaks.com/topic/28650-mysql-connect-error/
Share on other sites

[quote author=mgallforever link=topic=116489.msg474616#msg474616 date=1164657870]
try using double quotes instead of single quotes while defining your host,user,pass and dbname
[/quote]
That wont make a single difference ;)

The problem is because you dont have the mysql extension enabled. Please read the thread titled "[b]Call To Undefinded Function mysql_connect[/b]" in the [url=http://www.phpfreaks.com/forums/index.php/board,41.0.html]FAQ/Code Snippet Repository[/url] forum. Should be able help you.

Note: that FAQ is for Windows only.

If you are on a linux based OS then you'll need to recompile PHP the --with-mysql=path/mysql/installDir command option
Link to comment
https://forums.phpfreaks.com/topic/28650-mysql-connect-error/#findComment-131101
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.