Jump to content

um error i cant figure this out


BillyBoB

Recommended Posts

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

[code]
<?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
?>
[/code]

but heres the error

[code]
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
[/code]

Now this code is built on my programs page where if they click a program the url would be like
http://dreamshowstudios.net/programs.php?name=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 :)
Link to comment
https://forums.phpfreaks.com/topic/16084-um-error-i-cant-figure-this-out/
Share on other sites

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

into this:
[code]
$update = mysql_query("UPDATE programs SET count = '$count' WHERE id = " . $qarray['id']) or die(mysql_error());
[/code]
Change this:
[code]<meta http-equiv=\"Refresh\" content=\"0; URL=http://dreamshowstudios.net/programs/$name.exe \" />[/code]
to:
[code]<meta http-equiv=\"Refresh\" content=\"0; URL=http://dreamshowstudios.net/programs/{$name}.exe \" />[/code]
Its simple

[code]
<?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
?>
[/code]

[code]
<?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
?>
[/code]

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]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.