Hey guys, I would appreciate it if someone could help me with the following code I am using to try and insert data into a MYSQL table. I KNOW this code is not great, but its just for testing/learning. For some reason, I seem to be getting the following error:
Parse error: syntax error, unexpected ‘’ (T_ENCAPSED_AND_WHITESPACE), expecting ‘]’ in /home/gamersun/public_html/truckworld/submit.php on line 41
My code is the following:
[php]<?php
if (isset ($_POST[‘submit’])){
require_once(“includes/inc_files.php”);
$servername = “localhost”;
$username = “”;
$password = “”;
$dbname = “”;
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
mysql_select_db(“gamersun_truckworld”,$con);
$sql = “INSERT INTO jobs (username,s_loc,e_loc,distance,earnings,cargo,s_time,e_time,f_cost,m_cost,dam_trailer,dam_truck) VALUES (’$_POST[Your Name]’,’$_POST[Pick up Location]’,’$_POST[Destination]’,’$_POST[Distance]’,’$_POST[Cargo/Load]’,’$_POST[Starting Time]’,’$_POST[Earnings]’,’$_POST[Duration]’,’$_POST[Fuel Cost]’,’$_POST[Maintenance Cost]’,’$_POST[Damage % truck]’,’$_POST[Damage % trailer]’)”;
mysql_query($sql,$con);
mysql_close($con);
}
?>[/php]
Would love it if someone could lighten me up to what is going wrong, I just cant seem to work it out. Sorry if its very simple.
Thanks.