Checkbox Localhost Vs. Server Problem

Hi everybody,

I’ve been developing in Yii for a couple of days now, and my website is looking good for a January 28th release. The beta is ready and can be visited here: tasta.be/tasta (it’s all sample data, we won’t be using GiantBombs videos, no worries! :) ).

That being said, I have a weird problem where it works perfectly on my localhost, but doesn’t work on my server. It’s regarding a check if a certain value is 0 or 1. In my database, I have defined the column as BIT(1).

When you visit tasta.be/tasta/index.php?r=games/view&id=2 for instance, underneath the description (which ends with "Reclaimer Trilogy") there should be a span, because in my view.php method, I do this:


             <?php if($model->playstation3 == '1')

                            echo '<span class="playstation3 label">PlayStation 3</span>'; ?>

                    

                    <?php if($model->xbox360 == '1')

                            echo '<span class="xbox label">Xbox 360</span>'; ?>

                    

                    <?php if($model->pc == '1')

                            echo '<span class="pc label">PC</span>'; ?>

This works fine locally, as I said. You can see here: 3675

yii_problem.PNG

I personally don’t think the problem lies in the span syntax, or the problem lies in the view file at all. The same problem happens in my videos view file, so it’s not a singular view file problem.

Why I think that? Because when I try to update a game (as admin), all the checkboxes are unticked (even though in the database it has the correct values). So even when in the database all platforms are set to 1, I see:

3678

empty_checkboxes.PNG

On localhost, the boxes are correctly ticked when theres a 1 value in the database. Also in the games management screen on the server, it seems like there are no values 3676

gamesadmin_server.PNG

In localhost, again, it displays correctly: 3677

gamesadmin_localhost.PNG

I have two extra things to add:

  • Code is 100% the same.

  • (Server) Even though checboxes ‘reset’ visually, when I update the game and check some boxes, the changes are correctly saved in the database.

I’m puzzled. I don’t know where to start looking. So any help whatsoever would be really great!

the code is the same… but the database is different…

I did not understand your last sentence… if you update a game on the server and set a checkbox and then save the record… is that shown as it should ?

The database is also the same. I exported the sql from my localhost to my server’s database.

When I update a game on the server and set a checkbox, this is saved succesfully to the server’s database, but no, it isn’t shown as it should. :(

Screen of server database:

3679

database.PNG

It’s difficult to say what is the problem… but the BIT field could have to do something with this… mysql / php versions are the same on localhost and server ?

Also try to


print_r($model->attributes)

to see the values of those checkbox fields… also try to compare with a numeric 1 instead of a string ‘1’

Yes, it seems the problem was due to a difference in database versions. I changed the BIT to tinyint(1) on my server, and now everything works.

Thanks for your tip! :)