List:General Discussion« Previous MessageNext Message »
From:Jan-Michael Ong Date:April 25 2002 8:06am
Subject:Re: PHP and MySQL help please !
View as plain text  
Hello,

Try this
<?

function samp_db_connect()
{
  $hostname = "localhost";
  $username = "joe";
  $password = "user";
  $dbName = "test";

   $link = @mysql_pconnect($hostname, $username, $password);
   if ($link && mysql_select_db($dbName))
      return $link;
   return FALSE;
}

samp_db_connect() or exit();

?>

good luck

Andrew Rich wrote:

> Further to this, I removed the "@" symbol and got:-
>
> Fatal Error: Call to undefined function: mysql_connect() in
> /var/www/html/results.php
>
> @ $db = mysql_pconnect("localhost", "user", "password");
>
> $db = mysql_pconnect("localhost", "user", "password");
>
> Ideas ? Why is it  now a undefined function ?
>
> Andrew
> -----Original Message-----
> From: Andrew Rich [mailto:andrew.rich@stripped]
> Sent: Thursday, 25 April 2002 11:14 AM
> To: mysql@stripped
> Subject: PHP and MySQL help please !
>
> + PHP Installed and going - I can write to files, retrieve flatfiles
> + Apache running servers outpages nop probes
>
> Trying to talk to SQL using PHP.
> ----------------------------------------------------------------------------
> ----------
> <html>
> <body>
> <h1>Go to SQL now</h1>
> <?
> echo "looking";
>    @ $db = mysql_pconnect("localhost", "user", "password");
>   if (!$db);
>   {
>      echo "Error: Could not connect to database.  Please try again later.";
>      exit;
>   }
>   mysql_select_db("test");
>   $query = "select * from logbook" ;
>   $result = mysql_query($query);
>   $num_results = mysql_num_rows($result);
>   echo "<p>Number of books found: ".$num_results."</p>";
> ?>
> </body>
> </html>
> ----------------------------------------------------------------------------
> -------------
> What gets me if I can do all this from the mysql prompt:-
> laptop>mysql -u user -p (enterpassword gets me in)
> mysql>use test;  OK
> mysql>select * from logbook;  OK (shows entries no probs);
> ----------------------------------------------------------------------------
> -------------
> What am I doing wrong ?
>
> It doesnt get past the
>
>  @ $db = mysql_pconnect("localhost", "user", "password");
>
> in the code.
>
> ??????????????
>
> Andrew
>
> -------------------------------------------
> Andrew Rich
> Callsign: VK4TEC
> andrew.rich@stripped
> www.users.bigpond.com/andrew.rich/vk4tec.htm
>
> -------------------------------------------
> Andrew Rich
> Callsign: VK4TEC
> andrew.rich@stripped
> www.users.bigpond.com/andrew.rich/vk4tec.htm
>
> ---------------------------------------------------------------------
> Before posting, please check:
>    http://www.mysql.com/manual.php   (the manual)
>    http://lists.mysql.com/           (the list archive)
>
> To request this thread, e-mail <mysql-thread107050@stripped>
> To unsubscribe, e-mail
> <mysql-unsubscribe-andrew.rich=bigpond.com@stripped>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>
> ---------------------------------------------------------------------
> Before posting, please check:
>    http://www.mysql.com/manual.php   (the manual)
>    http://lists.mysql.com/           (the list archive)
>
> To request this thread, e-mail <mysql-thread107051@stripped>
> To unsubscribe, e-mail <mysql-unsubscribe-jmong=adobe.com@stripped>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Thread
PHP and MySQL help please !Andrew Rich25 Apr
  • RE: PHP and MySQL help please !Andrew Rich25 Apr
    • RE: PHP and MySQL help please !Andrew Rich25 Apr
      • RE: PHP and MySQL help please !Michael Chang25 Apr
    • Re: PHP and MySQL help please !Jan-Michael Ong25 Apr