Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    Regular Coder
    Join Date
    Oct 2009
    Posts
    478
    Thanks
    7
    Thanked 3 Times in 3 Posts

    mysql query not doing what I think it should be doing.

    FOUND ANOTHER WAY. USED PHP SCRIPT TO CHECK INSTEAD.









    I want to add text to the start of each entry that does not already have the text.

    Here is the code I used, but for some reason it is showing every link even if the NOT LIKE is used.

    Code:
    <?
    include("includes/connect.php");
    
    $sql = "SELECT * FROM `links` WHERE `sourceURL` NOT LIKE '%http' AND `sourceURL` != '' ORDER BY `id` DESC";
    $fetchLinks = mysql_query($sql);
    
    if(mysql_num_rows($fetchLinks)) {
        while($result = mysql_fetch_assoc($fetchLinks)) {
    		$linkID = $result['id'];
    		$sourceURL = mysql_real_escape_string("http://".$result['sourceURL']);
    
    		$query = "UPDATE `links` SET `sourceURL` = '{$sourceURL}' WHERE `id` = {$linkID}";
    		echo($query."<br><br>");
    
    		//      mysql_query($query);
    		}
    }
    ?>
    I added the % to the query as I thought that this would search the start, or have I not got this right ?
    Last edited by needsomehelp; 12-31-2011 at 03:31 PM. Reason: FOUND ANOTHER WAY. USED PHP SCRIPT TO CHECK INSTEAD.


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •