HI all, hoping someone can help me

I created a scratch card game with a mix of PHP and Flash, with over 250 installs I have barely ever had a problem, and none that I couldnt solve, but now I have user who can't get it to run and it seems to be a PHP problem.

His install is here http://listhoster.net/scratch/
Here is a working copy http://www.w8lossreviews.com/scratchcardpro/index.php

an example issue is the images that should show on the prize page they look like this
http://listhoster.net/scratch/images/prize_th_%3C?=$prize[%27id%27];%20?%3E.jpg

It should look like this http://www.w8lossreviews.com/scratchcardpro/images/prize_th_4.jpg

Any idea whats gone wrong? My user has even reinstalled PHP

Thanks in Advance

Recommended Answers

All 4 Replies

http://listhoster.net/scratch/images/prize_th_%3C?=$prize[%27id%27];%20?%3E.jpg

It appears you have incorrectly connected an array to a string. Without the code that echos that line I can only guess but I would say that line would look something like the following:

<?php echo 'http://listhoster.net/scratch/images/prize_th_'.$prize['id'].'.jpg'; ?>

And the above will return something like the below:

http://listhoster.net/scratch/images/prize_th_variable.jpg

It appears you have incorrectly connected an array to a string. Without the code that echos that line I can only guess but I would say that line would look something like the following:

<?php echo 'http://listhoster.net/scratch/images/prize_th_'.$prize['id'].'.jpg'; ?>

And the above will return something like the below:

http://listhoster.net/scratch/images/prize_th_variable.jpg

Here is my template code that is called in on that php page, based on that any ideas how I can fix it?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Available Prizes</title>
<link rel="StyleSheet" href="styles.css" type="text/css">
</head>
<body>
<h1>Available Prizes</h1>
<table cellpadding="0" cellspacing="0" class="table">
	<tr class="tablehead">
	<td>SN</td>
	<td>Title</td>
	<td>Description</td>
	<td>Image</td>
	<td>Quantity</td>
	</tr>
   <?php 
   $count=0;
   foreach ($prizes as $prize) 
   {
   $class=(!($count%2))?'class="even"':'';
    ?>
	<tr align="center" <?=$class?>>
		<td><?=$count+1; ?></td>
		<td><?=$prize['title']; ?></td>
		<td><?=nl2br($prize['description']); ?></td>
		<td><img src="images/prize_th_<?=$prize['id']; ?>.jpg"/></td>
		<td><?=$prize['quantity']; ?></td>
    </tr>
    <?php $count++; 
	}
	 ?>
</table>

The corrected code is as follows however you will need to add an array called $prizes near the beginning.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Available Prizes</title>
<link rel="StyleSheet" href="styles.css" type="text/css">
</head>
<body>
<h1>Available Prizes</h1>
<table cellpadding="0" cellspacing="0" class="table">
	<tr class="tablehead">
	<td>SN</td>
	<td>Title</td>
	<td>Description</td>
	<td>Image</td>
	<td>Quantity</td>
	</tr>
    <?php 
    $count=0;
    foreach ($prizes as $prize) 
    {
    $class=(!($count%2))?'class="even"':'';
    $do=$count+1;
    echo '<tr align="center" '.$class.'>
        <td>'.$do.'</td>
        <td>'.$prize['title'].'</td>
        <td>'.nl2br($prize['description']).'</td>
        <td><img src="images/prize_th_'.$prize['id'].'.jpg"/></td>
        <td>'.$prize['quantity'].'</td>
    </tr>';
    unset($do);
    $count++; 
	}
	 ?>
</table>

Can anyone tell me why this script has worked on hundreds of sites and now on this one doesnt? I have several pages like the code attached Im hoping the user can change something on their server to make this work.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.