Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions

Reply
 
Thread Tools Display Modes
  #11  
Old 07-19-2005, 09:24 PM
Mr Blunt Mr Blunt is offline
 
Join Date: Jan 2004
Posts: 133
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ahhh, so the periods basically join your 3 "seperate strings" in the last example, one of which doesn't use double quotes since it's a var .... and those joining periods never get put into the actual saved string.

It's sinking in I think.

So if I declare an array key with $var['keyname'], and I come across a place where I'd rather call it with a simple $var[keyname], will it fly in most situations or must I do something stupid like $var[keyname] = $var['keyname'] beforehand? .... in which case it would probably be best to just use a new keyname to distinguish the difference?

I guess the reason I'm getting so technical is that I'm afraid of using non-arrayed variables as I don't want to conflict with anyone elses vars .... sooo one of my goals, as you might notice from my php file, was to try and handle all my vars from mainly one single array named "whodl" (3 really, but who's counting LOL).

Part of me says I'm going too far since it's a self contained webpage being displayed one time, and since control isn't going back to the origin page, I should be able to declare just about any simple (non-array) var that I want .... but then the inexperience in me thinks that's sloppy code so I've taken the long route so far.
Reply With Quote
  #12  
Old 07-20-2005, 04:38 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Mr Blunt
So if I declare an array key with $var['keyname'], and I come across a place where I'd rather call it with a simple $var[keyname], will it fly in most situations or must I do something stupid like $var[keyname] = $var['keyname'] beforehand? .... in which case it would probably be best to just use a new keyname to distinguish the difference?
You don't need to declare the version without the quotes. It will fail however if you have defined a constant with the same name as your keyname.

I even in a seperate script prefix most of my var's (since you are also including standard vB scripts, there could still be a name conflict even in a standalone script).
Reply With Quote
  #13  
Old 07-29-2005, 10:47 PM
Mr Blunt Mr Blunt is offline
 
Join Date: Jan 2004
Posts: 133
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Just a follow-up....

Thank you BIGTIME for the help here.
I finished a beta copy of my script.
I'll leave the old code here, but it shouldn't be used by anyone.
Maybe someone else will learn from comparing this vs. that.


https://vborg.vbsupport.ru/showthread.php?t=93167


I don't know if anyone is up for it, but I'd sure love to have someone double check my work. I feel pretty confident, but between a ton of rewrites and a wireless keyboard that sometimes skips a character LOL ... another set of eyes to check me would be awesome because I DO care about the people who install my products.

And if anyone does check it out .... I'm up for any suggestions, ideas, and or little coding tips if you feel like sharing them with me.
Reply With Quote
  #14  
Old 08-24-2005, 07:13 AM
Mr Blunt Mr Blunt is offline
 
Join Date: Jan 2004
Posts: 133
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Somewhat important follow-up.
The code examples above don't reflect UNSIGNED integer values.
vBulletin uses unsigned for these 4 INT values, so I should too.
PHP Code:
    $db->query("CREATE TABLE " TABLE_PREFIX "blunts_whodownloaded_ip (
        blunts_whodownloaded_ipid INT(10) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
        userid INT(10) UNSIGNED NOT NULL default 0,
        username VARCHAR(100) NOT NULL default '',
        filename VARCHAR(100) NOT NULL default '',
        fileid INT(10) UNSIGNED NOT NULL default 0,
        ipaddress VARCHAR(15) NOT NULL default '',
        alt_ip VARCHAR(15) NOT NULL default '',
        dateline INT(10) UNSIGNED NOT NULL default 0
    )"
); 
Here's a quote from dev.mysql.com
http://dev.mysql.com/doc/mysql/en/numeric-types.html
Quote:
All integer types can have an optional (non-standard) attribute UNSIGNED. Unsigned values can be used when you want to allow only non-negative numbers in a column and you need a bigger upper numeric range for the column.

As of MySQL 4.0.2, floating-point and fixed-point types also can be UNSIGNED. As with integer types, this attribute prevents negative values from being stored in the column. However, unlike the integer types, the upper range of column values remains the same.
And from the same thread:
Quote:
For example, the range of an INT column is -2147483648 to 2147483647. If you try to insert -9999999999 into an INT column, MySQL clips the value to the lower endpoint of the range and stores -2147483648 instead. Similarly, if you try to insert 9999999999, MySQL clips the value to the upper endpoint of the range and stores 2147483647 instead.

If the INT column is UNSIGNED, the size of the column's range is the same but its endpoints shift up to 0 and 4294967295. If you try to store -9999999999 and 9999999999, the values stored in the column are 0 and 4294967296.

When a floating-point or fixed-point column is assigned a value that exceeds the range implied by the specified (or default) precision and scale, MySQL stores the value representing the corresponding end point of that range.
In a nutshell .... Not only does unsigned not allow a negative number to be inserted, but an unsigned column allows for DOUBLE the amount of possible positive integer values than a signed column .... unless floating point numbers are involved.

Just trying to help the next guy....
Reply With Quote
  #15  
Old 08-24-2005, 11:59 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes that is the reason some fields are defined as unsigned.
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:56 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04318 seconds
  • Memory Usage 2,206KB
  • Queries Executed 11 (?)
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
  • (1)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (5)post_thanks_box
  • (5)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (5)post_thanks_postbit_info
  • (5)postbit
  • (5)postbit_onlinestatus
  • (5)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_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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete