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

?>

Link to comment
Share on other sites

<?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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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