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'; ?> Quote Link to comment 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. Quote Link to comment 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()); Quote Link to comment 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 Quote Link to comment 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 } ?> Quote Link to comment 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? Quote Link to comment Share on other sites More sharing options...
jsucupira Posted August 29, 2007 Author Share Posted August 29, 2007 now I did, thnx thorpe Quote Link to comment Share on other sites More sharing options...
trq Posted August 29, 2007 Share Posted August 29, 2007 Good. Problem solved then? Quote Link to comment 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). Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
jsucupira Posted August 29, 2007 Author Share Posted August 29, 2007 thnx for the replies Quote Link to comment 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.