I just started using MYSQL so I'm not sure if I've done something wrong here. The data went into the database but the first character of the first query was removed.
I executed this query in PHP and it inserted into the database but the first value was shortened by it's first character.
This was the query I then commented it out to see if it was correct.
$query = "INSERT INTO Locations (Zip, LAT, LNG, Name, Address) VALUES (01915, 45.5, 55.6, 'Name', 'Address');";
The output is
1915<br />45.5<br />55.6<br />Name<br />Address<br />
PHP Code:
<?php
include_once('db_conn.php');
//$query = "INSERT INTO Locations (Zip, LAT, LNG, Name, Address) VALUES (01915, 45.5, 55.6, 'Name', 'Address');";
$query = "SELECT * FROM Locations";
// Perform Query
$result = mysql_query($query);
if (!$result) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
}
// Use result
// Attempting to print $result won't allow access to information in the resource
// One of the mysql result functions must be used
// See also mysql_result(), mysql_fetch_array(), mysql_fetch_row(), etc.
while ($row = mysql_fetch_assoc($result)) {
echo $row['Zip'] . "<br />";
echo $row['LAT'] . "<br />";
echo $row['LNG'] . "<br />";
echo $row['Name'] . "<br />";
echo $row['Address'] . "<br />";
}
// Free the resources associated with the result set
// This is done automatically at the end of the script
mysql_free_result($result);
?>
Bookmarks