Current location: Hot Scripts Forums » Programming Languages » PHP » news problems


news problems

Reply
  #1 (permalink)  
Old 03-23-04, 05:14 PM
darkcarnival's Avatar
darkcarnival darkcarnival is offline
PHP/MySQL coder
 
Join Date: Jun 2003
Posts: 939
Thanks: 0
Thanked 0 Times in 0 Posts
news problems

hi,

fixed the last problem,in a way but now i got a different one now. when the news is viewed, it will not sure the post like i want it to show. like for example if i wanted to show dates or names like:

3/2/04-me
3/5/04-you
3/23/04-meself

it will show up like this:

3/2/04-me3/5/04-you3/23/04-meself

any ideas on whats doing this?thx.
Reply With Quote
  #2 (permalink)  
Old 03-23-04, 05:29 PM
Infinite_Hackers's Avatar
Infinite_Hackers Infinite_Hackers is offline
Coding Addict
 
Join Date: Dec 2003
Posts: 307
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by darkcarnival
hi,

fixed the last problem,in a way but now i got a different one now. when the news is viewed, it will not sure the post like i want it to show. like for example if i wanted to show dates or names like:

3/2/04-me
3/5/04-you
3/23/04-meself

it will show up like this:

3/2/04-me3/5/04-you3/23/04-meself

any ideas on whats doing this?thx.
please show us your script (never forget that!)
__________________
New beta project: GFX-PRO.ATH.CX
Description: GFX-PRO a great new project that anyone can and setup in less then a minute. [ More info ]
Website: http://gfx-pro.ath.cx
Status: Online
http://gfx-pro.ath.cx/sig.png
Reply With Quote
  #3 (permalink)  
Old 03-23-04, 05:52 PM
darkcarnival's Avatar
darkcarnival darkcarnival is offline
PHP/MySQL coder
 
Join Date: Jun 2003
Posts: 939
Thanks: 0
Thanked 0 Times in 0 Posts
well im not sure what line to show. if you tell me what line, ill show it
Reply With Quote
  #4 (permalink)  
Old 03-23-04, 06:00 PM
Infinite_Hackers's Avatar
Infinite_Hackers Infinite_Hackers is offline
Coding Addict
 
Join Date: Dec 2003
Posts: 307
Thanks: 0
Thanked 0 Times in 0 Posts
show us the line(s) where you get your information and display it
__________________
New beta project: GFX-PRO.ATH.CX
Description: GFX-PRO a great new project that anyone can and setup in less then a minute. [ More info ]
Website: http://gfx-pro.ath.cx
Status: Online
http://gfx-pro.ath.cx/sig.png
Reply With Quote
  #5 (permalink)  
Old 03-23-04, 06:40 PM
darkcarnival's Avatar
darkcarnival darkcarnival is offline
PHP/MySQL coder
 
Join Date: Jun 2003
Posts: 939
Thanks: 0
Thanked 0 Times in 0 Posts
do you mean the line that displays the info or the line that inserts the info in the DB?
Reply With Quote
  #6 (permalink)  
Old 03-23-04, 06:53 PM
Infinite_Hackers's Avatar
Infinite_Hackers Infinite_Hackers is offline
Coding Addict
 
Join Date: Dec 2003
Posts: 307
Thanks: 0
Thanked 0 Times in 0 Posts
the whole code... really.. we just need to see how/what you code is... and how we can help you... :S
__________________
New beta project: GFX-PRO.ATH.CX
Description: GFX-PRO a great new project that anyone can and setup in less then a minute. [ More info ]
Website: http://gfx-pro.ath.cx
Status: Online
http://gfx-pro.ath.cx/sig.png
Reply With Quote
  #7 (permalink)  
Old 03-23-04, 07:20 PM
darkcarnival's Avatar
darkcarnival darkcarnival is offline
PHP/MySQL coder
 
Join Date: Jun 2003
Posts: 939
Thanks: 0
Thanked 0 Times in 0 Posts
ok then

PHP Code:

<?

echo "<FORM METHOD=\"post\" ACTION=\"/News2/Post.php?action=process_post\">";
echo 
"Logged in as: $metaluser<BR>";
echo 
"Posting In: <SELECT NAME=\"cat\">";
echo 
"<OPTION VALUE=\"\">Select Category<BR>";

include 
"/home/httpd/vhosts/metalstation1.com/httpdocs/News2/config.php";

$db_connection mysql_connect ($DB_HOST$DB_USER$DB_PASS) or die ('Could not connect to MySQL: ' mysql_error());
mysql_select_db ($DB_NAME) or die ('Could not Select Database: ' mysql_error());
$query2 mysql_query("select * from News_Category");

if (
$query2)
        {

$numOfRows mysql_num_rows ($query2);

for (
$i 0$i $numOfRows$i++)
        {
$cat mysql_result ($query2$i"Category");

echo
"<OPTION VALUE=\"$cat\">$cat<BR>";
        }
echo 
"</SELECT><BR>";
        }
else
        {
echo 
mysql_errno().": ".mysql_error()."<BR>";
        }
echo 
"Subject: <input type=\"text\" name=\"subject\" SIZE=\"35\" value=\"\" class=\"text\"><BR>";
echo 
"<TEXTAREA NAME=\"body\" ROWS=\"15\" COLS=\"50\" WRAP=\"hard\" class=\"text\"></TEXTAREA><BR>";
echo 
"<INPUT TYPE=\"submit\" Value=\"Post\" class=\"submit\">";
echo 
"</FORM>";
  switch ( 
$action )
  {
  case 
'process_post':
  
  if (
$subject == ""){
  echo 
"You didnt add a subject. Please go back and add it.";
       }
  elseif (
$body == ""){
  echo 
"You didnt add anything. Please go back and do add something.";
  }
  elseif (
$cat == ""){
  echo 
"You didn't add a category. Please enter a category.";
  }
  else{
        include 
"/home/httpd/vhosts/metalstation1.com/httpdocs/News2/config.php";
        
$db_connection mysql_connect ($DB_HOST$DB_USER$DB_PASS) or die ('Could not connect to MySQL: ' mysql_error());
        
mysql_select_db ($DB_NAME) or die ('Could not Select Database: ' mysql_error());

            
$query mysql_query("insert into News_Posts (Subject, Body, Date, Username, Category) values ('$subject', '$body', CURDATE(), '$metaluser', '$cat')");

            if (
$query)
            {
              echo 
"Success! being redirected to post, click <A HREF=\"/News2/view.php?cat=$cat\">here</A> if your want to go now.";
              echo 
"<META HTTP-EQUIV=\"Refresh\" CONTENT=\"2; URL=/News2/view.php?cat=$cat\">";
            }
            else
            {
              echo 
"post error! below is error message:<BR>";
              echo 
mysql_errno().": ".mysql_error()."<BR>";
            }
      }
  break;
  }
Reply With Quote
  #8 (permalink)  
Old 03-24-04, 07:08 AM
Infinite_Hackers's Avatar
Infinite_Hackers Infinite_Hackers is offline
Coding Addict
 
Join Date: Dec 2003
Posts: 307
Thanks: 0
Thanked 0 Times in 0 Posts
Where in your code does it display
3/2/04-me3/5/04-you3/23/04-meself

(when viewed)
__________________
New beta project: GFX-PRO.ATH.CX
Description: GFX-PRO a great new project that anyone can and setup in less then a minute. [ More info ]
Website: http://gfx-pro.ath.cx
Status: Online
http://gfx-pro.ath.cx/sig.png
Reply With Quote
  #9 (permalink)  
Old 03-24-04, 02:44 PM
darkcarnival's Avatar
darkcarnival darkcarnival is offline
PHP/MySQL coder
 
Join Date: Jun 2003
Posts: 939
Thanks: 0
Thanked 0 Times in 0 Posts
alright, i think i figured it out

what i was using as a example was the body($row[body])

when my program outputs the body of my news its putting it out in text form. because i made a test post that did this:

hi,

test

bye

and it came out like this:

hi test bye

now is there a code that will add <BR> to blank spots? or is there a small problem that im not getting at?

but im talking about the body variable.
Reply With Quote
  #10 (permalink)  
Old 03-24-04, 03:43 PM
Keith's Avatar
Keith Keith is offline
Community Liaison
 
Join Date: Feb 2004
Posts: 1,232
Thanks: 1
Thanked 11 Times in 11 Posts
Wherever you want to break to a new line, add <br /> to the end of the echo string, inside the quotations.
Reply With Quote
Reply

Bookmarks


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

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Archiving timestamped news by month? Keith PHP 5 03-06-04 05:28 PM
Starting Small - A simple news script RaiTid_R PHP 4 03-06-04 12:45 PM
news pending program florindin77 Script Requests 1 07-23-03 01:55 PM
Page ID for news articles... macj1326 PHP 16 07-04-03 02:13 PM
More inserting problems Psybadek PHP 7 06-17-03 04:39 AM


All times are GMT -5. The time now is 10:21 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.