try $something=settype(mysql_result($variable,0),"string");
----- Original Message ----- From: "daniel" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, January 25, 2002 12:25 PM Subject: Re: [PHP] Must results from MySQL fetches always be an Array?? > > This is sort of a "is there an easier/better way" kind of question. No > > error or problem, but I'd like to know how others handle it. > > > > I'm fetching single elements of data from several tables, then piecing > > it together. Here's an example of one element I need to fetch: > > > > $series = mysql_fetch_array(mysql_query("SELECT key2 FROM models WHERE > > lang='$lang' AND recordname='$model'",$db)); > > > > Now I realize that with this function $series will always be an array, > > even if it contains just one element (which it does). What I'd like to > > know is, can I write that statement so that $series is created just as a > > string? (So that I don't have to write "$series = $series[0];" > > immediately afterwards in order to treat $series as a $string.) > > > > ...Rene > > function mysql_get_one_field($stmt,$db) { > $res = mysql_query($stmt,$db); > $series = mysql_fetch_array($res); > mysql_free_result($res); > > return $series[0]; > } > > > > Daniel J. Lashua > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]