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
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]
Link to comment
Share on other sites

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]
Link to comment
Share on other sites

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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.