Re: Re: function problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If you were trying to use the result from mysql_pconnect() as the second
optional argument to mysql_query() in your function, be sure you declare
it 'global' inside the function.

Read PHP docs on "variable scope" if this is what tripped you up.

If not, I have no idea why the database is not selected, but you can now
focus on figuring out where/when it got selected, and where/when it got
un-selected, and there may even be a query you could send to ask MySQL
what database it thinks you are using.  Sprinkle a lot of those through
your code to find out where it changes from what you expect to "not
working"

Viktor Popov wrote:
> Hi,
>
> Thank you for your reply!
>
> I have changed the function like this:
>
> function doReg($fname1="",$family1="",$company1="", $MOL1="", $dannum1="",
> $bulstat1="", $phone1="", $email1="", $username1="", $password1="",
> $payment1="", $maillist1="", $Addr1="", $City1="", $zipcode1="",
> $Country1="", $shippingName1="", $shippingFamily1="", $shippingphone1="",
> $shippingAddr1="", $shippingcity1="", $shippingzipcode1="",
> $shippingCountry1="")
> {
>
>   mysql_pconnect ($DB_SERVER, $DB_LOGIN, $DB_PASSWORD) or
> die(mysql_error());
>
>
>
>  mysql_select_db($DB) or die(mysql_error());
>   mysql_query( "insert into users(name,family,company, MOL, taxnum,
> bulstat,
> phone, email, username, password, payment, maillist, Addr, City, zipcode,
> Country, shippingName, shippingFamily, shippingphone, shippingAddr,
> shippingcity, shippingzipcode, shippingCountry)
> values('$fname1','$family1','$company1', '$MOL1', '$dannum1', '$bulstat1',
> '$phone1', '$email1', '$username1', '$password1', '$payment1',
> '$maillist1',
> '$Addr1', '$City1', '$zipcode1',
> '$Country1','$shippingName1','$shippingFamily1',
> '$shippingphone1','$shippingAddr1', '$shippingcity1', '$shippingzipcode1',
> '$shippingCountry1')") or die (mysql_error());
>
>
> }
>
> I think that the problem is not in the insertion string because when write
> the function body :
>  mysql_pconnect(.....);
> mysql_select_db($DB) or die(mysql_error());
> mysql_query("insert into ....");
>
> instead doReg() in register.php, everything works. I have inserted some
> data
> in this way.
> The problem is that A DATABASE is  NOT SELECTED. This is the message when
> I
> use doReg().
>
> The register.php   is   in the DOCROOT->emagazine.  In the subdirectory
> script are "common.inc"  and  "functions.php". In common.inc is this:
>
> <?php
>  $DB_SERVER="localhost";
>  $DB_LOGIN="admin";
>  $DB_PASSWORD="******";
>  $DB="emagazine";
>  $HTTP_HOST="localhost:3000";
>  $DOCROOT="emagazine";
>
> ?>
>
> Is it all right? I think that $DB="emagazine"  should work. Here I select
> the $DB, which name is "emagazine".
>
> I don't understand what's going on:)
>
>
>
> Thank you!
>
> Viktor
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux