Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
  #1  
Old 08-15-2008, 11:35 AM
stryka stryka is offline
 
Join Date: Aug 2002
Posts: 201
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Conditionals on Serialized fields...

Has anyone had issues with conditionals on serialized fields

The condition works for one value... but not another... i tried deleting the record and resubmitting the value... and still no luck...

I don't think its an issue with spaces cuz the char count is always the same

i:7;s:8:"xxxxxxxx"

but there other values that work... and i even have the display on to print/show exactly what the variables are being compared to within the conditional.
Reply With Quote
  #2  
Old 08-15-2008, 05:04 PM
Guest190829
Guest
 
Posts: n/a
Default

What is your expression you are using? It is probably easier to do conditionals on un-serialized arrays rather than serialized strings.
Reply With Quote
  #3  
Old 08-15-2008, 07:51 PM
stryka stryka is offline
 
Join Date: Aug 2002
Posts: 201
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I actually do that...

I use the unserialize function on the customfield first and then i perform the following condition against the array value:

<if condition="$customfields[7]==$name">

However... the condition doesn't work all the time... If it works on one variable value... it doesn't for another...

eg) $name = Sam works but $name = Kevin doesn't work... even though there is a value for "Kevin" the customfield array and the value being passed is "Kevin"... i checked for spacing, different lengths...

I can PM anyone specific examples if interested in the exact context
Reply With Quote
  #4  
Old 08-16-2008, 11:43 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

How are you defining your comparison variables, are you sure they exist where you are using them?
Reply With Quote
  #5  
Old 08-16-2008, 11:46 AM
stryka stryka is offline
 
Join Date: Aug 2002
Posts: 201
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes... i have both the unserialized and comparison value being displayed... on the page as output as i debug... and they both look fine...

the comparison value is actually coming in as a request from another link and it looks like this

filename.php?show=1&name=Kevin

i don't think i have to trim the value cuz i am %99 certain that there are no trailing spaces in the records with the serialized value because i show both variables and i actually had both variables displayed with no space in between...

the other funny thing is that... if the serialized value is two words... it still works... the filter shows all the records that match the two words
Reply With Quote
  #6  
Old 08-16-2008, 12:13 PM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Forget about the serialized variables. Serializing is done to store an object (often an aray) as a single value. You do not perform operations on a serialized field.

You restore the original object (an array in your case) using unserialize() and perform your operations on the restored object.

To troubleshoot your problem please provide a var_dump of the (unserialized) array.
Reply With Quote
  #7  
Old 08-16-2008, 12:29 PM
stryka stryka is offline
 
Join Date: Aug 2002
Posts: 201
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

No offense Marco but I don't think you read the whole thread... I am using unserialize() and then performing the operation with the conditional statement... i mention serialized cuz maybe there is a problem when i use unserialize.

I also do a var_dump on $customfields[7] and it shows the value that want... again ... it works for one value and not the next...
Reply With Quote
  #8  
Old 08-16-2008, 07:25 PM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Run this PHP code:

PHP Code:
var_dump($customfields$name, ($customfields['7'] == $name)); 
And post the output here.
Reply With Quote
  #9  
Old 08-17-2008, 01:13 PM
stryka stryka is offline
 
Join Date: Aug 2002
Posts: 201
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ahh... that var_dump satement is a good debugger... i ended up being still more puzzled tho... not sure where else to check... cuz where both cases are true... only one case displays properly.... i skipped through a few values with "...."

array(11) { [1]=> string(1) "E" ......... [7]=> string(5) "Kevin" ..... [11]=> string(0) "" } string(5) "Kevin" bool(true)


array(11) { [1]=> string(1) "F" ..........[7]=> string(3) "Sam" ....... [11]=> string(0) "" } string(3) "Sam" bool(true)


Hmm... i will check my other templates see if i am losing something somewhere... unless you guys see something obvious

Quote:
Originally Posted by Opserty View Post
Run this PHP code:

PHP Code:
var_dump($customfields$name, ($customfields['7'] == $name)); 
And post the output here.
Reply With Quote
  #10  
Old 08-18-2008, 06:17 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Post your code, this might lead to a much faster solution.
Reply With Quote
Reply

Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:02 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04359 seconds
  • Memory Usage 2,246KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (9)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete