Allow different spelling of names

Forum
Last Post
Threads / Messages

SilverDragonTears

I am your Nemesis.
Premium Member
Joined
Jun 1, 2011
Messages
1,113
Points
36
Mysidian Dollar
51,802
If someone has the name Holly for an adopt, how can I make it so that another person can use HoLLy, or some other variation of the same name?
 
Not that I can answer this...but are users currently unable to give their pet the same name of another existing pet..?
 
You can use strcmp() function to validate the name of an adoptable with another. This one is case sensitive, so Adopt and adopt are not the same.
 
I tried this but I don't think it's correct as it didn't work.

Code:
else{
                    $stmt = $adopts->query("SELECT * FROM ".constant('PREFIX')."owned_adoptables WHERE name='{$more}'");
                    $row = $stmt->fetchObject();
                    if(!is_object(strcmp($row))){ 
                       // The name has not yet been used, we are good to go!
 
Of course its not correct lol. You dont know how to use the strcmp() function dont ya? It accepts two arguments, not one. The arguments have to be strings, not objects. Try this:

PHP:
$name = $adopts->query("SELECT name FROM ".constant('PREFIX')."owned_adoptables WHERE name='{$more}'")->fetchColumn();
if(!strcmp($name, $more)){
    // The name has not be used...
}
else{
    // Show error message
}
 
Rawr, I'm not putting it in the right place :(

Code:
$name = $adopts->query("SELECT name FROM ".constant('PREFIX')."owned_adoptables WHERE name='{$more}'")->fetchColumn();
if(!strcmp($name, $more)){
                       // The name has not yet been used, we are good to go!
                        $adopts->query("UPDATE  ".constant('PREFIX')."owned_adoptables SET name='{$more}' WHERE aid='{$id}' and  owner='{$loggedinname}'");

It says it worked but it didn't change the name.
 
Last edited:
umm are you sure the query is executed correctly? I mean, do the variables $id and $more exist? If so, what values do they hold? Use var_dump($id) and var_dump($more) to validate their values. If one of them turns out to be blank or null, you know the problem.
 

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,274
Messages
33,115
Members
1,602
Latest member
BerrieMilk
BETA

Latest Threads

Latest Posts

Top