Boxerman Posted October 14, 2012 Share Posted October 14, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/269460-flag-error/ Share on other sites More sharing options...
jcbones Posted October 15, 2012 Share Posted October 15, 2012 (edited) 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 October 15, 2012 by jcbones Quote Link to comment https://forums.phpfreaks.com/topic/269460-flag-error/#findComment-1385213 Share on other sites More sharing options...
Boxerman Posted October 15, 2012 Author Share Posted October 15, 2012 Hi thanks for your reply. I have changed the $_GET if(isset($_GET['flag'])) This now redirects to watchtest.php?id=**?flag but does not execute the sql etc..? Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/269460-flag-error/#findComment-1385293 Share on other sites More sharing options...
TOA Posted October 15, 2012 Share Posted October 15, 2012 You are also appending it to an query string, but should be using an ampersand(&) instead of another question mark(?). Quote Link to comment https://forums.phpfreaks.com/topic/269460-flag-error/#findComment-1385297 Share on other sites More sharing options...
Boxerman Posted October 15, 2012 Author Share Posted October 15, 2012 I missed that out. Sorry! Thanks for the help both of you! this appeared to have worked! Many thanks to all. Quote Link to comment https://forums.phpfreaks.com/topic/269460-flag-error/#findComment-1385320 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.