<?php
$location = "localhost";
$username = "username";
$password = "password";
$database = "database";
$conn = mysql_connect("$location","$username","$password");
if (!$conn) die ("Could not connect MySQL");
mysql_select_db($database,$conn) or die ("Could not open database");
mysql_query("DROP TABLE IF EXISTS auth_info");
mysql_query("CREATE TABLE auth_info(username varchar(10), password varchar(10), trainer varchar(30))";// or die ("Could not create table");
print ("Error: ".mysql_error()."<BR>\n");
$insert = "INSERT INTO auth_info(username, password) VALUES ('username','password')";
mysql_query($insert) or die ("Could not add data to the table");
$query = "SELECT * FROM auth_info";
$result = mysql_query($query);
while ($row = mysql_fetch_array($result))
{
echo "The username is $row[username]";
echo "The password is $row[password]";
}
?>
I get an error something along the lines of:
Error: You have an error in your SQL syntax near '' at line 1
Could not add data to the table
I'm hoping I'm just missing something easy so I thought I'd have you folks check it over for misplaced semicolons(😉 or quotations("). Thanks
*EDIT - The error is coming from line 10 because if I uncomment the "die" part of it, I get the "Could not create table" message.
*EDIT II - Swapped my " and ) on line 10. Now I'm getting an error:
Parse error: parse error in /opt/htdocs/cantonsc/usertable.php on line 10