Re: or die
| From: | Raidell Avello | Date: | Sat, 04 May 2002 18:05:34 +0000 |
| Subject: | Re: or die | ||
| References: | 1 2 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-13537@lists.php.net to get a copy of this message | ||
thanks, now work
the problems is i copy this sample from distribution chm manual
i'll send a message inform that...
The whole sample is:
<?php
$link = mysql_pconnect ("kron", "jutta", "geheim") {
or die ("Could not connect");
}
mysql_select_db ("samp_db") {
or die ("Could not select database");
}
$query = "SELECT last_name, first_name FROM friends";
$result = mysql_query ($query) {
or die ("Query failed");
}
# fetch rows in reverse order
for ($i = mysql_num_rows ($result) - 1; $i >=0; $i--) {
if (!mysql_data_seek ($result, $i)) {
printf ("Cannot seek to row %d\n", $i);
continue;
}
if(!($row = mysql_fetch_object ($result)))
continue;
printf ("%s %s<BR>\n", $row->last_name, $row->first_name);
}
mysql_free_result ($result);
?>
> The first example fixed:
> $link = mysql_pconnect ("localhost", "sa", "sa") or die
> ("Could not
> connect");
>
> or die is an option of mysql_pconnect so you don´t need the {}.
>
> In the second example you can use {} for the if.
>
> []´s Waldemar
>
>
> ----- Original Message -----
> From: "Raidell Avello" <ravello@ucfinfo.ucf.edu.cu>
> To: <php-windows@lists.php.net>
> Sent: Saturday, May 04, 2002 1:33 PM
> Subject: [PHP-WIN] or die
>
>
> > hi
> > a have this code
> > $link = mysql_pconnect ("localhost", "sa", "sa") {
> > or die ("Could not connect");
> > }
> > and i receive
> > Parse error: parse error in c:\htdocs\otra.php on line 2
> >
> > and rewrite the code like this
> > if (!$link = mysql_pconnect ("localhost", "sa", "sa")) {
> > echo "Could not connect";
> > }
> > and work
> > what's wrong???
> > regards
> > RAM
> >
> >
> > --
> > PHP Windows Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>
>
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php