mysql_query help: check table for entires
ok back again for some help...
I have created a table with entires. I would like to be able to check this table when a new entry is being inserted so I don't have duplicates.
I have highlighted the line of code that is giving me trouble below. I get an error that reads "Parse error: syntax error, unexpected T_VARIABLE in /home2/whackand/public_html/index_files/basic_db_wiki.php on line 68" and I can't seem to figure out how to fix it.
I know it is probably a simple fix. Any help is appreciated.
//Checking database for existance of table
function table_exists($table, $db)
//retrives the whole list of tables from database
$tables_check = mysql_list_tables($db);
echo mysql_list_tables($db) . "<br />";
//cycles through the list checking each entry
while (list ($temp) = mysql_fetch_array($tables_check))
if ($temp == $table)
//declaration of variables
//creating connection to server
$con = mysql_connect("localhost","username","password") or die('Could not connect to server' . mysql_error());
$table = "entries";
$db = "whackand_wikieng";
//create table "entries" process
$crt_table = "CREATE TABLE $table
Number int NOT NULL AUTO_INCREMENT,
//insert values into "entries" process
$insert_value = "INSERT INTO $table
//getting entries from table for evaluation
$result = mysql_query(SELECT * FROM $table WHERE $name = '$_POST[Name]', $con);
//execution of page
//checking for table existance
mysql_query($crt_table, $con) or die('Could not create table' . mysql_error());
//checking for value in table, if it doesnt exist, insert value
echo "The entry already exists."
//closing server connection
You need quotes around the entire SQL query string, so that PHP treats it as a string literal and not as a sequence of constants, PHP keywords, and/or operators.
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
thanks a bunch i will have to try to remember that one.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)