my web site is http://gamewars.x10hosting.com/ click xbox button and post wars button and enter in any old info and you will see what is going wrong. Basically im getting an error and im not entering my data base name i guess correctly. plz help
$con = mysql_connect( '[B]localhost[/B]', 'gamewars_gamewars' , 'your[B]secret[/B]passwd');
mysql_select_db("my_db");
You really shouldn't make us wait for the connection to time out to get the error when you could have easily posted it yourself.Warning: mysql_connect() [function.mysql-connect]: Can't connect to MySQL server on 'gamewars_xbox360postedwars' (4) in /home/gamewars/public_html/postwarsxbox360.php on line 2
Could not connect: Can't connect to MySQL server on 'gamewars_xbox360postedwars' (4)
# localDB.php defines local_db_connect
include_once('localDB.php')
# the following should be abstracted away into classes
$fields=array_intersect(
array('firstname' => 'Game', 'lastname' => 'Gamertag',
'quantity' => 'Time and Date',
'items' => 'Number of rounds', 'players' => 'Number of players'),
$_POST
);
# define 'validate()' elsewhere and fill out function call here.
$errors = validate($_POST, ...);
if (count($errors)) {
foreach ($errors as $name => $msg) {
# reprint the form, with error messages inlined.
}
} else {
# this code in particular should be refactored into classes
try {
$db = local_db_connect('pdo', array('db' => 'gamewars_xbox360postedwars'));
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
# Note: the following four lines could be done in one, but have been separated
# for readability.
$columnClause = '`' . implode('`, `', $fields) . '`';
$valueClause = ':' . implode(', :', array_keys($fields)) ;
$query = "INSERT INTO Players ($columnClause) VALUES ($valueClause)";
$stmt = $db->prepare($query);
$stmt->execute($_POST);
} catch (PDOException $pdoe) {
# error reporting should be abstracted away into a function or class
$errorMsg = __FILE__ . '@' . __LINE__ . ':' . $pdoe->getMessage();
error_log($errorMsg);
# note: $siteAdmin and $from need to be set somewhere, a strong argument for a class.
mail($siteAdmin, $from, "Script error on $_SERVER[SERVER_NAME]",$errorMsg);
echo "Internal error. It's been logged, ";
}
}