jsucupira Posted August 29, 2007 Share Posted August 29, 2007 Sry for been so newb, but could someone tell me what's wrong with these 3 codes. when I try a login code I got "PHP Fatal error: Call to undefined function mysql_connect() in C:\Inetpub\wwwroot\library\opendb.php on line 11" <?php // This is an example opendb.php $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); mysql_select_db($dbname); ?> -------------------------------------------------------- <?php mysql_close($conn); ?> ------------------------------- <?php $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = 'ace'; $dbname = 'tallynightlife'; ?> Link to comment https://forums.phpfreaks.com/topic/67179-solved-call-to-undefined-function-mysql_connect/ Share on other sites More sharing options...
mmarif4u Posted August 29, 2007 Share Posted August 29, 2007 <?php $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = 'ace'; $dbname = 'tallynightlife'; // This is an example opendb.php $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die (mysql_error()); mysql_select_db($dbname); ?> And <?php mysql_close($conn); ?> for closing connection after queries or at code end. But mostly not used. Link to comment https://forums.phpfreaks.com/topic/67179-solved-call-to-undefined-function-mysql_connect/#findComment-336964 Share on other sites More sharing options...
coder71 Posted August 29, 2007 Share Posted August 29, 2007 Your connection string is wrong. Use this: $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/67179-solved-call-to-undefined-function-mysql_connect/#findComment-336965 Share on other sites More sharing options...
vijayfreaks Posted August 29, 2007 Share Posted August 29, 2007 Hi.. before that check whether php_mysql extension is on or not? -vijay Link to comment https://forums.phpfreaks.com/topic/67179-solved-call-to-undefined-function-mysql_connect/#findComment-336969 Share on other sites More sharing options...
jsucupira Posted August 29, 2007 Author Share Posted August 29, 2007 it still gave me the error "PHP Fatal error: Call to undefined function mysql_connect() in C:\Inetpub\wwwroot\library\opendb.php on line 10" how do I see if extension is on? also this is the code for my page that is calling this --------------------------------------------- <?php if (isset($_POST['add'])) { include 'library/config.php'; include 'library/opendb.php'; $username = $_POST['login']; $password = $_POST['password']; $query = "INSERT INTO login (login, password) VALUES ('$username','$password')"; mysql_query($query) or die('Error, insert query failed'); $query = "FLUSH PRIVILEGES"; mysql_query($query) or die('Error, insert query failed'); include 'library/closedb.php'; echo "New MySQL user added"; } else { ?> <form method="post"> <table width="400" border="0" cellspacing="1" cellpadding="2"> <tr> <td width="100">Username</td> <td><input name="username" type="text" id="login"></td> </tr> <tr> <td width="100">Password</td> <td><input name="password" type="text" id="password"></td> </tr> <tr> <td width="100"> </td> <td> </td> </tr> <tr> <td width="100"> </td> <td><input name="add" type="submit" id="add" value="Add New User"></td> </tr> </table> </form> <?php } ?> Link to comment https://forums.phpfreaks.com/topic/67179-solved-call-to-undefined-function-mysql_connect/#findComment-336975 Share on other sites More sharing options...
trq Posted August 29, 2007 Share Posted August 29, 2007 Did you read the sticky at the top of this board with the same subject as this thread? Link to comment https://forums.phpfreaks.com/topic/67179-solved-call-to-undefined-function-mysql_connect/#findComment-336981 Share on other sites More sharing options...
jsucupira Posted August 29, 2007 Author Share Posted August 29, 2007 now I did, thnx thorpe Link to comment https://forums.phpfreaks.com/topic/67179-solved-call-to-undefined-function-mysql_connect/#findComment-336989 Share on other sites More sharing options...
trq Posted August 29, 2007 Share Posted August 29, 2007 Good. Problem solved then? Link to comment https://forums.phpfreaks.com/topic/67179-solved-call-to-undefined-function-mysql_connect/#findComment-336990 Share on other sites More sharing options...
jsucupira Posted August 29, 2007 Author Share Posted August 29, 2007 yep problem solved. I had a question for u. what did u mean by post code between [ code ] [ /code ] tags (without the spaces). Link to comment https://forums.phpfreaks.com/topic/67179-solved-call-to-undefined-function-mysql_connect/#findComment-336992 Share on other sites More sharing options...
matthewhaworth Posted August 29, 2007 Share Posted August 29, 2007 yep problem solved. I had a question for u. what did u mean by post code between [ code ] [ /code ] tags (without the spaces). [code][/code] put your code between them two tags so that it'll format correctly. Link to comment https://forums.phpfreaks.com/topic/67179-solved-call-to-undefined-function-mysql_connect/#findComment-336998 Share on other sites More sharing options...
jsucupira Posted August 29, 2007 Author Share Posted August 29, 2007 thnx for the replies Link to comment https://forums.phpfreaks.com/topic/67179-solved-call-to-undefined-function-mysql_connect/#findComment-337001 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.