Yii Framework Forum: Checkbox Localhost Vs. Server Problem - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Checkbox Localhost Vs. Server Problem Works fine locally, doesn't display on server Rate Topic: -----

#1 User is offline   NicolasVH 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 11-November 12

Posted 07 January 2013 - 09:00 AM

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: Attached File  yii_problem.PNG (10.85K)
Number of downloads: 6

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:

Attached File  empty_checkboxes.PNG (3.09K)
Number of downloads: 3

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 Attached File  gamesadmin_server.PNG (33.03K)
Number of downloads: 5

In localhost, again, it displays correctly: Attached File  gamesadmin_localhost.PNG (33.37K)
Number of downloads: 4

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!
0

#2 User is offline   Maurizio Domba 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,229
  • Joined: 12-October 09
  • Location:Croatia

Posted 07 January 2013 - 09:04 AM

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 ?
Find more about me.... btw. Do you know your WAN IP?
0

#3 User is offline   NicolasVH 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 11-November 12

Posted 07 January 2013 - 09:08 AM

View PostMaurizio Domba, on 07 January 2013 - 09:04 AM, said:

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:

Attached File  database.PNG (20.67K)
Number of downloads: 4
0

#4 User is offline   Maurizio Domba 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,229
  • Joined: 12-October 09
  • Location:Croatia

Posted 07 January 2013 - 09:21 AM

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'
Find more about me.... btw. Do you know your WAN IP?
0

#5 User is offline   NicolasVH 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 11-November 12

Posted 07 January 2013 - 09:30 AM

View PostMaurizio Domba, on 07 January 2013 - 09:21 AM, said:

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! :)
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users