Hi. I've just written a script enabling me to post news on my news page. One problem tho! When I posted first time it worked fine, but my second post wont display? it gets into the database successfully but its not getting to the news page! why? My code:
news page:
<?php echo '<font face="Palatino Linotype" size="2"> ' . $a_row['postDate'] . '</font>' ?>
<?php echo '<font face="Palatino Linotype size="2"> ' . $a_row['postedBy'] . '</font>'; ?>
?php echo '<font face="Palatino Linotype" size="2"> ' . $a_row['postSubject'] . '</font>'; ?>
<?php echo '<font face="Palatino Linotype" size="2"> ' . $a_row["posttext"] . '</font>'; ?>
<?php echo '<font face="Palatino Linotype" size="2"> ' . $a_row["postRule"] . '</font>'; ?>
create post page:
<?php
if($Submit=="Post News"){
$error = verify_data($HTTP_POST_VARS);
if ($error == "")
$success = "News Posted Successfully!";
}
?>
<?php
function verify_data($formdata) {
$error = "";
$form_data = trim_data($formdata);
$user = $form_data['posttext'];
if (!check_form($form_data)) {
$error="All Form Fields must be filled in";
return($error); }
data into table
$insert_check = insert_data($formdata);
error
if ($insert_check != "true")
return($insert_check);
inserted successfully
return("");
}
function insert_data($formdata) {
$error = "";
$myhost = "localhost";
$myuser = "subastic";
$mypass = "pass";
$mydb = "evostation_com_2";
$postDate = $formdata['postDate'];
$postSubject = $formdata['postSubject'];
$postedBy = $formdata['postedBy'];
$posttext = $formdata['posttext'];
$postRule = $formdata['postRule'];
$mysql = mysql_connect($myhost, $myuser, $mypass);
if (!$mysql) {
$error = "Cannot connect to mySQL server";
return($error);
}
$mysqldb = mysql_select_db($mydb, $mysql);
if (!$mysqldb) {
$error = "Cannot open Database";
return($error);
}
$myquery = "INSERT INTO es_news_posts ( PostDate, postSubject, postedBy, posttext, postRule) VALUES ('$postDate', '$postSubject', '$postedBy', '$posttext', '$postRule')";
$result = mysql_query($myquery, $mysql);
if (!$result) {
$error = "Cannot run Query";
return $error;
}
return("true");
}
?>
I have an include file for that (obviously). Whats going wrong? thx.