Go Back   Novahq.net Forum > Computers > Web design and Programming
FAQ Community Calendar Today's Posts Search

Web design and Programming Discuss website creation and other programming topics.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 11-28-2004, 11:42 AM
Stu is offline Stu
Resident Member

Join Date: Aug 2003
Posts: 3,319

Confused Continued news script, confused

Hey all, i'm still working on the news script, i'v aquired help from Blackbelt, and all is good... well sort of.
------------------------
What I've done so far:
- Succesfully create MySQL tables.
- Connect to the database.
- Make a form to submit news
Problems:
- So far i have submitted 2 news items, which have been submitted to the database, and confirmed.
- The to items appear on the news page, but the text doesn't.
------------------------
The url to the script is www.members.lycos.co.uk/sc20032004/bb-t2-news/ . Please treat the script with respect, and dont download or use this script without my permission(thnx). Does anyone know what i'm doing wrong? I would like to thank BlackBelt for helping me here, i'v learnt alot whilst making this script
- Warm regards
Reply With Quote
  #2  
Old 11-28-2004, 11:57 AM
JonM is offline JonM
Registered User

Join Date: Jun 2004
Posts: 2,156

perhaps i could see a script...it could kind of help > lol , but if you don't want to cuz of some people who may "steal" your script i understand. i made a news script a while back, there not as easy as i thought it would be...
Reply With Quote
  #3  
Old 11-28-2004, 12:01 PM
Stu is offline Stu
Resident Member

Join Date: Aug 2003
Posts: 3,319

elite, shall i PM you the code?
Reply With Quote
  #4  
Old 11-28-2004, 12:04 PM
katana*GFR* is offline katana*GFR*

Join Date: May 2002
Location: North Sea
Posts: 2,421

Send a message via ICQ to katana*GFR* Send a message via MSN to katana*GFR*
first of all get .htacces orso in it, or delete the install php form the directory,
It seems like the script echo's the $news_title Author: $news_author
$news_content

$news_title Author: $news_author
$news_content

instead of the text you entered. So i think you have to look at the code again m8
__________________
<- Sponsored by Chris



Found on Youtube:
Quote:
And if Newton Faulkner's voice can be described as "R&B" then Kurt Cobain must be a member of Boyz II Men.
Link here
Reply With Quote
  #5  
Old 11-28-2004, 12:04 PM
JonM is offline JonM
Registered User

Join Date: Jun 2004
Posts: 2,156

sure/i won't steal it lol
Reply With Quote
  #6  
Old 11-28-2004, 12:22 PM
Stu is offline Stu
Resident Member

Join Date: Aug 2003
Posts: 3,319

Ok, i might aswell put the code here, it has a copyright towards it anyway.
And apperntly your PM inbox is full, so this is the easy way round i guess.
Config.php
PHP Code:
<? 
// Database info !! Important for host changes !!
$host 'localhost'// Always keep as this
$username 'sc2003-2004'// MySql username
$password ''// MySql username's password
$databasename'sc20032004_uk_db'// MySql DB to connect to
//connect to mysql
$connect=mysql_connect("$host""$username""$password");
mysql_select_db("$databasename"$connect);
// Print headers and footers
$header '<img src="/images/news-head.gif"><p>';
$footer '<center><b>Powered by <a href="http://www.fleabib-php.tk"> FleabibPHP-News</a></b><center>';
// Process any errors
error_reporting(1); 
?>
install.php
PHP Code:
<?php
include('config.php');
$sql 'CREATE TABLE news ( 
     id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, 
     news_title TEXT,
     news_content TEXT, 
     news_date DATE NOT NULL 
   )'

if (@
mysql_query($sql)) { 
 echo 
'<p>News table sucessfully created!</p>'
} else { 
 exit(
'<p>Error creating tables: ' 
     
mysql_error() . '</p>'); 
}
?>
news_submit.php
PHP Code:
<?

include("config.php");    //All the config stuff.


If ($_POST['postnews']) {    //If the have sunmitted a form whose name is postnews
    
$news_title=$_POST["Title"];        //What this does is take the data entered into the form and turn it into a variable we can manipulate
$news_author=$_POST["Author"];
$newstext=$_POST["Text"];    

mysql_query("INSERT INTO news VALUES ('NULL', '$news_title', '$news_author', '$news_text')");

Echo(
"Data entered into database");
    
} ELSE {
Echo(
"<form method=\"POST\" action=\"news_submit.php\">");
Echo(
"<p><input type=\"text\" name=\"Title\" size=\"31\" value=\"Tecoma2\">Title of News Article<br>");
Echo(
"<input type=\"text\" name=\"Author\" size=\"31\">Author<br>");
Echo(
"<textarea rows=\"5\" name=\"Text\" cols=\"26\"></textarea>News as you want it displayed.<br>");
Echo(
"<input type=\"submit\" value=\"Submit\" name=\"postnews\"><input type=\"reset\" value=\"Reset\" name=\"B2\"></p>");
Echo(
"</form>");

}

?>
show-news.php
PHP Code:

<?php
require('config.php');
// Print news
$result=mysql_query("SELECT * FROM news") or die ("<br /><br />There's an error in the MySQL-query: ".mysql_error());
while(
$r=mysql_fetch_array($result)) {
$news_title= [$r'news_title'];
$news_author= [$r'news_author'];
$news_content=[$r'news_content'];
// Html Layout
include('layout.html');
}
?>
layout.html
<html>
<body>

<table width="358" border="1" cellpadding="0" cellspacing="0">

<tr>
<td width="358" height="17" valign="top">$news_title Author: news_author</td>
</tr>
<tr>
<td height="92" valign="top">$news_content</td>
</tr>

</table>

<br>
</body>
</html>
__________________________________
do u think u can help me here m8? I would be most greatful if u could.
- warm regards
Reply With Quote
  #7  
Old 11-28-2004, 12:54 PM
Stu is offline Stu
Resident Member

Join Date: Aug 2003
Posts: 3,319

ooo, now its not showing atall
Reply With Quote
  #8  
Old 11-28-2004, 01:01 PM
JonM is offline JonM
Registered User

Join Date: Jun 2004
Posts: 2,156

it can't be in html make it like this <td height="92" valign="top"><? echo"$news_content"; ?></td>
</tr> except do that for everything ...
Reply With Quote
  #9  
Old 11-28-2004, 01:24 PM
JonM is offline JonM
Registered User

Join Date: Jun 2004
Posts: 2,156

o wait hey on this whole layout.html ... i didn't realize it was a different page lolz anywayz instead of including it go ... :
PHP Code:
<?php 
require('config.php'); 
// Print news 
$result=mysql_query("SELECT * FROM news") or die ("<br /><br />There's an error in the MySQL-query: ".mysql_error()); 
while(
$r=mysql_fetch_array($result)) { 
$news_title= [$r'news_title']; 
$news_author= [$r'news_author']; 
$news_content=[$r'news_content']; 

?> 

<html>
<body>

<table width="358" border="1" cellpadding="0" cellspacing="0">

<tr>
<td width="358" height="17" valign="top"><? echo"$news_title"Author: echo"news_author";</td>
</
tr>
<
tr>
<
td height="92" valign="top"><? echo"$news_content"?> </td>
</tr>

</table>

<br>
</body>
</html>
Reply With Quote
  #10  
Old 11-28-2004, 02:11 PM
katana*GFR* is offline katana*GFR*

Join Date: May 2002
Location: North Sea
Posts: 2,421

Send a message via ICQ to katana*GFR* Send a message via MSN to katana*GFR*
i dont know much PHP but isnt HTML embedded into the PHP code? so the php close tag ( ?>) comes at the end of the html part here?
__________________
<- Sponsored by Chris



Found on Youtube:
Quote:
And if Newton Faulkner's voice can be described as "R&B" then Kurt Cobain must be a member of Boyz II Men.
Link here
Reply With Quote
  #11  
Old 11-28-2004, 03:08 PM
JonM is offline JonM
Registered User

Join Date: Jun 2004
Posts: 2,156

html is not embedded in php, but it can be ... but then things like <border="0"> would have to be echo"<border=\"0\">"; so sometimes with large html scripts it's easier to keep it not intergrated into php.
Reply With Quote
  #12  
Old 11-28-2004, 03:08 PM
Stu is offline Stu
Resident Member

Join Date: Aug 2003
Posts: 3,319

no katana m8, you can save a php file as a .php file if it has html in it, but the html either needs to be in echo() array or outside the <?php ?> tags .
P.s. Thnx elite ... but it didn't do much atall LOL it isn't showing all the news anymore.
http://www.members.lycos.co.uk/sc200.../show_news.php
Panther can you help us?

Last edited by Stu; 11-28-2004 at 03:19 PM.
Reply With Quote
  #13  
Old 11-28-2004, 03:15 PM
JonM is offline JonM
Registered User

Join Date: Jun 2004
Posts: 2,156

lol i guess i can't do it...ahhhhhhhh bak to sitting bak...

Last edited by JonM; 11-28-2004 at 03:27 PM.
Reply With Quote
  #14  
Old 11-28-2004, 03:19 PM
Stu is offline Stu
Resident Member

Join Date: Aug 2003
Posts: 3,319

lol sorry elite, refresh that post i just posted lol
Reply With Quote
  #15  
Old 11-28-2004, 03:32 PM
JonM is offline JonM
Registered User

Join Date: Jun 2004
Posts: 2,156

here is the script i would dO:::

PHP Code:
<?
require('config.php'); 
// Print news 
$result=mysql_query("SELECT * FROM news") or die ("<br /><br />There's an error in the MySQL-query: ".mysql_error()); 
while(
$myrow=mysql_fetch_array($result)) { 
printf("<table border=\"1\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse: collapse\" bordercolor=\"#111111\" width=\"100%\" id=\"AutoNumber1\" height=\"96\">
  <tr>
    <td width=\"100%\" height=\"19\">
$myrow[newstitle] :: Posted by $myrow[news_author]</td>
  </tr>

  <tr>
    <td width=\"100%\" height=\"76\" valign=\"top\">
$myrow[news_content]</td>
  </tr>
</table>
}
?>
Reply With Quote
  #16  
Old 11-28-2004, 03:37 PM
JonM is offline JonM
Registered User

Join Date: Jun 2004
Posts: 2,156

give that one a try, it is a lil different but is basically the same ... if it doesn't work that's my last try we'll just let a pro come in lol
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple News Script EDGE phphq.Net Forums 7 06-25-2007 05:52 PM
News Script JonM Web design and Programming 2 11-09-2004 04:11 PM
html news script? macd_m2 Web design and Programming 4 06-10-2003 12:35 PM
News script to Headlines þúÑî$h€® Web design and Programming 8 05-10-2003 11:45 AM
php news script? Se7eN Web design and Programming 2 05-04-2003 12:09 PM


All times are GMT -5. The time now is 12:42 AM.




Powered by vBulletin®