On 30/04/2011, Daniel Brown <[email protected]> wrote:
> Readers? Sounds like you spend too much time writing newsletters
> (to the wrong address, since [email protected] is
> a self-help command list for digest-form subscriptions). ;-P
>
> On Sat, Apr 30, 2011 at 04:41, e-letter <[email protected]> wrote:
>> <?php
>> $db = pg_connect('dbname=databasename user=username');
>> $query = 'SELECT * FROM databasename';
>> $value=pg_fetch_result($query,1,0);
>> echo 'export of database is ',$value,'';
>> ?>
>> <p>
>> why does this fail?
>
> How is it failing? What error(s) are you seeing on screen or in
> your log files? Noting that $value would contain an array, is that
> the problem? And why are you using ending quotes in your echo? You
> should just place the semicolon immediately after $value.
>
I looked at the error file located at '/var/log/httpd/error_log',
which identifies an error:
...Apache/2.2.6 (Mandriva Linux/PREFORK-8.2mdv2008.0) PHP/5.2.4 with
Suhosin-Patch mod_put/2.0.8 configured -- resuming normal
operations...
...PHP Parse error: syntax error, unexpected T_VARIABLE, expecting
',' or ';'...
The file was changed as follows which caused the parse error shown above:
<?php
$db = pg_connect('dbname=webcuttings user=httpd');
$query = 'SELECT * FROM articles';
$value=pg_fetch_result($query);
echo 'all files' $value;
?>
The file was copied from the manual page, without understanding that
an array was being used.
>> </p>
>> </body>
>> </html>
>>
>> The following php code produces the user agent:
>>
>> <?php
>> echo '$_SERVER['HTTP_USER_AGENT']';
>> ?>
>
> First of all, no it doesn't. Placed inside single quotes, it'll
> not only try to return it verbatim (i.e. - the variable would be
> printed to screen), but it'll also cause a parse error, as you reuse
> single quotes in the variable key container.
>
My mistake; with the command:
<?php
echo $_SERVER['HTTP_USER_AGENT'];
?>
the result is:
Opera/9.80 (X11; Linux i686; U; en-GB) Presto/2.6.30 Version/10.61
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php