Try to search your question here, if you can't find : Ask Any Question Now ?

"php not inserting in to mysql server in xampp"

HomeCategory: stackoverflow"php not inserting in to mysql server in xampp"
Avatarjohn asked 1 month ago

“I have read alot of problem been solved in stock overflow similar to my problem, and have seen alot of example, yet still my code is not inserting in to mysql. however if i hard feed the php it would insert. my info is comming as submit from html post.I have good server conncetion and also conncetion ot the datababase, can any one help me if i miss any thing. here is my code below.”

$servername = "localhost";
$username = "root";
$password = "";

// Create connection

$connection = mysqli_connect($servername, $username, $password, $db); // Establishing Connection with Server
if (!$connection) {
      die("Connection failed: " . mysqli_connect_error());
      echo "Connected successfully"; 

if(isset($_POST['submit'])){ // Fetching variables of the form which travels in URL
$name = $_POST['name'];
$image = $_POST['image'];

echo $name;
echo $image;

if($name !=''||$image !=''){
//Insert Query of SQL
$query = mysqli_query("INSERT INTO image (id, name, imagename) VALUES ('NULL', '$name', '$image')");
echo "Data Inserted successfully...!!";
echo "Insertion Failed <br/> Some Fields are Blank....!!";
mysqli_close($connection); // Closing Connection with Server

<form action = "test2.php" method="POST" enctype="multipart/form-data">
    <label>name: </label><input type="text" name="name" />
    <label>File: </label><input type="text" name="image" />
    <input type="submit" />

” i expect output of 5/2 to be 2.5″

1 Answers
Best Answer
AvatarMannu answered 1 month ago
Your Answer

5 + 18 =

Popular Tags

WP Facebook Auto Publish Powered By :