My php does not post information to mysql


In my php file i have made it so it post information to mysql and it works when i use “XAMPP” to host it from my local pc but when i copy the file over to my website and change the mysqli_connect with the right settings it dosnt post anything in mysql database, please help.
Thanks, Victor


So what is your code and what is your site and what are your config settings?


Im using php version :PHP 5.6 (becouse newer version dosnt work to open up the php file)
This is the php code:

	//connect to database
	$db = mysqli_connect("localhost", "username", "password", "database");
	if(isset($_POST['send_btn'])) {
		$firstname = mysql_real_escape_string($_POST['firstname']);
		$lastname = mysql_real_escape_string($_POST['lastname']);
		$age = mysql_real_escape_string($_POST['age']);
		$email = mysql_real_escape_string($_POST['email']);
		$ingusername = mysql_real_escape_string($_POST['ingusername']);
		$position = mysql_real_escape_string($_POST['position']);
		$why = mysql_real_escape_string($_POST['why']);
		$mcexperience = mysql_real_escape_string($_POST['mcexperience']);
		$weexperience = mysql_real_escape_string($_POST['weexperience']);
		$anything = mysql_real_escape_string($_POST['anything']);
		$sql = "INSERT INTO application(firstname, lastname, email, age, ingusername, position, why, mcexperience, weexperience, anything) VALUES('$firstname', '$lastname', '$age', '$email', '$ingusername', '$position','$why','$mcexperience','$weexperience','$anything')";
		mysqli_query($db, $sql);
		header("location: applied.php");



<!DOCTYPE html>
		<title>Staff Application</title>
		<meta charset="utf-8">
		<link href="style.css" type="text/css" rel="stylesheet">
	<h2>Staff Application</h2>
	<div class="wrapper">
		<form method="post" action="index.php">
					<td>First Name: </td>
					<td><input type="text" name="firstname" class="textInput" required></td>
					<td>Last Name: </td>
					<td><input type="text" name="lastname" class="textInput" required></td>
					<td>Age: </td>
					<td><input type="number" name="age" class="textInput" required></td>
					<td>E-mail: </td>
					<td><input type="email" name="email" class="textInput" required></td>
					<td>InGame Username: </td>
					<td><input type="text" name="ingusername" class="textInput" required></td>
					<td>Applying position: </td>
					<td><select name="position" class="dropdownInput" required>
						<option>Plugin Developer</option>
					<td>Why should you be a staff: </td>
					<td><textarea name="why" cols="40" rows="5" class="boxInput"></textarea></td>
					<td>Minecraft Experience: </td>
					<td><select name="mcexperience" class="dropdownInput">
					<td>WorldEdit Experience: </td>
					<td><select name="weexperience" class="dropdownInput">
					<td>Anything worth mension: </td>
					<td><textarea name="anything" cols="40" rows="5" class="boxInput"></textarea></td>
					<td><input type="submit" name="send_btn" value="Send" class="send_btn"></td>


I can assume you created a database within and then put those details into the script?


for example


yes i did create one a database in 000webhost and i have the right database information.


Just replace the"mysql_real_escape_string"
and only use $_POST[‘firstname’];
like this:
$firstname =$_POST[‘firstname’];
and it will be ok


I changed the code but now i cant load the site anymore.
Error message:

The page does not work on ----.----.—

-----.-----.— currently unable to handle the request.
HTTP Error 500


Visit general settings on and choose the PHP version you are working with :slight_smile:


I fixed it i forgot to remove “)” after the name of the string :slight_smile:
Thanks everyone that helped me :slight_smile: