Jump to content

[SOLVED] Help needed related where condition in select statement


Recommended Posts

i have a column vmkey in table wvideos, in that column i have master key of all videos like 'cW3z70WMCTg' for the youtube video of

 

Now i want to get the url from users favourite video & want to check in my database if that already exist in database or not

 

i m checking it by following condition

 

$sql = "select * from wvideos where '".$_POST['surl']."' LIKE vmkey";

 

but its not work, urgent help is needed

 

thank you

 

Huzefa

change

$sql = "select * from wvideos where '".$_POST['surl']."' LIKE vmkey";

 

to

 

$surl = addslashes($_POST['surl']);
$sql = "select * from wvideos where vmkey LIKE '%$surl%' ";

 

That should do it(provided the column name with the vmkeys's name is 'vmkey'. ).

yah

 

$result = mysql_query($sql) or die('Error connecting to database, Please try later');

if (mysql_num_rows($result) > 0){

// further processing here

}

 

 

 

 

What's the "further processing" ?

 

And I didnt realize you needed to search for an exact entry. Don't to the LIKE. Change it to:

$surl = addslashes($_POST['surl']);
$sql = "select * from wvideos where vmkey='$surl' ";

 

If this doesn't work, then either your form is not putting the variable into $_POST['surl'] or there is some issue with your database and the values in it or the way it's setup

$surl = addslashes($_POST['surl']);

$sql = "select * from wvideos where vmkey='$surl' ";

 

how its possible?

 

value in  $surl  is

& in vmkey column is cW3z70WMCTg

 

so how its locate as true

 

i also checked the variable & all others

 

 

 

 

 

^ omfg.

 

 

 

THIS is why I wish people would be more specific

 

Christ. I swear, I love helping people for free... but this is ridiculous.

 

 

Think about it... You're trying to find xxx value in http://www.youtube.com/xxx(or whatever) so would it make sense to search for 'xxx' in 'http://www.youtube.com/xxx' or search for 'http://www.youtube.com/xxx' in 'xxx' ? Because you're looking for 'http://www.youtube.com/xxx' in 'xxx' which obviously would never happen. Had you told us(or me) to begin with that $surl would have the entire url, it would've taken 2 seconds to say "just remove the part in front of the code you're looking for.

 

Once again. If you have a row in the database that says "bob" and then a variable b that says "bobby". Would it make sense to search for 'bobby' in the database to try and find 'bob' ?

<?php

$url = '

$url = parse_url($url);

parse_str($url['query'],$out);

$url = addslashes($out['v']);

$sql = "select * from wvideos where vmkey='$url' ";

?>

 

Thanks sasa

 

Its working properly for youtube video, but what about google video, there is 'docid' variable & a lot of more video provider also on the net.

 

so is it not possible to check database value in the variable in where condition?

 

Thanks

 

Huzefa

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.