View Single Post
Old 10-17-2008, 05:30 PM   #21 (permalink)
codefreek
Super Moderator
Inquisitive 
 
codefreek's Avatar
 
Join Date: Sep 2007
Location: Near you.
Posts: 791
Thanks: 241
codefreek is on a distinguished road
Bug

This is how i am doing it but i get

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\wamp\www\t\index.php on line 22

Warning: Invalid argument supplied for foreach() in C:\wamp\www\t\index.php on line 23

PHP Code:
<?php
error_reporting
(E_ALL E_NOTICE);
include 
"config.php";

if(isset(
$_POST['submit']))
{

    
$url=$_POST['url'];
    
    if(
strlen($url)<1
        {
        print 
"You did not enter a URL.";
    }
    else
{
    
$bringdb "SELECT * FROM upload";
            
            
$results mysql_fetch_array($bringdb);
            foreach(
$results as $result) {
            if(
$result == $url) {
            die (
'no!');
        }
    }
}
        if (
preg_match('~^http://(?:[a-z]{2,3}\.)?youtube\.com/watch\?v=.+$~i'$url))
        {
            
$sql="INSERT INTO `upload` (`link`) VALUES('$url')";
            
mysql_query($sql) or die(mysql_error());
            print 
"Link added!";
    }
        else
        {
            print 
"Link is invalid";    
    }
}


else
{
    print 
"<form action='index.php' method='post'>";
    print 
"URL(include http://):<br>";
    print 
"<input type='text' name='url' size='20'><br>";
    print 
"<input type='submit' name='submit' value='submit'></form>";
}  
?>
codefreek is offline  
Reply With Quote