I'm working on a very simple (at least I think it should be) php file to insert something into a database. I'm not a program but I've learned enough to get by.
Below is my code. I am getting the error:
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in i................... input.php on line 22
I am using a host gator account which I believe is php5
HTML FORM FILE:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Form Input Data</title>
</head>
<body>
<table border="1">
<tr>
<td align="center">Form Input Employees Data</td>
</tr>
<tr>
<td>
<table>
<form method="post" action="input.php">
<tr>
<td>Name</td>
<td><input type="text" name="name" size="60">
</td>
</tr>
<tr>
<td>Address</td>
<td><input type="text" name="address" size="80">
</td>
</tr>
<tr>
<td>Description</td>
<td><input type="text" name="description" size="100">
</td>
</tr><tr>
<td>Link</td>
<td><input type="text" name="link" size="180">
</td>
</tr><tr>
<td>Lat</td>
<td><input type="text" name="lat" size="40">
</td>
</tr><tr>
<td>Long</td>
<td><input type="text" name="lng" size="40">
</td>
</tr>
<tr>
<td>Type</td>
<td><input type="text" name="type" size="30">
</td>
</tr>
<tr>
<td></td>
<td align="right"><input type="submit"
name="submit" value="Send"></td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
Input.php File
<?php
//the example of inserting data with variable from HTML form
//input.php
require("sqlconnect.php");
// Opens a connection to a MySQL server
$connection=mysql_connect (localhost, $username, $password);
if (!$connection) { die('Not connected : ' . mysql_error());}
// Set the active MySQL database
$db_selected = mysql_select_db($database, $connection);
if (!$db_selected) {
die ('Can\'t use db : ' . mysql_error());
}
//inserting data marker
//possible INSERT INTO 'meingh_canadamap`.`markers` (
$marker = "INSERT INTO markers (id, name, address, description, link, lat, lng, type, approved)
VALUES(NULL, $_POST['address'], $_POST['description'], $_POST['link'], $_POST['lat'], $_POST['lng'], $_POST['type'], '0')";
//declare in the marker variable
$result = mysql_query($marker,$connection); //marker executes
if (!mysql_query($markers,$connection))
{
die('Error: ' . mysql_error());
}
echo "1 record added";
mysql_close($connection);
?>