- 1

Plz any one can change following mysql code to mysqli and pdo ??

i wrote following code in mysql , plz any one can change this code to mysqli ?? <html> <body bgcolor=#777 text=yellow> <form action=submit.php method=post> <pre> id <input type=text name=id size=5> <br> User name <input type=text name=username> <br> Password <input type=password name=password> <br> Age <input type=text name=age> <br> Salary <input type=text name=salary> <br> <input type=submit> </pre></form> </body> </html> <?php if($_SERVER["REQUEST_METHOD"]=="POST") { $id=$_

27th Dec 2017, 6:40 PM
hassan
3 Respostas
0
bro this is just HTML and some php . there is no MySQL query written here..anyway the difference in MySQL and mysqli is in mysqli you have to pass the $conn at every requests. means at fetching or at running any query.
27th Dec 2017, 6:49 PM
ARNAB BISWAS
ARNAB BISWAS - avatar
0
jamie check the code below now a new is it correct code of mysqli ? <html> <body bgcolor=#777 text=yellow> <form action=submit1.php method=post> <pre> id <input type=text name=id size=5> <br> User name <input type=text name=username> <br> <input type=submit> </pre> </form> </body> </html> <?php if($_SERVER["REQUEST_METHOD"]=="POST") { $id=$_POST['id']; $username=$_POST['username']; $con=mysqli_connect("localhost" , "root" , "" , "hassan"); // no space allowed b/w double quotes if(mysqli_connect_errno()) { echo "failed to connect to mysql" . mysqli_connect_error(); } else { mysqli_query($con , "INSERT INTO student (id , username ) VALUES ('$id' , '$username')"); echo "your record is added successfully <br>"; } $con->close(); } ?>
28th Dec 2017, 7:25 PM
hassan
- 1
hey arnab can u change only that mysql portion into mysqli ??
27th Dec 2017, 6:56 PM
hassan