Re: Re: syntax error, unexpected T_STRING
| From: | Jochem Maas | Date: | Mon, 18 Jul 2005 20:34:52 +0000 |
| Subject: | Re: Re: syntax error, unexpected T_STRING | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-218915@lists.php.net to get a copy of this message | ||
George B wrote:
George B wrote:the semicolon delimits a single statement (however complex). tabs and spaces have no 'token' meaning. as in the parser doesn't give a hoot if you write the whole scripton a single line. (I use the word statement but I'm not sure that's the correct name for it - anyone care to add?) if/else/else if/while/for(/etc?) have the quality that you can leave out the braces if you are only wish to conditionally execute 1 statement ... e.g: // run this on the cmdline or change the '\n's to '<br />' $a = $b = $c = "A"; $d = array("A"); $e = "B"; echo "\nplainfoos and foofoos:\n"; // this one you dont see (the silentfoo) if (!in_array(str_replace($a,$b,$c),$d)) echo "silentfoo\n"; // this is like the next one if (in_array(str_replace($a,$b,$c),$d)) echo "foo\n"; // this is like the previous one if (in_array(str_replace($a,$b,$c),$d)) { echo "foo\n"; } /////////////////////////////////// // this is not like the next one if (in_array(str_replace($a,$b,$c),array($e))) echo "foo"; echo "foo\n"; // this is not like the previous one if (in_array(str_replace($a,$b,$c),$d)) { echo "foo"; echo "foo\n"; } and now a word from our sponsor for this evening about die()ing ...I am trying to connect to a datbase: " mysql_select_db ('database')this code works thoughor die ("couldnt connect to databse")" What is wrong here? This is the error: Parse error: syntax error, unexpected T_STRING in file name on line 12
$db = mysql_connect("localhost", "myaccount", "mypass") or die("Could not connect.");<? function yourmoney($kids = 1) { return 80 - (90 * $kids); } function yourlife($lastWords = "errr") { die(strval($s)); } yourmoney() or yourlife("is no choice at all."); ?> (it has to be added that we are talking about those special kind of children that are capable of 'breaking' your friends Hummer ;-)) [not a true story - just popped into my head.]
if(!$db)die(); die(); die() ... see it doesn't even sound very nice ;-) have fun!die("no db");if(!mysql_select_db("database",$db))die("No database selected.");