0

php sql doubt

i have tried making server the following code is able to do the display work on browser but unable to connect with database in sql. it is online at gillu.pagekite.me/index.php <html> <head> <title> php + sql </title> </head> <body> <a href="php.php">PHP</a> <p> <a href = "/pages/php.php">folder php</a> <form action="/data.php" method="get"> First Name : <input type="text" name="firstname"> <br> Last Name : <input type="text" name="lastname"> <br> <input type="submit" value="Submit"> </form> Welcome <?php echo $_GET["firstname"]; ?><br> Your surname is: <?php echo $_GET["lastname"]; ?> <?php $servername = "localhost"; $username = "root"; $password = "g123"; // Create connection $conn = mysqli_connect($servername, $username, $password, "firstDB"); if (!$conn) { die("Connection failed: " . mysqli_connect_error()); } else echo 'Hello'; $sql = "INSERT INTO tablll(fname , sname) VALUES('".$_GET["firstname"]."' , 'Dubey')"; if (mysqli_query($conn, $sql)) { echo "New record created successfully"; } else { echo "Error: " . $sql . "<br>" . mysqli_error($conn); } ?> </body> </html>

4th Apr 2017, 10:26 AM
Govind Choudhary
Govind Choudhary - avatar
6 Answers
+ 5
You also need to connect MYSQL in XAMPP.
4th Apr 2017, 10:33 AM
Cyrus Ornob Corraya
Cyrus Ornob Corraya - avatar
+ 5
Linux! can't help bro. My knowledge is bound in Windows. Sorry.
4th Apr 2017, 10:38 AM
Cyrus Ornob Corraya
Cyrus Ornob Corraya - avatar
+ 3
Are you using XAMPP or WAMP?
4th Apr 2017, 10:30 AM
Cyrus Ornob Corraya
Cyrus Ornob Corraya - avatar
0
i am using apache
4th Apr 2017, 10:32 AM
Govind Choudhary
Govind Choudhary - avatar
0
i do not know about this terms, but i use ubuntu, and installed apache2, sql and php using terminal, i am struck please help. visit this site : gillu.pagekite.me/index.php it is this one only the data is not coming in my database
4th Apr 2017, 10:37 AM
Govind Choudhary
Govind Choudhary - avatar
0
okay thanks bro, for introducing two new terms
4th Apr 2017, 10:40 AM
Govind Choudhary
Govind Choudhary - avatar