RE: [PHP-DB] Strings

From: Date: Mon, 19 Mar 2001 09:29:32 +0000
Subject: RE: [PHP-DB] Strings
Groups: php.db 
Request: Send a blank email to php-db+get-7589@lists.php.net to get a copy of this message
$row[Primaryexpertise] //not like this $row['Primaryexpertise'] //like this $row["Primaryexpertise"] //or like this >i always user double quotes with postgrtesql and it works like a treat. > the difference seems to be with mysql. Also, even though simple variable references are expanded within double-quotes (ex. "where Profileid = '$profileid'"), the PHP parser seems to be less certain about how to deal with array indexes: is the square bracket intedned as plain text, as a special character (such as in a regular expression) or is it actually an array index? I find that dropping out of quotes whenever referencing array indexes eliminates a lot of parse errors. For example: "select Primaryid from primarycodes where Code = '" . $row['Primaryexpertise'] . "'" Another option is to use extract() so that the array element can be treated as a simple string variable: extract($row); $result = mysql_query("select Primaryid from primarycodes where Code = '$Primaryexpertise'") > String manipulation has me baffled most of the time! Re-read the manual's chapters on strings and arrays. Also check out the Zend site. There are some interesting articles and tutorials over there that address issues not yet adequately covered in the manual. -- CC -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net For additional commands, e-mail: php-db-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.db (#7589) next »