Tutorials
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOtherTutorials

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old February 22nd, 2004, 11:34 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
PHP/MySQL News with Comments by Matt Wade (HELP NEEDED)

Okay, so I've configured the news backend. It works like a charm. I've messed about with it a little (made it valid XHTML, some formatting) and it's now included on a page. http://mysite.com/?page=news for example and everything works well.

All I needed to do was change things do this kind of thing:
?page=news&&action=show&id={$row['id']}
(where Bold is added).

That's all easy. But I cannot, for the love of god create a seperate Add News file. I simply cannot, but please believe me I've tried, make a php form/file which sends news to the News Table in the SQL database.
Here is what it looks like at the moment:

php Code:
Original - php Code
  1.  
  2. <div id="shortpage">
  3. <h2>Add News</h2>
  4. <p><b>Add News Item:</b> </p>
  5. <div id="form">
  6. <form method="post" action="?page=add_news_post">
  7.   <input name="title" type="text" value="Subject" size="30" /><br />
  8.     <textarea name="newstext" cols="30" rows="10">News</textarea>
  9.   <input type="submit" name="submit" value="Submit">
  10. </form>
  11. </div>


and the add_news_post.php file:

php Code:
Original - php Code
  1.  
  2. <? //initilize PHP
  3. if($submit) //If submit is hit
  4. {
  5.     mysql_connect("localhost","db_user","db_password"); //then connect as user
  6.     mysql_select_db("db_mydb"); //select which database you want to edit
  7.     $result=MYSQL_QUERY("INSERT INTO news (id,postdate,title,newstext)".
  8.     "VALUES ('NULL', '$postdate', '$title', '$newstext')");
  9.    
  10.     //Insert the values into the correct database
  11.     print "<p>This file has the Database."; //Get a conformation that it has been uploaded
  12. }
  13. ?>


I've tried about a hundred variations, can't you just give us the answer Matt :-/
Thanks for any replies,
Jay

Reply With Quote
  #2  
Old February 22nd, 2004, 11:37 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: PHP/MySQL News with Comments by Matt Wade (HELP NEEDED)

Oh, and the top bit of code (the html) isn't really in <? and ?> tags at all, I added the [highlight=php] by mistake :-/
Jay

Reply With Quote
  #3  
Old February 23rd, 2004, 08:48 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: PHP/MySQL News with Comments by Matt Wade (HELP NEEDED)

I've now managed to get it working, but there for some reason the postdate will not work. :/ I cannot understand why, here is my post news:

php Code:
Original - php Code
  1.  
  2. <?php
  3. $db = mysql_connect("localhost", "jayhills_pixel","AWMRmm");
  4. mysql_select_db("jayhills_pixelated",$db);
  5.  
  6. //for new PHP
  7. $title=$_POST[title];
  8. $newstext=$_POST[newstext];
  9. //
  10.  
  11. $sql = "INSERT INTO news (id, postdate, title, newstext)
  12. VALUES ('','','$title','$newstext')";
  13. $result = mysql_query($sql);
  14. echo "Thank you! Information entered.n";
  15. ?>


Postdate is listed as TIMESTAMP with Deafult:NULL in my db.
php Code:
Original - php Code
  1.  
  2.         $query = "SELECT id,title,newstext," .
  3.                  "DATE_FORMAT(postdate, '%l, %D %M') as date " .
  4.                  "FROM news ORDER BY postdate DESC LIMIT $max_items";
Is my fetch code, but all i get from postdate is a load of 0's.

Reply With Quote
Reply

Viewing: Codewalkers ForumsOtherTutorials > PHP/MySQL News with Comments by Matt Wade (HELP NEEDED)


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five &quot;checkpoints&quot; for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway