Jump to content


Photo

um error i cant figure this out


  • Please log in to reply
6 replies to this topic

#1 BillyBoB

BillyBoB
  • Members
  • PipPipPip
  • Advanced Member
  • 630 posts

Posted 31 July 2006 - 08:37 AM

ok heres the part of code that's giving me an error

<?php
	if($_GET[name]) //line 119
	{
		$name = $_GET['name'];
		$query = mysql_query("SELECT * FROM programs WHERE programname = $name") or die(mysql_error());
		$qarray = mysql_fetch_array($query);
		$count = $qarray['count'];
		$count = $count + 1;
		$update = mysql_query("UPDATE programs SET count = '$count' WHERE id = $qarray['id']") or die(mysql_error()); //line 126
		echo("
			<meta http-equiv=\"Refresh\" content=\"0; URL=http://dreamshowstudios.net/programs/$name.exe \" />
		");
		exit();
	} //line 131
?>

but heres the error

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/dreamsh/public_html/programs.php on line 126

Now this code is built on my programs page where if they click a program the url would be like
http://dreamshowstud...ame=PROGRAMNAME

then i want it to add a number to the counter and send it to the database and then finally pop the download up :)

#2 king arthur

king arthur
  • Members
  • PipPipPip
  • Advanced Member
  • 335 posts
  • LocationUK HQ

Posted 31 July 2006 - 09:29 AM

Make this line
$update = mysql_query("UPDATE programs SET count = '$count' WHERE id = $qarray['id']") or die(mysql_error());

into this:
$update = mysql_query("UPDATE programs SET count = '$count' WHERE id = " . $qarray['id']) or die(mysql_error()); 

Sir Isaac Newton said "If I have seen farther, it is by standing on the shoulders of giants". But it is not recorded as to whether he said it before or after he was hit on the head by a falling apple.

#3 BillyBoB

BillyBoB
  • Members
  • PipPipPip
  • Advanced Member
  • 630 posts

Posted 31 July 2006 - 05:50 PM

um that didnt work so good either

#4 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 31 July 2006 - 05:53 PM

Change this:
<meta http-equiv=\"Refresh\" content=\"0; URL=http://dreamshowstudios.net/programs/$name.exe \" />
to:
<meta http-equiv=\"Refresh\" content=\"0; URL=http://dreamshowstudios.net/programs/{$name}.exe \" />


#5 BillyBoB

BillyBoB
  • Members
  • PipPipPip
  • Advanced Member
  • 630 posts

Posted 31 July 2006 - 05:55 PM

nope that part works good please read the first post

#6 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 31 July 2006 - 05:56 PM

$update = mysql_query("UPDATE programs SET count = '$count' WHERE id = '" . $qarray['id']. "'") or die(mysql_error());

Legend has it that reading the manual never killed anyone.
My site

#7 Chetan

Chetan
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts
  • LocationIndia

Posted 31 July 2006 - 06:01 PM

Its simple

<?php
	if($_GET[name]) //line 119
	{
		$name = $_GET['name'];
		$query = mysql_query("SELECT * FROM programs WHERE programname = $name") or die(mysql_error());
		$qarray = mysql_fetch_array($query);
		$count = $qarray['count'];
		$count = $count + 1;
		$update = mysql_query("UPDATE programs SET count = '$count' WHERE id = $qarray['id']") or die(mysql_error()); //line 126
		echo("
			<meta http-equiv=\"Refresh\" content=\"0; URL=http://dreamshowstudios.net/programs/$name.exe \" />
		");
		exit();
	} //line 131
?>

<?php
	if($_GET[name]) //line 119
	{
		$name = $_GET['name'];
		$query = mysql_query("SELECT * FROM programs WHERE programname = '$name'") or die(mysql_error());
		$qarray = mysql_fetch_array($query);
		$count = $qarray['count'];
		$count = $count + 1;
		$update = mysql_query("UPDATE programs SET count = '$count' WHERE id = '$qarray[id]'") or die(mysql_error()); //line 126
		echo("
			<meta http-equiv=\"Refresh\" content=\"0; URL=http://dreamshowstudios.net/programs/$name.exe \" />
		");
		exit();
	} //line 131
?>

you see you need to put '' around data for mysql and also you use $VAR['name'] when you dont include it in a string and have "" around it. In such case when you use "" around it becomes $VAR[name]
I am a PHP Guru, ask me questions if you want to




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users