You are here: Re: PHP error for "if (mysql_connect_errno())" « All PHP « IT news, forums, messages
Re: PHP error for "if (mysql_connect_errno())"

Posted by Jerry Stuckle on 12/28/07 03:53

jcage@lycos.com wrote:
> Can someone help me with an issue I'm having with a bit of PHP code as
> it connects to a database? I'm trying to use the code below to let a
> user know that there is a problem connecting to the database and for
> whatever reason, cannot get the portion within the double quotes below
> to function properly (double quotes around the code is normally not
> there). PHP version is 4.1.1 so I'm wondering if perhaps the
> mysql_connect_errno (have tried 'error' in place of errno) is too
> advanced possibly for this php version because I can't get the code
> working.
>
> Code works fine without the error trapping portion below assuming a
> connection took place but otherwise, has created an issue on one
> occasion that I know of so I'd like to get the error trap in place.
> thanks for any pointers.
>
> John
>
> "if (mysql_connect_errno())
> {
> echo 'Error: Could not connect to database. Please try again
> later.';
> exit;
> }"
>
> mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable to connect to
> database"); // make connection to database
> mysql_select_db($DBName) or die("Unable to select database
> $DBName"); // select database
> if (mysql_connect_errno())
> {
> echo 'Error: Could not connect to database. Please try again
> later.';
> exit;
> }
> $sqlquery = "INSERT INTO $table VALUES('$id', '$time', '$month',
> '$year')";
> if ($results = mysql_query($sqlquery)) {
>

There is no function mysql_connect_errno() (or mysql_connect_error()).

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация