TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 10-24-2007, 02:36 AM   #1 (permalink)
The Acquainted
Upcoming Programmer 
 
CMellor's Avatar
 
Join Date: Sep 2007
Location: Leeds, UK
Posts: 141
Thanks: 6
CMellor is on a distinguished road
Default MySQL's LIKE condition query

Hiya,

Am making a rating script and what I want is, when you have already voted in the particular rating bar, you cannot rate again, it just becomes static.

In the database where I store the votes, values and IP's of the rating, in the IP row, all the IP's are serialized.

Code:
a:1:{i:0;s:14:"81.102.225.228";}
I use this query to check if my IP is already stored in the database:

PHP Code:
<?php
// Query to check if the user has voted
$voted mysql_query(sprintf("SELECT ip FROM %s
    WHERE ip LIKE '%s'
      AND id = '%d'"
,
        
$table,
        
$ip.'%',
        
$id
)) or die(mysql_error());
?>
I then use this if statement to check the query:

PHP Code:
<?php
for($num 1$num <= $stars$num++) {
    
// If the user HASN'T voted
    
if(!$voted) {
        
$image .= '
        <li><a href="javascript:rate('
.$num.')" title="'.$num.' out of '.$stars.'" class="star'.$num.'">&nbsp;</a></li>
        '
;
    }
    else {
        
$image .= '<li>&nbsp;</li>';
    }
}
?>
Now when I haven't voted, I can click the rating bar, but when I have rated, I can still click it! I'm pretty sure it has something to do with the LIKE condition, and because the IP row is serialized. Can I search within the serialized code for just the IP? Or something like that...

Anyone have an idea's?

Thanks,
- Chris.
__________________
Not quite a n00b...
CMellor is offline  
Reply With Quote
 



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 03:33 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design