[email protected] Posted November 27, 2006 Share Posted November 27, 2006 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]<?phpif(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? Quote Link to comment https://forums.phpfreaks.com/topic/28650-mysql-connect-error/ Share on other sites More sharing options...
marcus Posted November 27, 2006 Share Posted November 27, 2006 try using double quotes instead of single quotes while defining your host,user,pass and dbname Quote Link to comment https://forums.phpfreaks.com/topic/28650-mysql-connect-error/#findComment-131091 Share on other sites More sharing options...
printf Posted November 27, 2006 Share Posted November 27, 2006 You might not have MySQL installed...// test it...[code]<?phpif ( ! is_function ( 'mysql_connect' ) ){ echo 'MySQL is not installed';}else{ echo 'MySQL is installed';}?>[/code]printf Quote Link to comment https://forums.phpfreaks.com/topic/28650-mysql-connect-error/#findComment-131097 Share on other sites More sharing options...
kenrbnsn Posted November 27, 2006 Share Posted November 27, 2006 What version of PHP are you using? If you're using v5, the default DB is mysqli. To use MySQL, you need to enable it in the PHP.INI file.Ken Quote Link to comment https://forums.phpfreaks.com/topic/28650-mysql-connect-error/#findComment-131098 Share on other sites More sharing options...
wildteen88 Posted November 27, 2006 Share Posted November 27, 2006 [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 Quote Link to comment https://forums.phpfreaks.com/topic/28650-mysql-connect-error/#findComment-131101 Share on other sites More sharing options...
[email protected] Posted November 27, 2006 Author Share Posted November 27, 2006 1) i am using PHP42) i am using linux3) my host dosn't allow me editing the PHP.INI file4) i have spent many hours trying the recompile thing and yet it does not work.5) is their a way i can fix this for PHP4? Quote Link to comment https://forums.phpfreaks.com/topic/28650-mysql-connect-error/#findComment-131114 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.