Re: how to concatenate php variables in mysql query

From: Date: Wed, 22 Sep 2004 13:21:00 +0000
Subject: Re: how to concatenate php variables in mysql query
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-197568@lists.php.net to get a copy of this message
luke@lukem.co.uk wrote:
here is the whole query: $query = "INSERT INTO inmarsat_comp SET date_added=NOW(), prefix='$prefix', firstname='$firstname', lastname='$lastname', job_title='$jobtitle', company_name='$company', no_of_employees='$employees',address_1='$address1',address_2='$address2', address_3='$address3', town='$town', county ='$county', postcode='$postcode', country ='$country', telephone_number='$telcode.$telnumber', fax_number='$faxcode.$faxnumber', email='$email', enterprise='$enterprises', optin_thirdparty='$distribute', optin_news='$market'"; only the telcode gets inserted.
I guess telephone_number is type INT, then "telephone_number= '$telcode.$telnumber' " becomes "telephone_number= '555.456545' ", which is float, converted to int becomes just 555. You don't need concatenation oparators (.) within doublequoted strings, use just "telephone_number= '$telcode$telnumber' "

« previous php.general (#197568) next »