PHP Tutorial 26 – MySQL Introduction (PHP For Beginners)




Processing massive amounts of data without impairing the usability of an application is the most important to consider when developing high-end applications.

Original source


21 responses to “PHP Tutorial 26 – MySQL Introduction (PHP For Beginners)”

  1. Hi, I got an error message " Fatal error: Uncaught Error: Call to undefined function mysql_connect() in C:xampphtdocstutorialsmysql.php:5 Stack trace: #0 {main} thrown in C:xampphtdocstutorialsmysql.php on line 5".

    any idea how to solve it?

    The code I used is: "mysql_connect("localhost", "root", "password") or die(mysql_error()); "

    I tried adding an "i" to the code so that it becomes "mysqli_connect", the it still doesn't work.

    Regards,
    Andy

  2. /to connect mysql with php coding

    <?php

    $servername="localhost";
    $username="root"; /write your username here
    $password="**"; / write your password

    $conn=new mysqli("$servername","$username","$password"); */Mysqli stands My scripted query language improved

    if($conn->connect_error)
    {
    die("not connected".$conn->connect_error);
    }
    echo"connected successfully";

    ?>

  3. For all who has problem:

    <?php

    $user = 'root';
    $pass = ''; //your password
    $db = 'proiectbd'; //here you write the name of your database

    $db = new mysqli('localhost' ,$user , $pass , $db ) or die("Unable to connect");

    echo "Great work"; //to see that it works
    ?>

  4. mysql_connect("localhost", "root", "password")or die(mysql_error()); shows this error: Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead.

    Replace mysql_connect with PDO:
    $username = 'root';
    $password = 'password';
    $options = array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8');

    try {
        $dbh = new PDO($dsn, $username, $password, $options);
    } catch(PDOException $ex) {
        echo "An Error Occured!" . $ex;
    }

  5. Hello everyone can u tell me which username & password can i entered here because when i enter the username root & password is blank or any other it show the error message like couldn't connect to the database.I am doing work on mac-book pro.Please help me   

  6. what's wrong in my code can't insert data in to database

    <?php
            
            $connect = mysql_connect("localhost","root","root") or die(mysql_error());
            mysql_select_db("accounts",$connect);
            $sql = "
                CREATE TABLE users3
               {
                
    ID int NOT NULL AUTO_INCREMENT,
    Username VARCHAR(20),
    Password VARCHAR?(20),
    First VARCHAR(20),
    Last VARCHAR(20)

    )
     ";
            echo $sql;
                    
            mysql_query($sql,$connect);
            
            ?>

Leave a Reply