jimjim Posted April 28, 2011 Share Posted April 28, 2011 hi, i have a problem with this code it should check the video table for channel name and types embedded and uploaded. if the channel name and types are confirmed it should redirect to cat_verify.php. it works in that it redirects embedded and uploaded but it completely ignors the channel. so no matter what channel the user chooses it redirects. any ideas? $sql = "SELECT FROM videos WHERE channel = 'comedy' AND video_type = 'embedded' OR video_type = 'uploaded' "; $query = @mysql_query($sql); { include_once ('cat_verify.php'); @mysql_close(); any help greatly appreciated Quote Link to comment https://forums.phpfreaks.com/topic/235034-help-with-code/ Share on other sites More sharing options...
Pikachu2000 Posted April 28, 2011 Share Posted April 28, 2011 When posting code, please enclose it within the forum's . . . BBCode tags. There is nothing in that code that performs a redirect. All that code does is run a DB query and unconditionally include cat_verify.php without regard to the result of the query. Quote Link to comment https://forums.phpfreaks.com/topic/235034-help-with-code/#findComment-1207887 Share on other sites More sharing options...
jimjim Posted April 28, 2011 Author Share Posted April 28, 2011 would this be more like what i need $sql = "SELECT * FROM videos WHERE channel = 'comedy' FROM video_type = 'uploaded' OR video_type = 'embedded'"; $query = @mysql_query($sql); $result = @mysql_fetch_array($query); $comedy = $result["comedy"]; if ($comedy == "") { @mysql_close(); header("Location: $base_url/cat_verify.php"); die();} Quote Link to comment https://forums.phpfreaks.com/topic/235034-help-with-code/#findComment-1207899 Share on other sites More sharing options...
fugix Posted April 28, 2011 Share Posted April 28, 2011 I'm not sure what the@ are for. And what happens when you run this code? Any errors? Quote Link to comment https://forums.phpfreaks.com/topic/235034-help-with-code/#findComment-1207907 Share on other sites More sharing options...
jimjim Posted April 28, 2011 Author Share Posted April 28, 2011 it ignors the channel aswell and all channels are directed to cat_verify.php Quote Link to comment https://forums.phpfreaks.com/topic/235034-help-with-code/#findComment-1207909 Share on other sites More sharing options...
Pikachu2000 Posted April 28, 2011 Share Posted April 28, 2011 With the error suppressing @ symbols in there, you really have no way to tell what's happening when that code runs. You have a syntax error in the query string; there are two FROMs. Get rid of the @ symbols, make sure error reporting is enabled, and see if there are any other errors reported. Quote Link to comment https://forums.phpfreaks.com/topic/235034-help-with-code/#findComment-1207924 Share on other sites More sharing options...
jimjim Posted April 29, 2011 Author Share Posted April 29, 2011 ok thanks Pikachu2000, the tags were always in the file im working with. this is what i have now same results all channels directed to cat_verify.php error reporting enabled no errors reported <?php $sql = "SELECT FROM videos WHERE channel = 'comedy' AND video_type = 'uploaded' OR video_type = 'embedded'"; $query = @mysql_query($sql); $result = @mysql_fetch_array($query); $comedy = $result["comedy"]; if ($comedy == "") { mysql_close(); header("Location: $base_url/cat_verify.php"); die(); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/235034-help-with-code/#findComment-1207953 Share on other sites More sharing options...
Pikachu2000 Posted April 29, 2011 Share Posted April 29, 2011 Remove the @ error suppressors. With very limited exception, they have no place in code unless they're part of an email address. Quote Link to comment https://forums.phpfreaks.com/topic/235034-help-with-code/#findComment-1207988 Share on other sites More sharing options...
jimjim Posted April 29, 2011 Author Share Posted April 29, 2011 Pikachu2000 i cant tell you how much i appreciate your help! this is what i have now...same result all channels still directed to cat_verify.php with no errors. <?php $sql = "SELECT FROM videos WHERE channel = 'Comedy' AND video_type = 'uploaded' OR video_type = 'embedded'"; $query = mysql_query($sql); $result = mysql_fetch_array($query); $Comedy = $result["Comedy"]; if ($Comedy == "") { mysql_close(); header("Location: $base_url/cat_verify.php"); die(); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/235034-help-with-code/#findComment-1208017 Share on other sites More sharing options...
Pikachu2000 Posted April 29, 2011 Share Posted April 29, 2011 Edit the query execution line to: $query = mysql_query($sql) or die( "<br>Query: $sql<br>Produced error: " . mysql_error() ); Quote Link to comment https://forums.phpfreaks.com/topic/235034-help-with-code/#findComment-1208018 Share on other sites More sharing options...
jimjim Posted April 29, 2011 Author Share Posted April 29, 2011 ok did that got a syntax error needed to add the * near FROM. after adding it no errors but same results all channels direct to cat_verify.php. got any ideas from here when i first started this project i used this <?php if (($channel) =="Comedy"){ include_once ('cat_verify.php); } ?> and it did work but only if the video was uploaded then got a redirect to cat_verify.php but no redirect for embedded videos in the same channel. thats why i tried to come up with a way to make it recognize channel as well as uploaded and embedded videos in that channel. this is the code that shows no errors after adding the * <?php $sql = "SELECT * FROM videos WHERE channel = 'Comedy' AND video_type = 'uploaded' OR video_type = 'embedded'"; $query = mysql_query($sql) or die( "<br>Query: $sql<br>Produced error: " . mysql_error() ); $result = @mysql_fetch_array($query); $comedy = $result["comedy"]; if ($comedy == "") { mysql_close(); header("Location: $base_url/cat_verify.php"); die(); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/235034-help-with-code/#findComment-1208089 Share on other sites More sharing options...
Pikachu2000 Posted April 29, 2011 Share Posted April 29, 2011 I can't say I'm certain I understand what you're trying to do, but from what I gather I think you've got an operator precedence issue in the query. Try changing the query string to this: SELECT * FROM videos WHERE channel = 'Comedy' AND (video_type = 'uploaded' OR video_type = 'embedded') Quote Link to comment https://forums.phpfreaks.com/topic/235034-help-with-code/#findComment-1208392 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.