Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. SQL Server
  3. Question
SQL Server

Call to undefined function mysql_query() with Login

Asked by Crowny Hasegawa Jun 8, 2021 994 views 1 answer
Share

About this question

<?php
    $user = 'root';
    $password = 'root';
    $db = 'inventory';
    $host = 'localhost';
    $port = 8888;
    $link = mysqli_init();
    $success = mysqli_real_connect(
       $link,
       $host,
       $user,
       $password,
       $db,
       $port
    );
    ?>
    <?php
    $username = $_POST['username'];
    $password = $_POST['password'];
    $sql = mysql_query("SELECT * FROM login WHERE username = '".$_POST['username']."' and password = '".md5($_POST['password'])."'");
    $row = mysql_num_rows($sql);
    if($rom > 0 )
    {
      session_start();
      $_SESSION['username'] = $_POST['username'];
      $_SESSION['password'] = $_POST['password'];
      echo "login done";
    }else {
      echo "fail login ";
    }
    ?>
The Error
PHP Fatal error: Uncaught Error: Call to undefined function mysql_query() in /Applications/MAMP/htdocs/lprapp/config.php:23 Stack trace:#0 {main} thrown in /Applications/MAMP/htdocs/lprapp/config.php on line 23 

When I am trying to execute my PHP code below, I am getting a fatal error “call to undefined function mysql_query()” and don’t know how to resolve it.

Your answer

1 Answer

More SQL Server discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest SQL Server Blogs

Guides, tips and career advice on SQL Server from JanBask experts.