Jump to content

help with code


jimjim

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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();}

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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();

 

}

 

?>

Link to comment
Share on other sites

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();

 

}

 

?>

 

 

 

 

Link to comment
Share on other sites

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();

 

}

 

?>

Link to comment
Share on other sites

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')

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.