Jump to content

PHP/MySQL news cms problem...please help?


Guest tripnosis
 Share

Recommended Posts

Guest tripnosis

I'm having the most annoying problem. I have a PHP/MySQL script I use for a news cms. I have never had any problems with it, till now. I use it on 2 sites with no issues. Now I am doing a site for a client, and for no explainable reason, most of it won't work. Maybe a little explanaition is needed:My news script uses an index page, which displays all the news stories in the datbase, with a "preview" paragraph, with a "read more" link, which the user may click to go to a page to view the entire article. There are also links to delete or edit the article(in the finished script, these are in the news admin section), and you may add new articles to the database with a seperate file, "add.php".Here is the problem I'm having. The index page will diplay any articles in the database, but if you click the "read more" "edit" or "delete" links, it goes to the appropriate page (read_more.php?newsid=1, delete_news.php?newsid=1, etc) but where the content should display, I get nothing, the header and footer load, but the box where content displays is empty. Furthermore, it won't add articles with the add.php page, when you fill out the fields, and click "submit" it just goes back to "add.php", and doesn't add the article to the database.Now here is where it gets really weird. As I said, I have already used this script before with no issues. So I uploaded the current site I am having issues with to my own server, and tested it using the MySQL on my server, and it works no problem! It is the EXACT same site that won't work on the clients server, WTH?!?!Both hosts use cpanel, and come with MySQL and PHP installed. Both hosts are basically the same, with some mild diferences in the software versions. If anyone has any idea what the issue could be, you'll be my hero man. Here is a link to both the working, and non-working versions:Working version: http://www.djtripnosis.com/productionNon-working version: http://www.maxxiumtraxx.com/productionAlso, here is some info on the servers:Working version server:PHP 4.4.1MySQL 4.0.26phpMyAdmin 2.6.4-pl2Cpanel 10.8.1-STABLE 114Non-working version server:PHP 4.3.11MySQL 4.1.13-standardphpMyAdmin 2.6.4-pl2Cpanel 10.8.1-STABLE 114I am new to PHP, but maybe this could be a register globals issue?and here's the source code for the add.php page:

<?phpinclude("../header.php");include("../dbconnect.php");   if($submit)  {//begin of if($submit).      // Set global variables to easier names      $title = $_POST['title'];      $text1 = $_POST['text1'];      $text2 = $_POST['text2'];               //check if (title) field is empty then print error message.              if(!$title){  //this means If the title is really empty.                     echo "Error: News title is a required field. Please fill it.";                     exit(); //exit the script and don't do anything else.              }// end of if          //run the query which adds the data gathered from the form into the database         $result = mysql_query("INSERT INTO news (title, dtime, text1, text2)                       VALUES ('$title',NOW(),'$text1','$text2')",$connect);          //print success message.          echo "<b>Thank you! News added Successfully!<br>You'll be redirected to Home Page after (4) Seconds";          echo "<meta http-equiv=Refresh content=4;url=index.php>";  }//end of if($submit).    // If the form has not been submitted, display it!else  {//begin of else       ?>      <br>      <h3>::Add News</h3>       <form method="post" action="<?php echo $PHP_SELF ?>">       Title: <input name="title" size="40" maxlength="255">      <br>      Text1: <textarea name="text1"  rows="7" cols="30"></textarea>      <br>      Text2: <textarea name="text2" rows="7" cols="30"></textarea>      <br>      <input type="submit" name="submit" value="Add News">      </form>      <?  }//end of else include("../footer.php"); ?>

Link to comment
Share on other sites

If you do a view source on the non-working version you'll notice that your action is blank ( for the form ).

<?php echo $PHP_SELF ?>

The code above must be returning a blank string, on the non-working server.Try:

<?php echo $_SERVER['PHP_SELF'] ?>

Also, I would check the submit with something like:

if(isset($_POST['submit']))

Hope this helps you. :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...