Page 360 - CITS - CSA - TP (Volume 1) - Hindi
P. 360

कंप्यूटर सॉफ्टवेयर एप्लीकेशन- CITS







































           टा  2: PHP से MySQL डेटाबेस से कने  कर  और डेटा इ ट  करे

           1  टे  एिडटर ओपन करे
           2  िन िल खत कोड िलख

                          <html >
                 <head>

                      <title> </title>
                 </head>
                 <body>
                    <?php
                       // Database connection parameters
                       $servername = “localhost”;  // Change this if  MySQL server is on a different host
                       $username = “your_username”; // Change this to your MySQL username

                       $password = “your_password”; // Change this to your MySQL password
                       $database = “example_db”;    // Change this to your database name
                       // Create connection
                       $conn = new mysqli($servername, $username, $password, $database);
                                // Check connection

                    if ($conn->connect_error) {
                        die(“Connection failed: “ . $conn->connect_error);
                        }
                 $sql = “INSERT INTO persons (first_name, last_name, email) VALUES (‘Peter ,         ‘Parker , ‘peterparker@mail.
                 com )”;
              if ($conn->query($sql) === TRUE) {



                                                           344

                                     CITS : IT & ITES - कं  ूटर सॉ वेयर ए ीके शन - अ ास 61
   355   356   357   358   359   360   361   362   363   364   365