huzefa Posted June 26, 2008 Share Posted June 26, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/111978-solved-help-needed-related-where-condition-in-select-statement/ Share on other sites More sharing options...
dannyb785 Posted June 26, 2008 Share Posted June 26, 2008 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'. ). Quote Link to comment https://forums.phpfreaks.com/topic/111978-solved-help-needed-related-where-condition-in-select-statement/#findComment-574769 Share on other sites More sharing options...
huzefa Posted June 27, 2008 Author Share Posted June 27, 2008 $surl = addslashes($_POST['surl']); $sql = "select * from wvideos where vmkey LIKE '%$surl%' "; Sorry but its not working, i have extra characters in $_POST['surl'] not in vmkey Quote Link to comment https://forums.phpfreaks.com/topic/111978-solved-help-needed-related-where-condition-in-select-statement/#findComment-575680 Share on other sites More sharing options...
dannyb785 Posted June 27, 2008 Share Posted June 27, 2008 $surl = addslashes($_POST['surl']); $sql = "select * from wvideos where vmkey LIKE '%$surl%' "; Sorry but its not working, i have extra characters in $_POST['surl'] not in vmkey Are you putting $sql into a query? Quote Link to comment https://forums.phpfreaks.com/topic/111978-solved-help-needed-related-where-condition-in-select-statement/#findComment-575716 Share on other sites More sharing options...
huzefa Posted June 27, 2008 Author Share Posted June 27, 2008 yah $result = mysql_query($sql) or die('Error connecting to database, Please try later'); if (mysql_num_rows($result) > 0){ // further processing here } Quote Link to comment https://forums.phpfreaks.com/topic/111978-solved-help-needed-related-where-condition-in-select-statement/#findComment-575730 Share on other sites More sharing options...
dannyb785 Posted June 27, 2008 Share Posted June 27, 2008 how about changing the die to "or die(mysql_error()); " that should tell you your error Quote Link to comment https://forums.phpfreaks.com/topic/111978-solved-help-needed-related-where-condition-in-select-statement/#findComment-575732 Share on other sites More sharing options...
huzefa Posted June 27, 2008 Author Share Posted June 27, 2008 i changed to "die(mysql_error());" but not show any error message Quote Link to comment https://forums.phpfreaks.com/topic/111978-solved-help-needed-related-where-condition-in-select-statement/#findComment-575738 Share on other sites More sharing options...
huzefa Posted June 27, 2008 Author Share Posted June 27, 2008 I have in column vmkey : cW3z70WMCTg & if user submit : than i want to show a message that video already added experts help is needed Thank you Huzefa Quote Link to comment https://forums.phpfreaks.com/topic/111978-solved-help-needed-related-where-condition-in-select-statement/#findComment-575745 Share on other sites More sharing options...
huzefa Posted June 27, 2008 Author Share Posted June 27, 2008 is any body have a solution of my problem? Quote Link to comment https://forums.phpfreaks.com/topic/111978-solved-help-needed-related-where-condition-in-select-statement/#findComment-576072 Share on other sites More sharing options...
dannyb785 Posted June 27, 2008 Share Posted June 27, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/111978-solved-help-needed-related-where-condition-in-select-statement/#findComment-576075 Share on other sites More sharing options...
huzefa Posted June 27, 2008 Author Share Posted June 27, 2008 $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 Quote Link to comment https://forums.phpfreaks.com/topic/111978-solved-help-needed-related-where-condition-in-select-statement/#findComment-576088 Share on other sites More sharing options...
dannyb785 Posted June 27, 2008 Share Posted June 27, 2008 ^ 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' ? Quote Link to comment https://forums.phpfreaks.com/topic/111978-solved-help-needed-related-where-condition-in-select-statement/#findComment-576150 Share on other sites More sharing options...
sasa Posted June 27, 2008 Share Posted June 27, 2008 try <?php $url = 'http://www.youtube.com/watch?v=cW3z70WMCTg'; $url = parse_url($url); parse_str($url['query'],$out); $url = addslashes($out['v']); $sql = "select * from wvideos where vmkey='$url' "; ?> Quote Link to comment https://forums.phpfreaks.com/topic/111978-solved-help-needed-related-where-condition-in-select-statement/#findComment-576205 Share on other sites More sharing options...
huzefa Posted June 28, 2008 Author Share Posted June 28, 2008 <?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 Quote Link to comment https://forums.phpfreaks.com/topic/111978-solved-help-needed-related-where-condition-in-select-statement/#findComment-576543 Share on other sites More sharing options...
sasa Posted June 28, 2008 Share Posted June 28, 2008 try <?php $url = 'http://www.youtube.com/watch?v=cW3z70WMCTg'; $sql = "select * from wvideos where locate(vmkey,'$url') "; ?> Quote Link to comment https://forums.phpfreaks.com/topic/111978-solved-help-needed-related-where-condition-in-select-statement/#findComment-576547 Share on other sites More sharing options...
huzefa Posted June 28, 2008 Author Share Posted June 28, 2008 Thank you sir, now my problem has been solved with it. Thanks once again Huzefa Quote Link to comment https://forums.phpfreaks.com/topic/111978-solved-help-needed-related-where-condition-in-select-statement/#findComment-576549 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.