Go Back   Pictual Design Forums > Webmaster > Programming
Top Posters Referers Register Members List Calendar Search Today's Posts Mark Forums Read

Programming Post any problems that you have coding or post any topics about coding here.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 02-24-2006, 08:42 PM
tripnosis tripnosis is offline
Returning Member
 
Rep Power: 0
tripnosis is off the scale
Default

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/production

Non-working version: http://www.maxxiumtraxx.com/production
Also, here is some info on the servers:

Working version server:
PHP 4.4.1
MySQL 4.0.26
phpMyAdmin 2.6.4-pl2
Cpanel 10.8.1-STABLE 114

Non-working version server:
PHP 4.3.11
MySQL 4.1.13-standard
phpMyAdmin 2.6.4-pl2
Cpanel 10.8.1-STABLE 114

I am new to PHP, but maybe this could be a register globals issue?
and here's the source code for the add.php page:
Code:
<?php include("../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"); ?>
Reply With Quote
  #2  
Old 02-25-2006, 12:46 PM
ownsyou ownsyou is offline
Returning Member
Advanced Member (50+ posts)
 
Location: England
Rep Power: 0
ownsyou is an unknown quantity at this point
Send a message via MSN to ownsyou
Default

try
Code:
if($_POST['submit']) {
because if register_globals is OFF, u can't use abbreviated terms.
Reply With Quote
  #3  
Old 02-26-2006, 12:00 AM
tripnosis tripnosis is offline
Returning Member
 
Rep Power: 0
tripnosis is off the scale
Default

<div class='quotetop'>QUOTE(James @ Feb 25 2006, 10:46 AM)</div><div class='quotemain'>try
Code:
if($_POST['submit']) {
because if register_globals is OFF, u can't use abbreviated terms.
[snapback]4730[/snapback]
[/quote:059b164082]

NICE! Fixed it right ff, thanks bro!

But I am still having an issue with the files:

read_more.php
edit_news.php
delete_news.php

I belive the issue may be the same, but, as I said earlier, I am still new to php.

here is read_more.php
Code:
<?php include("../header.php"); include("submenu.php"); include("config.php"); ?> <div class="body"> <?PHP $result = mysql_query("SELECT * FROM news WHERE newsid='$newsid' ",$connect); while($myrow = mysql_fetch_assoc($result)) { echo "<b>"; echo $myrow['title']; echo "</b><br>On: <i>"; echo $myrow['dtime']; echo "</i><hr>"; echo $myrow['text1']; echo " "; echo $myrow['text2']; echo "<br><br><a href=\"javascript:self.history.back();\"><-- Go Back</a>"; } ?> </div> <?PHP include("../footer.php"); ?>

edit_news.php
Code:
<?php include("../header.php"); include("submenu.php"); include("config.php"); ?> <div class="body"> <?php if($_POST['submit']) { // Set global variables to easier names // and prevent sql injection and apostrophe to break the db. $title = mysql_real_escape_string($_POST['title']); $text1 = mysql_real_escape_string($_POST['text1']); $text2 = mysql_real_escape_string($_POST['text2']); $result = mysql_query("UPDATE news SET title='$title', text1='$text1', text2='$text2' WHERE newsid='$newsid' ",$connect); echo "<b>Thank you! News UPDATED Successfully!<br>You'll be redirected to Home Page after (4) Seconds"; echo "<meta http-equiv=Refresh content=4;url=index.php>"; } elseif($newsid) { $result = mysql_query("SELECT * FROM news WHERE newsid='$newsid' ",$connect); while($myrow = mysql_fetch_assoc($result)) { $title = $myrow["title"]; $text1 = $myrow["text1"]; $text2= $myrow["text2"]; ?> <br> <h3>::Edit News</h3> <form method="post" action="<?php echo $PHP_SELF ?>"> <input type="hidden" name="newsid" value="<? echo $myrow['newsid']?>"> Title: <input name="title" size="40" maxlength="255" value="<? echo $title; ?>"> <br> Text1: <textarea name="text1" rows="7" cols="30"><? echo $text1; ?></textarea> <br> Text2: <textarea name="text2" rows="7" cols="30"><? echo $text2; ?></textarea> <br> <input type="submit" name="submit" value="Update News"> </form> <? }//end of while loop }//end else ?> </div> <?PHP include("../footer.php"); ?>

delete_news.php
Code:
<?php include("../header.php"); include("submenu.php"); include("config.php"); ?> <div class="body"> <?php $result = mysql_query("DELETE FROM news WHERE newsid='$newsid' ",$connect); echo "<b>News Deleted!<br>You'll be redirected to Home Page after (4) Seconds"; //header("location: index.php"); echo "<meta http-equiv=Refresh content=4;url=index.php>"; ?> </div> <?PHP include("../footer.php"); ?>
Reply With Quote
  #4  
Old 03-03-2006, 11:46 AM
ownsyou ownsyou is offline
Returning Member
Advanced Member (50+ posts)
 
Location: England
Rep Power: 0
ownsyou is an unknown quantity at this point
Send a message via MSN to ownsyou
Default

try this:

read_more.php
Code:
<?php include("../header.php"); include("submenu.php"); include("config.php"); ?> <div class="body"> <?PHP $result = mysql_query("SELECT title,dtime,text1,text2 FROM news WHERE newsid='$newsid' ",$connect); while($myrow = mysql_fetch_assoc($result)) { echo "<b>"; echo $myrow['title']; echo "</b><br>On: <i>"; echo $myrow['dtime']; echo "</i><hr>"; echo $myrow['text1']; echo " "; echo $myrow['text2']; echo "<br><br><a href=\"javascript:self.history.back();\"><-- Go Back</a>"; } ?> </div> <?PHP include("../footer.php"); ?>



edit_news.php
Code:
<?php include("../header.php"); include("submenu.php"); include("config.php"); ?> <div class="body"> <?php if($_POST['submit']) { // Set global variables to easier names // and prevent sql injection and apostrophe to break the db. $title = mysql_real_escape_string($_POST['title']); $text1 = mysql_real_escape_string($_POST['text1']); $text2 = mysql_real_escape_string($_POST['text2']); $result = mysql_query("UPDATE news SET title='$title', text1='$text1', text2='$text2' WHERE newsid='$newsid' ",$connect); echo "<b>Thank you! News UPDATED Successfully!<br>You'll be redirected to Home Page after (4) Seconds"; echo "<meta http-equiv=Refresh content=4;url=index.php>"; } elseif(isset($_GET['newsid'])) { $newsid = $_GET['newsid']; $result = mysql_query("SELECT title,text1,text2 FROM news WHERE newsid='$newsid' ",$connect); while($myrow = mysql_fetch_assoc($result)) { $title = $myrow["title"]; $text1 = $myrow["text1"]; $text2= $myrow["text2"]; ?> <br> <h3>::Edit News</h3> <form method="post" action="<?php echo $PHP_SELF ?>"> <input type="hidden" name="newsid" value="<? echo $myrow['newsid']?>"> Title: <input name="title" size="40" maxlength="255" value="<? echo $title; ?>"> <br> Text1: <textarea name="text1" rows="7" cols="30"><? echo $text1; ?></textarea> <br> Text2: <textarea name="text2" rows="7" cols="30"><? echo $text2; ?></textarea> <br> <input type="submit" name="submit" value="Update News"> </form> <? }//end of while loop }//end else ?> </div> <?PHP include("../footer.php"); ?>



delete_news.php
Code:
<?php include("../header.php"); include("submenu.php"); include("config.php"); ?> <div class="body"> <?php $newsid = mysql_real_escape_string($_GET['newsid'])); // If this doesn't work, try $_POST['newsid'] instead of $_GET['newsid'] $result = mysql_query("DELETE FROM news WHERE newsid='$newsid' ",$connect); echo "<b>News Deleted!<br>You'll be redirected to Home Page after (4) Seconds"; //header("location: index.php"); echo "<meta http-equiv=Refresh content=4;url=index.php>"; ?> </div> <?PHP include("../footer.php"); ?>
Reply With Quote
Reply


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

Advanced Search
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

vB 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
News Management. xplicit Business 7 04-23-2010 06:05 AM
[Scripts] Fusion News 6.3.1 FireNova Downloads 0 06-14-2005 02:40 PM


All times are GMT -4. The time now is 01:00 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
vRewrite 1.5 beta SEOed URLs completed by Tech Help Forum and Chalo Na.