LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-04-2008, 06:34 PM   #1
bad_gui
LQ Newbie
 
Registered: Mar 2003
Distribution: vector, Debian
Posts: 17

Rep: Reputation: 0
php4 to php5.2 breaks old code?


I am new to php and html.

I have been modifying an open source php project but I recently
upgraded my distro and it has php 5.2 instead of 4.1.

Now the code is broken but none of my php books or web guides
explains what is wrong with this code:

Code:
<?
session_start();

include 'data.php';

$reload_to_install = str_replace("index", "install", $_SERVER['PHP_SELF']);
if (!isset($database_host)) header("Location: http://$_SERVER[HTTP_HOST]$reload_to_install");

if (!isset($_GET["from"])) {
$from = '0';
} else {
$from = $_GET["from"];
}

if (!empty($_SESSION["user"])) $username = explode ('@', strtoupper($_SESSION["user"]));

/////////////start define functions//////////////////////

function show_results($result,$select,$from,$show) {

include 'data.php';
$i = $from;

    $link = mysql_connect($database_host, $database_user, $database_password);
    mysql_select_db ($database_name);

echo '<TABLE BORDER="0" CELLPADDING="5" CELLSPACING="5" WIDTH="100%">';

while ($paper = mysql_fetch_array($result)){
$i = $i + 1;

echo "
 <TR>
  <TD>
  $i. <U>$paper[authors]</U><BR>
  <B>$paper[title]</B><BR>
  <I>$paper[journal] $paper[date1]</I><BR>";
What I see on the browser is:

Quote:
; while ($paper = mysql_fetch_array($result)){ $i = $i + 1; echo " $i. $paper[authors]
$paper[title]
$paper[journal] $paper[date1]
"; if ($show == 'abstract') { print "Brief"; } else { print "Abstract"; } if (isset($_SESSION["auth"])) { echo " | Full text | Edit"; } if (date('Y-m-d') == $paper['date2']) { $today = 'Today!'; } else { $today =''; } echo "
Category: ".str_replace("|", ", ", $paper[category])." "; if ($show == 'abstract') echo "
Is this a problem with the echo syntax or is html no longer passed via echo? Is there a way to get php5.2 to give php4.2 behavior?
Can someone suggest where I should look to fix this code?
 
Old 03-04-2008, 07:34 PM   #2
BrianK
Senior Member
 
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Rep: Reputation: 51
Quote:
Originally Posted by bad_gui View Post
I am new to php and html.
....

What I see on the browser is:


Is this a problem with the echo syntax or is html no longer passed via echo? Is there a way to get php5.2 to give php4.2 behavior?
Can someone suggest where I should look to fix this code?
Looks to me like a single quote is either missing or being introduced through a variable, otherwise, you would see no '$'s in the output. If I were a betting man, I'd say that some variable is coming in like "Paul's thingy" & the single quote isn't being escaped properly.... because of that, it's terminating the echo before the actual end of the echo. What happens if you view the source of the html page? What does it look like (as it will have more and better info that what's actually seen in the browser)?

maybe magic_quotes_gpc is set differently in php5's ini file vs php4's ini file?

Last edited by BrianK; 03-04-2008 at 07:37 PM.
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
switch between php4 and php5 cooljai Linux - Software 1 06-11-2007 07:15 AM
having problem in porting php4 code to php5 in sessions mohtasham1983 Programming 3 04-10-2007 02:56 AM
PHP5 to PHP4 on FC4? kz26 Fedora 5 10-24-2005 05:09 AM
Php5 >> Php4 Eric45008 Slackware 22 04-25-2005 07:37 PM
upgradeing from php4 to php5 mgarcia001 Debian 0 09-30-2004 07:31 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:35 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration