Re: Help with a script

From: Date: Sat, 23 Aug 2003 15:18:19 +0000
Subject: Re: Help with a script
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-160507@lists.php.net to get a copy of this message
what is the source for the page that you initially enter the data on the web form look like? Jim Lucas ----- Original Message ----- From: "Stevie D Peele" <sdp2006@juno.com> To: <php-general@lists.php.net> Sent: Saturday, August 23, 2003 6:25 AM Subject: [PHP] Help with a script > I've been working on a script for quite some time now, particulary a site > news script. Heres how it works > > 1. Information is passed from a form to the database > 2. Table is selected to a page to be viewed by the general public. > > The problem is, when I use the form, there are no errors in the script, > but nothing is entered into the database. > > Here are my scripts > ------------------------------------The > Query------------------------------------ > CREATE TABLE SiteNews > ( > Alias varchar(50) NOT NULL default '0', > News BLOB NOT NULL, > NewsDate Date NOT NULL > ) TYPE=MyISAM > ------------------------------------------------------------------------- > --------- > > ------------------------------------form > action------------------------------------ > <?php > include ('config.php'); > $link = @mysql_pconnect($location, $username, $password) > or die("Could not connect to the databaseserver. Please go back and > try again or try again later."); > @mysql_select_db($database, $link) > or die ("Could not select database. Please go back and try again or > try again later."); > $sql_insert = "INSERT INTO SiteNews > ('Alias','News','NewsDate') > VALUES ('". addslashes($_POST['newsperson']) . "','" . > $_POST['date'] . > "','" . addslashes($_POST['thenews']) . "')"; > > $result = mysql_query($sql_insert, $link); > echo (mysql_affected_rows($link) . " News entry inserted"); > ?> > ------------------------------------------------------------------------- > ------------- > > ------------------------------------Viewing the news > script--------------------------- > <?php > include ('config.php'); > $link = @mysql_pconnect($location, $username, $password) > or die("Could not connect to the databaseserver. Please go back and > try again or try again later."); > @mysql_select_db($database,$link) > or die ("Could not select database. Please go back and try again or > try again later."); > $sql = "SELECT Alias, NewsDate, News FROM SiteNews ORDER BY NewsDate > DESC"; > $news = mysql_query($sql,$link) or > die(mysql_error().'<p>'.$sql.'</p>'); > > if ($news){ > if (mysql_num_rows($news)== 0){ > echo ("No newsitems found."); > } > else{ > while ($row = mysql_fetch_assoc($news)){ > echo("<p>"); > echo($row['Alias']. "<br />"); > echo($row['NewsDate']."<br />"); > echo($row['News']); > echo("</p>"); > echo("<hr />"); > } > } > } > else{ > echo("Queryproblem"); > } > > ?> > ------------------------------------------------------------------------- > ------------- > > Can anyone see what is wrong?? > > Thanks

« previous php.general (#160507) next »