Jump to content

[SOLVED] Call to undefined function mysql_connect()


jsucupira

Recommended Posts

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';

?>

<?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.

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

}

?>

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.

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.