vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   not updating correctly, completely wrong number (https://vborg.vbsupport.ru/showthread.php?t=72628)

AN-net 12-08-2004 02:11 AM

not updating correctly, completely wrong number
 
well im submitting the number 7327060765 but when it passes through php and is finally placed in the database it is: 2147483647. and that is the same number in the database for any combination of numbers i use>_< can someone explain y its doing this?

my code is:
PHP Code:

    if($cellnum != $bbuserinfo['cellnum'])
    {
        if(
strlen($cellnum) <> 10 OR strlen($cellnumconfirm) <>10)
        {
            eval(
print_standard_error('error_badcellnum'));
        }
        if(
$cellnum != $cellnumconfirm)
        {
            eval(
print_standard_error('error_cellnummismatch'));
        }
        if(
$usedcellnum $DB_site->query_first("SELECT cellnum FROM ".TABLE_PREFIX."user WHERE userid!=".intval($bbuserinfo['userid'])." AND cellnum=".intval($cellnum).""))
        {
            eval(
print_standard_error('error_cellnumtaken'));
        }
        
$newcellnum 'cellnum = "' intval($cellnum) . '" ,' ;
    }
    else
    {
        
$newcellnum '';
    } 

i have it set it globalize() that $cellnum and $cellnumconfirm are intergers

Zachery 12-08-2004 02:34 AM

Quote:

Originally Posted by AN-net
well im submitting the number 7327060765 but when it passes through php and is finally placed in the database it is: 2147483647. and that is the same number in the database for any combination of numbers i use>_< can someone explain y its doing this?

my code is:
PHP Code:

    if($cellnum != $bbuserinfo['cellnum'])
    {
        if(
strlen($cellnum) <> 10 OR strlen($cellnumconfirm) <>10)
        {
            eval(
print_standard_error('error_badcellnum'));
        }
        if(
$cellnum != $cellnumconfirm)
        {
            eval(
print_standard_error('error_cellnummismatch'));
        }
        if(
$usedcellnum $DB_site->query_first("SELECT cellnum FROM ".TABLE_PREFIX."user WHERE userid!=".intval($bbuserinfo['userid'])." AND cellnum=".intval($cellnum).""))
        {
            eval(
print_standard_error('error_cellnumtaken'));
        }
        
$newcellnum 'cellnum = "' intval($cellnum) . '" ,' ;
    }
    else
    {
        
$newcellnum '';
    } 

i have it set it globalize() that $cellnum and $cellnumconfirm are intergers

Whats the size of the field? :)

AN-net 12-08-2004 10:00 AM

field is 11 intergers;)

amykhar 12-08-2004 10:55 AM

Quote:

Originally Posted by AN-net
well im submitting the number 7327060765 but when it passes through php and is finally placed in the database it is: 2147483647. and that is the same number in the database for any combination of numbers i use>_< can someone explain y its doing this?

my code is:
PHP Code:

    if($cellnum != $bbuserinfo['cellnum'])
    {
        if(
strlen($cellnum) <> 10 OR strlen($cellnumconfirm) <>10)
        {
            eval(
print_standard_error('error_badcellnum'));
        }
        if(
$cellnum != $cellnumconfirm)
        {
            eval(
print_standard_error('error_cellnummismatch'));
        }
        if(
$usedcellnum $DB_site->query_first("SELECT cellnum FROM ".TABLE_PREFIX."user WHERE userid!=".intval($bbuserinfo['userid'])." AND cellnum=".intval($cellnum).""))
        {
            eval(
print_standard_error('error_cellnumtaken'));
        }
        
$newcellnum 'cellnum = "' intval($cellnum) . '" ,' ;
    }
    else
    {
        
$newcellnum '';
    } 

i have it set it globalize() that $cellnum and $cellnumconfirm are intergers

Just for giggles, I have to wonder if the strlen is messing you up. Try doing a numerical comparison instead.

Amy

AN-net 12-08-2004 04:56 PM

how would i do that? cause i want to make sure the sure its 10 numbers long:)

amykhar 12-08-2004 05:22 PM

Quote:

Originally Posted by AN-net
how would i do that? cause i want to make sure the sure its 10 numbers long:)

easy. YOu make sure it's greater than 1000000000 and less than 10000000000 ;)

Unless it can start with 0 and then you should probably make it a string and not an integer.

Amy

AN-net 12-09-2004 12:01 AM

im going to assume area codes dont start with 0...?

Reeve of shinra 12-09-2004 01:44 AM

area codes can start with zero if your dialing internationally.

011+xxxxxxxxxx whatevfer

AN-net 12-09-2004 01:58 AM

ok i guess i can it that way since currently my script only works within the US:) and requires no international dialing:D

AN-net 12-09-2004 02:18 AM

its still putting the same exact number in!

AN-net 12-10-2004 08:15 AM

bump!

AN-net 12-10-2004 06:22 PM

is it possible that its getting put in wrong due to the cell phone fields being on the same page as edit password and edit email? because that is where its located

AN-net 12-11-2004 10:54 AM

bump it like its hot, bump it like its hot!

sabret00the 12-11-2004 01:48 PM

what is your query to insert the data into the database?

AN-net 12-11-2004 11:06 PM

the query is:
PHP Code:

$DB_site->query("UPDATE " TABLE_PREFIX "user SET $newpassword $newemail $newcellnum usergroupid = " intval($bbuserinfo['usergroupid']) . " WHERE userid = $bbuserinfo[userid]"); 


amykhar 12-11-2004 11:19 PM

If it's always the same number going in, make sure your form is set up correctly and that it's not passing a constant value somehow.

It's really difficult to help people debug when you don't have access to the actual running code.

AN-net 12-13-2004 10:18 PM

here is the template:
HTML Code:

<script type="text/javascript" src="clientscript/vbulletin_md5.js"></script>
<script type="text/javascript">
function hash_passwords(currentpassword, currentpassword_md5, newpassword, newpassword_md5, newpasswordconfirm, newpasswordconfirm_md5)
{
        md5hash(currentpassword, currentpassword_md5);
        // do various checks
        if (newpassword.value != '')
        {
                md5hash(newpassword, newpassword_md5);
        }
        if (newpasswordconfirm.value != '')
        {
                md5hash(newpasswordconfirm, newpasswordconfirm_md5);
        }
}
</script>

<form action="profile.php" method="post" onsubmit="hash_passwords(currentpassword, currentpassword_md5, newpassword, newpassword_md5, newpasswordconfirm, newpasswordconfirm_md5)">
<input type="hidden" name="s" value="$session[sessionhash]" />
<input type="hidden" name="do" value="updatepassword" />
<input type="hidden" name="currentpassword_md5" />
<input type="hidden" name="newpassword_md5" />
<input type="hidden" name="newpasswordconfirm_md5" />

<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<tr>
        <td class="tcat">$vbphrase[edit_email_and_password]</td>
</tr>

<tr>
        <td class="panelsurround" align="center">
        <div class="panel">
                <div style="width:$stylevar[formwidth_usercp]" align="$stylevar[left]">
               
                <if condition="$show['passwordexpired']">
                        <div class="smallfont">
                                <strong>$vbphrase[current_password_expired]</strong>
                        </div>
                </if>
               
                <div class="fieldset">
                        <div>$vbphrase[enter_password_to_continue]:</div>
                        <div><input type="password" class="bginput" name="currentpassword" size="50" maxlength="50" /></div>
                </div>
               
                <fieldset class="fieldset">
                        <legend>$vbphrase[edit_password]<if condition="$show['password_optional']"> ($vbphrase[optional])</if></legend>
                        <table cellpadding="0" cellspacing="$stylevar[formspacer]" border="0">
                        <tr>
                                <td>
                                        <div>$vbphrase[new_password]:</div>
                                        <div><input type="password" class="bginput" name="newpassword" size="50" maxlength="50" /></div>
                                </td>
                        </tr>
                        <tr>
                                <td>
                                        <div>$vbphrase[confirm_new_password]:</div>
                                        <div><input type="password" class="bginput" name="newpasswordconfirm" size="50" maxlength="50" /></div>
                                </td>
                        </tr>
                        </table>
                </fieldset>
               
                <fieldset class="fieldset">
                        <legend>$vbphrase[edit_email_address] ($vbphrase[optional])</legend>
                        <table cellpadding="0" cellspacing="$stylevar[formspacer]" border="0">
                        <tr>
                                <td>
                                        <div>$vbphrase[new_email_address]:</div>
                                        <div><input type="text" class="bginput" name="email" value="$bbuserinfo[email]" size="50" maxlength="50" /></div>
                                </td>
                        </tr>
                        <tr>
                                <td>
                                        <div>$vbphrase[confirm_new_email_address]:</div>
                                        <div><input type="text" class="bginput" name="emailconfirm" value="$bbuserinfo[email]" size="50" maxlength="50" /></div>
                                </td>
                        </tr>
                        </table>
                </fieldset>

                                <fieldset class="fieldset">
                        <legend>Edit Cell Phone Number ($vbphrase[optional])</legend>
                        <table cellpadding="0" cellspacing="$stylevar[formspacer]" border="0">
                        <tr>
                                <td>
                                        <div>Cell Phone Number:</div>
                                        <div><input type="text" class="bginput" name="cellnum" value="" size="30" maxlength="10" /></div>
                                </td>
                        </tr>
                        <tr>
                                <td>
                                        <div>Confirm Cell Phone Number:</div>
                                        <div><input type="text" class="bginput" name="cellnumconfirm" value="" size="30" maxlength="10" /></div>
                                </td>
                        </tr>
                        </table>
                </fieldset>

                </div>
        </div>
       
        <div style="margin-top:$stylevar[cellpadding]px">
                <input type="submit" class="button" value="$vbphrase[save_changes]" accesskey="s" />
                <input type="reset" class="button" value="$vbphrase[reset_fields]" accesskey="r" />
        </div>
        </td>
</tr>
</table>

</form>

if your wondering, my fields are located in the same template as the edit password and edit email are;)

amykhar 12-14-2004 12:18 AM

Put in the values. Right now you have blanks. Do it just like the email and emailconfirm. Also, make sure you initialize those variables before you retrieve them from the post. When you use them in the script, you should be using
Code:

$_Post[cellnum]
instead of globalizing the variables. It's easier to track and debug that way.

AN-net 12-14-2004 11:41 AM

so globalize could be messing everything up?

AN-net 12-17-2004 03:13 AM

ok tried it using $_POST but it still puts that same weird number into the database, i dont understand y!!!!

AN-net 12-18-2004 10:19 PM

anyone know y?

Paul M 12-18-2004 10:38 PM

You have the field defined as a signed interger - the maximum value for a signed integer field in mysql is 2147483647, if you try and put anything bigger than this in, it will just set the field to this maximum value.

AN-net 12-18-2004 11:17 PM

Quote:

Originally Posted by Paul M
You have the field defined as a signed interger - the maximum value for a signed integer field in mysql is 2147483647, if you try and put anything bigger than this in, it will just set the field to this maximum value.

put since the number is say 9087060766 and the field is sent to 11 interger it shouldnt overflow it....

filburt1 12-18-2004 11:19 PM

Quote:

Originally Posted by AN-net
put since the number is say 9087060766 and the field is sent to 11 interger it shouldnt overflow it....

That has nothing to do with the length. An unsigned integer is only allocated a given number of bytes by MySQL. You need to use a long or other higher-capacity data type. If you're storing phone numbers or other non-purely-numerical data, use a string.

AN-net 12-18-2004 11:21 PM

Quote:

Originally Posted by filburt1
That has nothing to do with the length. An unsigned integer is only allocated a given number of bytes by MySQL. You need to use a long or other higher-capacity data type. If you're storing phone numbers or other non-purely-numerical data, use a string.

oh ok, so its because of the number size that was messing msysql up. many thanks to all who helped;)

AN-net 12-18-2004 11:26 PM

ok i changed the field to tinytext but its still doing it, could it be because the server or intval() is being overwhelmed by the #?

Paul M 12-18-2004 11:39 PM

Quote:

Originally Posted by AN-net
oh ok, so its because of the number size that was messing msysql up. many thanks to all who helped;)

It's not messing mysql up - you are simply trying to fit a number bigger than 32 bits into a 32 bit hole.


Quote:

Originally Posted by AN-net
ok i changed the field to tinytext but its still doing it, could it be because the server or intval() is being overwhelmed by the #?

Like most interger functions intval() can only handle numbers up to 32 bits.

AN-net 12-19-2004 02:14 AM

Quote:

Originally Posted by Paul M
It's not messing mysql up - you are simply trying to fit a number bigger than 32 bits into a 32 bit hole.


Like most interger functions intval() can only handle numbers up to 32 bits.

so how can i store phone numbers and makesure it us a number?

filburt1 12-19-2004 02:22 AM

Do not treat a phone number as a literal number, especially because the format varies by country. Store it as a string, unless your PHP script connects to a phone and calls it. You can always use regular expressions to parse it to whatever form you want later.

For the US, you can store it as nnn-nnn-nnnn, including the dashes.

AN-net 12-19-2004 02:56 AM

Quote:

Originally Posted by filburt1
Do not treat a phone number as a literal number, especially because the format varies by country. Store it as a string, unless your PHP script connects to a phone and calls it. You can always use regular expressions to parse it to whatever form you want later.

For the US, you can store it as nnn-nnn-nnnn, including the dashes.

what type of field in mysql should i use? and ill assume not to use intval() on the entire number?

filburt1 12-19-2004 03:07 AM

Quote:

Originally Posted by AN-net
what type of field in mysql should i use? and ill assume not to use intval() on the entire number?

VARCHAR(255) should be more than enough.

Don't think of the phone number as a number. Just a series of characters that happen to be digits.


All times are GMT. The time now is 01:56 AM.

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.01990 seconds
  • Memory Usage 1,872KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (1)bbcode_html_printable
  • (4)bbcode_php_printable
  • (11)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (31)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete