Re: PHP give me empty page



mtczx232@xxxxxxxxx wrote:
but I have another problam with connection MySQL page:

heare the code:


<?php
$host = "localhost";
$username = "root";
$password = "1234";
$database = "db";
echo "xxdfdfdf";
echo mysql_error();
$server = mysql_connect($host, $username, $password);
echo (mysql_error());

I try a lot, but always all echo after :"mysql_connect" ignored!

why?


The function mysql_error() will only generate a string if there have been an error while you did the mysql_connect(), if no error, then no string and then no output from the echo.

From http://www.php.net/manual/en/function.mysql-error.php
Return Values
Returns the error text from the last MySQL function,
or '' (empty string) if no error occurred.


//Aho
.



Relevant Pages

  • Re: php form info...
    ... when trying to search in the mysql statement. ... : echo $testvar; ... combine a variable containing an arbitrary string with a constant number. ... The results within php depend a great deal on the contents ...
    (comp.lang.php)
  • Re: How does PHP store strings?
    ... To access the 'null terminator', ... or access out of the bounds of the string. ... I tried doing this in PHP 5 by writing: ... echo $string; ...
    (php.general)
  • Re: String variable read from Mysql DB + echo = Newline problem
    ... echo "$formatting2"; ... create the variable inline in my php script. ... barfs if I pass the string I got from the DB. ... However, when read in from an external source, these are the characters "backslash" and "en". ...
    (comp.lang.php)
  • Re: set user=%username%
    ... Your most recent feedback confirms that Windows is ... Type this: echo %MyName% ... > usertest=This is a long string. ...
    (microsoft.public.windows.server.general)
  • Re: formating text retrieved from a db
    ... Polar wrote: ... > think I've gotten along fine for only starting php coding 2 weeks ago. ... so you are putting the nl2brfunction within the text string - ... echo ''; ...
    (comp.lang.php)