...

View Full Version : mysql query not doing what I think it should be doing.



needsomehelp
12-31-2011, 03:26 PM
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.



<?
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 ?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum