What is wrong with this ?

Status
Not open for further replies.

Hazem

New member
PHP:
echo '<table width="150"><tr><td><div id="download"><a href="download_program.php">Download '.$page_title'  </a></div></td></tr></table>';

I get

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/***/public_html/view_program.php on line 1
 

Hazem

New member
PHP:
echo '<table width="150"><tr><td><div id="download"><a href="download_program.php">Download .$page_title  </a></div></td></tr></table>';

PHP:
echo '<table width="150"><tr><td><div id="download"><a href="download_program.php">Download {.$page_title}  </a></div></td></tr></table>';

PHP:
echo "<table width="150"><tr><td><div id="download"><a href="download_program.php">Download '$page_title'  </a></div></td></tr></table>";

not working
 

Hazem

New member
all I need to do is to make the command echo return Download (page title)

so it will show like

Download Firefox

Download Google Chrome

Download AVG
 

jaran

New member
Your problem is coming from view_program.php on line 1. It look missing Your download_program.php was called view_program.php over include function. Also try this code to declare the echo.
PHP:
echo '<table width="150"><tr><td><div id="download"><a href="download_program.php">Download '.$page_title.'  </a></div></td></tr></table>';
Please check at $page_title rows. You are missing some command.
 

Peter

New member
Yeah I think the problem is that you are missing a dot after the variable name.

If you use double quotes you can put the variables directly inside the string but then you'll have to escape the double quote characters in the string.

PHP:
echo "<table width=\"150\">
<tr><td><div id=\"download\"><a href=\"download_program.php\">Download $page_title</a></div></td></tr></table>";
 

Hazem

New member
This is the url downup4soft [.] com

Here is the view_program.php code

PHP:
<?php

include("config_mysite.php");

connect();



$id=strip_tags(mysql_real_escape_string($_GET['id']));

$select=mysql_query("select * from `programs` where `id`='$id'");

$row=mysql_fetch_array($select);

$page_title=$row['title'];

$current='view_program';

?>

<?php include('html/header.php');?>



<?php

echo '

<table width="100%">

<tr><td valign="top" style="color: #000; border-right: 1px solid #f0f0f0;border-left: 1px solid #f0f0f0; background: #f9f9f9;padding: 5px; width: 150px;">

'.nl2br($row['data']).'

</td><td valign="top">

<div id="view_program"><h1>'.$row['title'].'</h1>

<p>

<img src="'.$row['image'].'"/>

';

echo nl2br($row['description']);

?>

<br/><br/>



<br/>

<br/>

<?php

if($row['file'])

echo '<table width="150"><tr><td><div id="download"><a href="'.$row['file'].'">Download</a></div></td></tr></table>';

else

echo '<table width="150"><tr><td><div id="download"><a href="'.$row['url'].'" rel="nofollow">Download</a></div></td></tr></table>';







echo '

</td></tr></table>

';

?>

<div style="width: 95px; float: left;"><g:plusone href="<?php echo 'http://'.$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];?>" size="medium"></g:plusone></div>

<div style="width: 65px; float: left;"><a href="http://twitter.com/share" class="twitter-share-button" data-count="none">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div>

<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>

<fb:like href="<?php echo 'http://'.$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];?>" send="true" layout="button_count" width="30" show_faces="false" font="" style="float: left;"></fb:like>

<script src="https://apis.google.com/js/plusone.js" type="text/javascript"></script>



<br/>

<h3>See more</h3>

<ul>

<?php

$select=mysql_query("select `title`,`id` from `programs` order by rand() limit 10");

while($row=mysql_fetch_array($select))

{

echo '<li><a href="view_program.php?id='.$row['id'].'">'.$row['title'].'</a></li>';

}

?>

</ul>

<?php include('html/footer.php');?>

As you can see the link in Download is directly download the requested file ( this green button )

I want to modify this so when click another page ( download_program.php ) - with the same content - load and visitor can download from that page ( download_program.php )

and I want to modify this Download to be Download "file name here"


HELP
I hate php
 

jaran

New member
Try this one.
PHP:
echo '<table width="150"><tr><td><div id="download"><a href="download_program.php?id='.$_GET['id'].'">Download '.$page_title.'  </a></div></td></tr></table>';
You should filling value of variable $_GET['id'] correctly to solve the problem.
 

Hazem

New member
PHP:
<?php

include("config_mysite.php");

connect();



$id=strip_tags(mysql_real_escape_string($_GET['id']));

$select=mysql_query("select * from `programs` where `id`='$id'");

$row=mysql_fetch_array($select);

$page_title=$row['title'];

$current='view_program';

?>

<?php include('html/header.php');?>



<?php

echo '

<table width="100%">

<tr><td valign="top" style="color: #000; border-right: 1px solid #f0f0f0;border-left: 1px solid #f0f0f0; background: #f9f9f9;padding: 5px; width: 150px;">

'.nl2br($row['data']).'

</td><td valign="top">

<div id="view_program"><h1>'.$row['title'].'</h1>

<p>

<img src="'.$row['image'].'"/>

';

echo nl2br($row['description']);

?>

<br/><br/>



<br/>

<br/>

<?php


echo '<table width="150"><tr><td><div id="download"><a href="download_program.php?id='.$_GET['id'].'">Download '.$page_title.'  </a></div></td></tr></table>'; 


?>



<div style="width: 95px; float: left;"><g:plusone href="<?php echo 'http://'.$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];?>" size="medium"></g:plusone></div>

<div style="width: 65px; float: left;"><a href="http://twitter.com/share" class="twitter-share-button" data-count="none">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div>

<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>

<fb:like href="<?php echo 'http://'.$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];?>" send="true" layout="button_count" width="30" show_faces="false" font="" style="float: left;"></fb:like>

<script src="https://apis.google.com/js/plusone.js" type="text/javascript"></script>



<br/>

<h3>See more</h3>

<ul>

<?php

$select=mysql_query("select `title`,`id` from `programs` order by rand() limit 10");

while($row=mysql_fetch_array($select))

{

echo '<li><a href="view_program.php?id='.$row['id'].'">'.$row['title'].'</a></li>';

}

?>

</ul>

<?php include('html/footer.php');?>


@jaran same error

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/downup4s/public_html/view_program.php on line 1


Any other suggestions ?

:(
 

Hazem

New member
index page code

PHP:
<?php
include("config_mysite.php");
connect();

$limit=20;
$page=$_GET['p'];
if($page==null) $page=1;
$offset=(abs(intval($page))-1)*$limit;
?>
<?php include('html/header.php');?>

<?php
$select=mysql_query("select * from `programs` order by `id` desc limit $limit offset $offset");
while($row=mysql_fetch_array($select))
{
echo '
<div id="program">

<h2><a href="view_program.php?id='.$row['id'].'">'.$row['title'].'</a></h2>
<a href="view_program.php?id='.$row['id'].'">';
if($row['image'])
echo '<img src="'.$row['image'].'"/>';
else
echo '<img src="images/noImageAvailable.gif"/>';
echo '</a>
'.truncate_str(strip_tags($row['description']),350).' <a href="view_program.php?id='.$row['id'].'" class="more">[ More ]</a>

</div>
';

}
?>

<?php
$select=mysql_query("select count(`id`) as cnt from `programs`");
$row=mysql_fetch_array($select);
$count=$row['cnt'];

if($count==0 || $count<=$limit)
	{}else{
	echo '<br/><br/><table width="95%" align="center"><tr><td id="paging">';
	$pg=0;
	while($count>0)
	{
	$count=$count-$limit;
	$pg=$pg+1;
	}
	$i2=0;
	$page=$_GET['p'];
	if($page==null)
	$page=1;
	$last=$pg;
	$first=1;
	for($x=0;$x<4;$x++){
	if($i2==0)
	{if($page>1) echo '<a href="?p='.$first.'">First</a><a href="?p='.($page-1).'">Prev</a>'; echo "<span>".$page."</span>";}
	else if(($page+$i2)<=$last)
	{ echo '<a href="?p='.($page+$i2).'">'.($page+$i2).'</a>';}
	
	$i2=$i2+1;
	}
	if($page!=$last) echo '<a href="?p='.($page+1).'">Next</a><a href="?p='.$last.'">Last</a>';
	echo '</td></tr></table>';
	}

?>

<?php include('html/footer.php');?>
 

Peter

New member
I think it's strange that it complains about line 1. Are you sure this is the correct code?
 

jaran

New member
Add this code at the top php if you not want to show the error.
PHP:
ini_set('display_errors','OFF');
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);
//your script.....
 
Status
Not open for further replies.