I did and it didn't work either so I rebuilt it from one that is already working and just changed the info to the other database. Here's the one that I have working and haven't had any errors on. I know all this probably makes me look like a fool but I am really confused here to why the old one works and not the new one. I've checked and double checked the database info and rebuilt it several times. I event made it to where I only added 1 field and it still gave me an error.
and honestly I can't see a difference between your version of sprintf and mine except for '%s' instead of '$a_title'.
old original version that works:
<?php
function setinclude(){
$levels = substr_count($_SERVER['PHP_SELF'],'/');
$root = '';
for($i = 1; $i < $levels; $i++){$root .= '../';}
set_include_path($root);
}
setinclude();
include ('site/inc/session_start.php');
include ('login/auth.inc');
require_once ('login/settings.php');
require_once ('login/functions.php');
if ( isadmin ( $_SESSION['user_id'] ) ):
$dash = "-";
if (isset($_POST['a_image']) && isset($_POST['a_link']) && isset($_POST['a_alt'])) {
// Connect
$link = mysql_connect('localhost', 'dbinfo', 'dbinfo');
$select = mysql_select_db('dbinfo', $link);
if(!is_resource($link)) {
echo "Failed to connect to the server";
} elseif(!$select) {
echo "Failed to select database";
} else {
// Reverse magic_quotes_gpc/magic_quotes_sybase effects on those vars if ON.
if(get_magic_quotes_gpc()) {
if(ini_get('magic_quotes_sybase')) {
$a_image = str_replace("''", "'", $_POST['a_image']);
$a_link = str_replace("''", "'", $_POST['a_link']);
$a_alt = str_replace("''", "'", $_POST['a_alt']);
} else {
$a_image = stripslashes($_POST['a_image']);
$a_link = stripslashes($_POST['a_link']);
$a_alt = stripslashes($_POST['a_alt']);
}
} else {
$a_image = $_POST['a_image'];
$a_link = $_POST['a_link'];
$a_alt = $_POST['a_alt'];
}
}}
//Event Adress
$a_size = $_POST['a_size'];
$a_type = $_POST['a_type'];
$a_site = $_POST['a_site'];
//Added Date
date_default_timezone_set('EST');
$today = date('YmdHis');
// Make a safe query
$query = sprintf("INSERT INTO table
(image, link, alt, size, type, site, added)
VALUES ('$a_image', '$a_link', '$a_alt', '$a_size', '$a_type', '$a_site', '$today')",
mysql_real_escape_string($a_image, $link),
mysql_real_escape_string($a_link, $link),
mysql_real_escape_string($a_alt, $link),
mysql_real_escape_string($a_size, $link),
mysql_real_escape_string($a_type, $link),
mysql_real_escape_string($e_state, $link),
mysql_real_escape_string($a_site, $link),
mysql_real_escape_string($$today, $link)
);
mysql_query($query, $link);
if (mysql_affected_rows($link) > 0) {
echo "Ad inserted\n";
} else {
echo "Fill the form properly\n";
echo "<br />Do not use an apostrophe ( ' ). Use the HTML version: ( <b>'</b> )";
}
mysql_close($link);
include ('admin/admin-link.php');
echo "<a href=\"/ad-submit.php\">Monster Ad Submit</a>";
endif;
?>