[PHP] Code Troubles

2002-04-26 Thread Randum Ian

Hi all, Im having trouble with this code, can anyone help?

---

?php // db.php

$dbhost = localhost;
$dbuser = dancepo_db;
$dbpass = database;

function dbConnect($db=dancepo_db) {
global $dbhost, $dbuser, $dbpass;

$dbcnx = @mysql_connect($dbhost, $dbuser, $dbpass)
or die(The site database appears to be down.);

if ($db!= and !@mysql_select_db($db))
die(The site database is unavailable.);

return $dbcnx;
}
?

---

Cheers, Ian.
---
Randum Ian
DJ / Reviewer / Webmaster, DancePortal (UK) Limited
[EMAIL PROTECTED]
http://www.danceportal.co.uk
DancePortal.co.uk - Global dance music media


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Code Troubles

2002-04-26 Thread Erik Price


On Friday, April 26, 2002, at 12:20  PM, Randum Ian wrote:

 Hi all, Im having trouble with this code, can anyone help?

 ---

 ?php // db.php

 $dbhost = localhost;
 $dbuser = dancepo_db;
 $dbpass = database;

 function dbConnect($db=dancepo_db) {
 global $dbhost, $dbuser, $dbpass;

 $dbcnx = @mysql_connect($dbhost, $dbuser, $dbpass)
 or die(The site database appears to be down.);

 if ($db!= and !@mysql_select_db($db))
 die(The site database is unavailable.);

 return $dbcnx;
 }
 ?

Well, you've simply defined a few variables and then a function.  Do you 
expect it to do something?

Show us the context in which this function is used.


Erik





Erik Price
Web Developer Temp
Media Lab, H.H. Brown
[EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Code Troubles

2002-04-26 Thread Randum Ian

The trouble I got with it is the code is chucking back the The site
database is unavailable. error and it is indeed available. I have used
other scripts at the same time and they are pumping it back. It is not a way
of coding I have used before and wondered if it was the code?

I am simply finding different ways of logging onto a mySQL db.

- Original Message -
From: Erik Price [EMAIL PROTECTED]
To: Randum Ian [EMAIL PROTECTED]
Cc: PHP [EMAIL PROTECTED]
Sent: Friday, April 26, 2002 5:21 PM
Subject: Re: [PHP] Code Troubles



 On Friday, April 26, 2002, at 12:20  PM, Randum Ian wrote:

  Hi all, Im having trouble with this code, can anyone help?
 
  ---
 
  ?php // db.php
 
  $dbhost = localhost;
  $dbuser = dancepo_db;
  $dbpass = database;
 
  function dbConnect($db=dancepo_db) {
  global $dbhost, $dbuser, $dbpass;
 
  $dbcnx = @mysql_connect($dbhost, $dbuser, $dbpass)
  or die(The site database appears to be down.);
 
  if ($db!= and !@mysql_select_db($db))
  die(The site database is unavailable.);
 
  return $dbcnx;
  }
  ?

 Well, you've simply defined a few variables and then a function.  Do you
 expect it to do something?

 Show us the context in which this function is used.


 Erik



 

 Erik Price
 Web Developer Temp
 Media Lab, H.H. Brown
 [EMAIL PROTECTED]





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Code Troubles

2002-04-26 Thread Miguel Cruz

It helps to say what sort of trouble you're having; i.e., provide 
symptoms, exact text of error messages, etc.

miguel 

On Fri, 26 Apr 2002, Randum Ian wrote:
 Hi all, Im having trouble with this code, can anyone help?
 
 ---
 
 ?php // db.php
 
 $dbhost = localhost;
 $dbuser = dancepo_db;
 $dbpass = database;
 
 function dbConnect($db=dancepo_db) {
 global $dbhost, $dbuser, $dbpass;
 
 $dbcnx = @mysql_connect($dbhost, $dbuser, $dbpass)
 or die(The site database appears to be down.);
 
 if ($db!= and !@mysql_select_db($db))
 die(The site database is unavailable.);
 
 return $dbcnx;
 }
 ?
 
 ---
 
 Cheers, Ian.
 ---
 Randum Ian
 DJ / Reviewer / Webmaster, DancePortal (UK) Limited
 [EMAIL PROTECTED]
 http://www.danceportal.co.uk
 DancePortal.co.uk - Global dance music media
 
 
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Code Troubles

2002-04-26 Thread Chris Wesley

 if ($db!= and !@mysql_select_db($db))
 die(The site database is unavailable.);

you probably want an or before that die().

g.luck,
~Chris /\
   \ / Microsoft Security Specialist:
X  The moron in Oxymoron.
   / \ http://www.thebackrow.net

On Fri, 26 Apr 2002, Randum Ian wrote:

 Hi all, Im having trouble with this code, can anyone help?

 ---

 ?php // db.php

 $dbhost = localhost;
 $dbuser = dancepo_db;
 $dbpass = database;

 function dbConnect($db=dancepo_db) {
 global $dbhost, $dbuser, $dbpass;

 $dbcnx = @mysql_connect($dbhost, $dbuser, $dbpass)
 or die(The site database appears to be down.);

 if ($db!= and !@mysql_select_db($db))
 die(The site database is unavailable.);

 return $dbcnx;
 }
 ?

 ---

 Cheers, Ian.
 ---
 Randum Ian
 DJ / Reviewer / Webmaster, DancePortal (UK) Limited
 [EMAIL PROTECTED]
 http://www.danceportal.co.uk
 DancePortal.co.uk - Global dance music media


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Code Troubles

2002-04-26 Thread Miguel Cruz

Why not take the @ off @mysql_select_db($db) so that you can see which 
particular error is being returned? Or print mysql_error().

miguel

On Fri, 26 Apr 2002, Randum Ian wrote:

 The trouble I got with it is the code is chucking back the The site
 database is unavailable. error and it is indeed available. I have used
 other scripts at the same time and they are pumping it back. It is not a way
 of coding I have used before and wondered if it was the code?
 
 I am simply finding different ways of logging onto a mySQL db.
 
 - Original Message -
 From: Erik Price [EMAIL PROTECTED]
 To: Randum Ian [EMAIL PROTECTED]
 Cc: PHP [EMAIL PROTECTED]
 Sent: Friday, April 26, 2002 5:21 PM
 Subject: Re: [PHP] Code Troubles
 
 
 
  On Friday, April 26, 2002, at 12:20  PM, Randum Ian wrote:
 
   Hi all, Im having trouble with this code, can anyone help?
  
   ---
  
   ?php // db.php
  
   $dbhost = localhost;
   $dbuser = dancepo_db;
   $dbpass = database;
  
   function dbConnect($db=dancepo_db) {
   global $dbhost, $dbuser, $dbpass;
  
   $dbcnx = @mysql_connect($dbhost, $dbuser, $dbpass)
   or die(The site database appears to be down.);
  
   if ($db!= and !@mysql_select_db($db))
   die(The site database is unavailable.);
  
   return $dbcnx;
   }
   ?
 
  Well, you've simply defined a few variables and then a function.  Do you
  expect it to do something?
 
  Show us the context in which this function is used.
 
 
  Erik
 
 
 
  
 
  Erik Price
  Web Developer Temp
  Media Lab, H.H. Brown
  [EMAIL PROTECTED]
 
 
 
 
 
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Code Troubles

2002-04-26 Thread Miguel Cruz

On Fri, 26 Apr 2002, Chris Wesley wrote:
 if ($db!= and !@mysql_select_db($db))
 die(The site database is unavailable.);
 
 you probably want an or before that die().

How would that work?

miguel


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Code Troubles

2002-04-26 Thread Chris Wesley

if( $db ){
mysql_select_db($db) or die(The site database is unavailable.);
}

To debug, use print( mysql_error ) instead of die to figure out what's
going on.  It's not that far of a leap in logic.

~Chris /\
   \ / Microsoft Security Specialist:
X  The moron in Oxymoron.
   / \ http://www.thebackrow.net

On Fri, 26 Apr 2002, Miguel Cruz wrote:

 On Fri, 26 Apr 2002, Chris Wesley wrote:
  if ($db!= and !@mysql_select_db($db))
  die(The site database is unavailable.);
 
  you probably want an or before that die().

 How would that work?

 miguel




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php