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:
  #1  
Old February 23rd, 2004, 12:34 AM
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: 25
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 23rd, 2004, 12:37 AM
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: 25
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, 09: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: 25
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!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

Request Your Free Technology Downloads!
 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

Request Your Free Technology Downloads!
 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

Request Your Free Technology Downloads!
 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

Request Your Free Technology Downloads!
 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

Request Your Free Technology Downloads!
 

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




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek