Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Blank page after attempt to insert

Tags:

mysql

Whenever I try to insert data into my database 'users' I always get a blank page. It doesn't give me any errors, it doesn't include 'mainmenu.php', or return any feedback what so ever. Can someone help me out? Here is the code:

<?php

include("mainmenu.php");

$con = mysql_connect("localhost", "root", "*********");
if (!$con) {
   die('Connection failure.' . mysql_error());
   }

//Variable def
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$email = $_POST['email'];
$usrname = $_POST['usrname'];
$password = $_POST['password'];

mysql_select_db("users",$con) or die(mysql_error());
mysql_query("INSERT INTO data (usrname, fname, lname, password, email) VALUES ($usrname, $fname, $lname, $password, $email)") or die(mysql_error());
mysql_close($con)

echo("Thank you for registering!")
?>

It looks right to me.

like image 434
Ken Avatar asked Jan 21 '23 18:01

Ken


1 Answers

don't you getting any syntax error?

first

mysql_close($con)
echo("Thank you for registering!")

change to

mysql_close($con);
echo("Thank you for registering!");

second, please quote your $_POST and escape it properly
read this - Escaping single quote in PHP when inserting into MySQL)

like image 143
ajreal Avatar answered Jan 31 '23 07:01

ajreal