Jump to content

Recommended Posts

Hi guys..

 

I've got a problem im trying to issue where when a user clicks Broken it does not work..

 

here is the php for it:

 

<h2 class="title2">Recently Added</h2>
<p>
<?PHP
$con = mysql_connect("localhost","*******","*********");
if (!$con)
 {
 die('Could not connect: ' . mysql_error());
 }

mysql_select_db("movies", $con);
/*  function to return the first N words of a string */
function shorten_string($string, $wordsreturned) {
$retval = $string;
$array = explode(" ", $string);
if (count($array)<=$wordsreturned) {
$retval = $string;
}else{
array_splice($array, $wordsreturned);
$retval = implode(" ", $array)." ...";
}
return $retval;
}
/* check to see if an article has been selected */
if(!$_GET['id']) {
$id = 0;
}else{
$id = (int) $_GET['id'];
}
/* set the number of words for the brief */
$N = 15;
/* if id is set display the news */
if($id>0) {
$query = "SELECT * FROM movies WHERE id='$id' ORDER BY id DESC";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
$title = $row['title'];
$timestamp = $row["added"];
$format='F j, Y, g:i a';
$formatedTime = date($format, strtotime($timestamp));
?><p>
<b><font size="5"><?PHP echo $title; ?></font> </b><br />
Story: <?PHP echo $row['desc'] ?></p><br>
<?php
$iphone = strpos($_SERVER['HTTP_USER_AGENT'],"iPhone");
$android = strpos($_SERVER['HTTP_USER_AGENT'],"Android");
$palmpre = strpos($_SERVER['HTTP_USER_AGENT'],"webOS");
$berry = strpos($_SERVER['HTTP_USER_AGENT'],"BlackBerry");
$ipod = strpos($_SERVER['HTTP_USER_AGENT'],"iPod");
if ($iphone || $ipod == true)
{
echo "<iframe width='200' height='150' src='movies/".$row['filename']."' frameborder='0' allowfullscreen></iframe><br>";
}
ELSE {
echo "<video id='video' autobuffer height='240' width='360' controls='controls' autoplay='autoplay'><source src='movies/".$row['filename']."'></video>";
}
?>
Posted At: <?php echo $formatedTime ?>
<br><br>
<?php
if(isset($_POST['flag']))
{
$con = mysql_connect("localhost","*******","*********");
if (!$con)
 {
 die('Could not connect: ' . mysql_error());
 }
mysql_select_db("movies", $con);
$id = (int) $_GET['id'];
$sql = "UPDATE movies SET flag = 1 WHERE id = $id";
if (!mysql_query($sql,$con))
 {
 die('Error: ' . mysql_error());
 }
echo "<font color='green'>Thanks for reporting!</font><br><br>";
mysql_close($con);
}
?>
<a href="watchtest.php?id=<? echo $id ?>?flag"><img src="img/flag_red.png" />Broken</a>
<BR><BR><BR>
<?PHP
}else{
echo "nothing here";
}
?>

 

Im aware of the badness of the coding, i will rewrite soon.. but hope the code helps you on the FLAG section

Link to comment
https://forums.phpfreaks.com/topic/269460-flag-error/
Share on other sites

The only thing I see wrong, is your are sending the index "flag" in the $_GET array, but checking for it in the $_POST array. You are also appending it to an query string, but should be using an ampersand(&) instead of another question mark(?).

Edited by jcbones
Link to comment
https://forums.phpfreaks.com/topic/269460-flag-error/#findComment-1385213
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.