Your not opening a MySQL connection is why there is that error. MySQL's engine does the escaping not php which is why its mysql_real_escape_string(); also try error suppression so you can test it via if statement and display your desired error message. Make a new .php file and name it dbconfig.php set your database connection in it and include it in this file. You could also use a simple php CRUD implementation to since your queries are fairly simple it would save you in code time. try these orm to help speed your code up and simplify it to.
ORM
http://www.propelorm.org/
Framework
http://www.akelos.org/
or new file
PHP Code:
<?php
//database config
$DB['host'] = 'localhost';
$DB['port'] = 36;
$DB['username'] = 'root';
$DB['password'] = '';
if($DB[port] == NULL || $DB[port] == 36)
{
$DBCONN = @mysql_connect($DB[host],$DB[username],$DB[password]);
$DBSELECT = @mysql_select_db("table_here",$DBCONN);
if(!$DBCONN)
{
echo "Could not connect to database";
}
if(!$DBSELECT)
{
echo "could not select that database";
}
}
else
{
$DBCONN = @mysql_connect($DB[host] . ":" . $DB[port],$DB[username],$DB[password]);
$DBSELECT = @mysql_select_db("table_here",$DBCONN);
if(!$DBCONN)
{
echo "Could not connect to database";
}
if(!$DBSELECT)
{
echo "could not select that database";
}
}
?>
this way is bad since your fixed with just one table but you get the gist of it right? This keep a connection open and you could just remove the select db or use a new one as an override.