p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

beginning_php thread: MySQL problem


Message #1 by "Mike Barber" <chanyom@h...> on Thu, 11 Jan 2001 22:09:41 -0000
This may sound like a dumb question, but I am a total newbie at this...



Am I supposed to put the database anywhere specific on the server?



We are hosted by a third-party who has MySQL installed on their Apache

server.  I have a PHP script that reads:



// Write Data To File

$dbname = "unicusClub";



$link_id = mysql_connect();

if(!$link_id) die(sql_error());



if(!mysql_select_db($dbname)) die(sql_error));



$query = "INSERT INTO member VALUES('$lastName', '$firstName', '$eMail',

'$serial')";

mysql_query($query);







Message #2 by "Rick" <rsal@h...> on Fri, 12 Jan 2001 05:40:00 -0000
Hello,



I hope this what your looking for...



It's fine to have your database on a different server. You would just call

it like this:



<?php 



$hostname="www.youdatabasever.whatever";

$username="username";

$password="password";

$dbName="database name";



$link_id = mysql_connect($hostname, $username, $password);

if(!$link_id){

   die(sql_error());

}

?>

as long as you have a function defined called sql_error



you could also do this:

@mysql_connect($hostname, $username, $password) || die "Unable to connect

to database server";

@mysql_select_db($dbName) || die "Unable to select database";



Hope that helps,

Rick





> This may sound like a dumb question, but I am a total newbie at this...

> 

> Am I supposed to put the database anywhere specific on the server?

> 

> We are hosted by a third-party who has MySQL installed on their Apache

> server.  I have a PHP script that reads:

> 

> // Write Data To File

> $dbname = "unicusClub";

> 

> $link_id = mysql_connect();

> if(!$link_id) die(sql_error());

> 

> if(!mysql_select_db($dbname)) die(sql_error));

> 

> $query = "INSERT INTO member VALUES('$lastName', '$firstName', '$eMail',

> '$serial')";

> mysql_query($query);

Message #3 by gaurav khanna <gaurav_khanna25@y...> on Fri, 12 Jan 2001 02:06:55 -0800 (PST)
hi rick ,





i m new to php could u tell me can i use MS-Access

with php





plz let me know & give some books or url where i can

ets lots of samples codes for it 





bye Gautam

mail is gauravkhanna_25@y...











--- Rick <rsal@h...> wrote:

> Hello,

> 

> I hope this what your looking for...

> 

> It's fine to have your database on a different

> server. You would just call

> it like this:

> 

> <?php 

> 

> $hostname="www.youdatabasever.whatever";

> $username="username";

> $password="password";

> $dbName="database name";

> 

> $link_id = mysql_connect($hostname, $username,

> $password);

> if(!$link_id){

>    die(sql_error());

> }

> ?>

> as long as you have a function defined called

> sql_error

> 

> you could also do this:

> @mysql_connect($hostname, $username, $password) ||

> die "Unable to connect

> to database server";

> @mysql_select_db($dbName) || die "Unable to select

> database";

> 

> Hope that helps,

> Rick

> 

> 

> > This may sound like a dumb question, but I am a

> total newbie at this...

> > 

> > Am I supposed to put the database anywhere

> specific on the server?

> > 

> > We are hosted by a third-party who has MySQL

> installed on their Apache

> > server.  I have a PHP script that reads:

> > 

> > // Write Data To File

> > $dbname = "unicusClub";

> > 

> > $link_id = mysql_connect();

> > if(!$link_id) die(sql_error());

> > 

> > if(!mysql_select_db($dbname)) die(sql_error));

> > 

> > $query = "INSERT INTO member VALUES('$lastName',

> '$firstName', '$eMail',

> > '$serial')";

> > mysql_query($query);

> 

Message #4 by "Wit B." <B.Wit@g...> on Fri, 12 Jan 2001 11:55:15 +0100
Make a system DNS for your database.. and then connect to it using the

ODBC-functions of PHP.



Good luck!



grt BasWit



> -----Oorspronkelijk bericht-----

> Van: gaurav khanna [mailto:gaurav_khanna25@y...]

> Verzonden: vrijdag 12 januari 2001 11:07

> Aan: beginning php

> Onderwerp: [beginning_php] Re: MySQL problem

> 

> 

> hi rick ,

> 

> 

> i m new to php could u tell me can i use MS-Access

> with php

> 

> 

> plz let me know & give some books or url where i can

> ets lots of samples codes for it 

> 

> 

> bye Gautam

> mail is gauravkhanna_25@y...

> 

> 

> 

> 

> 

> --- Rick <rsal@h...> wrote:

> > Hello,

> > 

> > I hope this what your looking for...

> > 

> > It's fine to have your database on a different

> > server. You would just call

> > it like this:

> > 

> > <?php 

> > 

> > $hostname="www.youdatabasever.whatever";

> > $username="username";

> > $password="password";

> > $dbName="database name";

> > 

> > $link_id = mysql_connect($hostname, $username,

> > $password);

> > if(!$link_id){

> >    die(sql_error());

> > }

> > ?>

> > as long as you have a function defined called

> > sql_error

> > 

> > you could also do this:

> > @mysql_connect($hostname, $username, $password) ||

> > die "Unable to connect

> > to database server";

> > @mysql_select_db($dbName) || die "Unable to select

> > database";

> > 

> > Hope that helps,

> > Rick

> > 

> > 

> > > This may sound like a dumb question, but I am a

> > total newbie at this...

> > > 

> > > Am I supposed to put the database anywhere

> > specific on the server?

> > > 

> > > We are hosted by a third-party who has MySQL

> > installed on their Apache

> > > server.  I have a PHP script that reads:

> > > 

> > > // Write Data To File

> > > $dbname = "unicusClub";

> > > 

> > > $link_id = mysql_connect();

> > > if(!$link_id) die(sql_error());

> > > 

> > > if(!mysql_select_db($dbname)) die(sql_error));

> > > 

> > > $query = "INSERT INTO member VALUES('$lastName',

> > '$firstName', '$eMail',

> > > '$serial')";

> > > mysql_query($query);

> > 

> 


  Return to Index