Re: [PHP] Re: [mysql]Problem with PHP5

2004-07-19 Thread [EMAIL PROTECTED]
Ciprian,
I may have missed whether or not you were able to resolve your problem 
from a couple days ago.

In one of my development environments (Win2K), I decided to install PHP 
5.0 with MySQL(i) 4.1.x support in IIS5.0 and Apache 2 (running on 
different ports).  It took a bit more work than I intended, but here's 
what I did:

FOR IIS (port 80):
1. downloaded and unzipped php-5.0.0-Win32.zip to c:\php
2. installed php as ISAPI
3. edited php-ini-recommended, tailored it to my environment, and copied 
it as php.ini into c:\winnt
NOTE: extension_dir = c:\php\ext
4. tested phpinfo() without extensions
5. edited php.ini enabling needed extensions.
NOTE: when uncommenting the line: extension=mysql.dll, changed line to 
read: extension=mysqli.dll
6. downloaded and unzipped mysql-4.1.3b-beta-win-noinstall.zip to c:\
7. configured mysql per www.mysql.com install instructions
8. copied c:\mysql\bin\libmysql.dll to c:\winnt\system32
9. restarted IIS, and IIS started successfully,
10. reloaded phpinfo(), and noticed that mysqli was properly loaded, but 
now my old mysql_connect_db scripts don't work!
Refer to the new mysqli PHP code: 
http://us3.php.net/manual/en/ref.mysqli.php
11. Here's a VERY basic example of the old mysql VS. new mysqli PHP code:

OLD mysql:

// connect to the database
mysql_connect("localhost", "wong", "password") or die ("Could not 
connect to mySQL server");

// select the database
mysql_select_db("music") or die ("Could not connect to database");
// store result
$result = mysql_query("SELECT * FROM artists") or die (mysql_error());
// display returned results
while ($row = mysql_fetch_array($result))
{
   echo $row["artist"], "  ", $row["album"];
   echo "";
}
// free result
mysql_free_result($result);
?>

NEW mysqli:

// connect to the database
$link = mysqli_connect("localhost", "wong", "password", "music");
// check connection
if (mysqli_connect_errno()) {
  printf("Connect failed: %s\n", mysqli_connect_error());
  exit();
}
// store query
$query = "SELECT * FROM artists";
// store result
$result = mysqli_query($link, $query);
// loop thru rows using associative array
while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC))
{
   echo $row["artist"], "  ", $row["album"];
   echo "";
}
// free the result
mysqli_free_result($result);
// close the link
mysqli_close($link);
?>
Additionally, for Apache 2 on Win2k (running on port 82):
1. Copied php.ini to c:\Apache Groups\Apache2
2. edited httpd.conf:
- added LoadModule php5_module "c:/php/php5apache2.dll"
- added AddType application/x-httpd-php .php
3. Restarted Apache server
Hopes this helps.
Dan
Ciprian Constantinescu wrote:
I have included the extension. Now I get "Unable to load dynamic library
'C:\php\ext\php_mysql.dll' - The specified procedure could not be found"
I have in Windows\System32 the file libmysql.dll. I have also put it in the
php\ext directory without any result.
 

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


RE: [PHP] Re: Mysql Problem

2004-05-28 Thread Ian Barnes
Hi,

Yes that was my mistake. But even with the code, it still doesnt display the
last one. If i didnt put a " it wouldnt work at all.

Thanks,
Ian

-Original Message-
From: Torsten Roehr [mailto:[EMAIL PROTECTED]
Sent: 28 May 2004 13:56
To: [EMAIL PROTECTED]
Subject: [PHP] Re: Mysql Problem


"Ian Barnes" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi,
>
> I am generating a mysql statement and then printing it to a formatted
field.
> Here is my code:
>
> $sql="SELECT * from tablename where name in ('Web','HTML','PHP') group by
> name;

You are missing the closing quote here!

Please set your error reporting to E_ALL while developing:
ini_set('error_reporting', E_ALL);

Regards, Torsten Roehr


> $mysql_rslt1 = mysql_query($sql, $mysql_bconn)
> or die ("Could not get data");
> while ($rec1 = mysql_fetch_array ($mysql_rslt1)) {
> echo "some stuff here";
> }
>
> Now the problem is it will leave out the last line of the reply. So it
would
> leave out the 'PHP' line for the query above. Always the last line, and if
> for some reason i only have 1 in my query, it displays nothing, although
if
> I do it manually using the mysql prompt, it works fine, and i get back the
> info I want. All the other lines format properly and the info is correct,
> just the last line doesnt display.
>
> Any ideas ?
>
> Ian

--
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] Re: MySQL Problem

2002-10-03 Thread OrangeHairedBoy

Well, that's just a typo...of course there should be a () to make it call a
function...

The whole point to my postings is that I can't get the darn variable to stay
in place!!! Look where it says "Prints NOTHING".

Does anyone know why it doesn't print "Hello World"???

::Lewis


"Mike Ford" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > -Original Message-
> > From: OrangeHairedBoy [mailto:[EMAIL PROTECTED]]
> > Sent: 03 October 2002 09:39
> >
> > Here's a simplier version...and I'm still having a problem
> > with it. It's
> > driving me insane!!! :)
> >
> > class MySQL
> >  {
> >  function SET ( )
> >   {
> >   $this->MYVAR = "Hello World!";
> >   }
> >  function RETREIVE ( )
> >   {
> >   print $this->MYVAR;
> >   }
> >  }
> > $helpme = new MySQL;
> > $helpme->SET;
> > $helpme->RETREIVE; /* Prints NOTHING */
>
> I'm pretty sure you have to add () on the end of those function names to
get
> PHP to actually *call* the function, so you need:
>
>   $helpme->SET();
>   $helpme->RETREIVE();
>
> Without the parentheses, PHP evaluates the name of the function (returning
> its "handle"), but then doesn't know what to do with it so just throws it
> away on seeing the terminating semicolon.  As far as PHP is concerned, you
> could quite legitimately want to do something entirely different with the
> handle, such as assigning it to a variable -- PHP won't assume you want to
> call it as a function just because it happens to be a function name.  For
> instance, the following should work (I think! - although I haven't tested
> it):
>
>   $method = $helpme->SET;
>   $method();
>
> In fact, you can ask PHP to try and call anything as a function by
appending
> parentheses, so this should work too:
>
>   $method = "SET";
>   $helpme->$method();
>
>
> Cheers!
>
> Mike
>
> -
> Mike Ford,  Electronic Information Services Adviser,
> Learning Support Services, Learning & Information Services,
> JG125, James Graham Building, Leeds Metropolitan University,
> Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
> Email: [EMAIL PROTECTED]
> Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211



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




RE: [PHP] Re: MySQL Problem

2002-10-03 Thread Ford, Mike [LSS]

> -Original Message-
> From: OrangeHairedBoy [mailto:[EMAIL PROTECTED]]
> Sent: 03 October 2002 09:39
> 
> Here's a simplier version...and I'm still having a problem 
> with it. It's
> driving me insane!!! :)
> 
> class MySQL
>  {
>  function SET ( )
>   {
>   $this->MYVAR = "Hello World!";
>   }
>  function RETREIVE ( )
>   {
>   print $this->MYVAR;
>   }
>  }
> $helpme = new MySQL;
> $helpme->SET;
> $helpme->RETREIVE; /* Prints NOTHING */

I'm pretty sure you have to add () on the end of those function names to get
PHP to actually *call* the function, so you need:

  $helpme->SET();
  $helpme->RETREIVE();

Without the parentheses, PHP evaluates the name of the function (returning
its "handle"), but then doesn't know what to do with it so just throws it
away on seeing the terminating semicolon.  As far as PHP is concerned, you
could quite legitimately want to do something entirely different with the
handle, such as assigning it to a variable -- PHP won't assume you want to
call it as a function just because it happens to be a function name.  For
instance, the following should work (I think! - although I haven't tested
it):

  $method = $helpme->SET;
  $method();

In fact, you can ask PHP to try and call anything as a function by appending
parentheses, so this should work too:

  $method = "SET";
  $helpme->$method();


Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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




Re: [PHP] Re: MySQL Problem

2002-10-03 Thread OrangeHairedBoy

I thought someone might mention that, but that is actually correct.

The problem is that the variable assigned on the line
$this->DBLink[$MyVars[NAME]] = mysql_connect( $MyVars[HOST] ,
$MyVars[USERNAME] , $MyVars[PASSWORD] ); dissapears and can't be retreived
on the line mysql_select_db( $MyVars[DATABASE] ,
$this->DBLink[$MyVars[LINK]] );.

For instance, if the first line saves $this->DBLink["TEST"], when CHOOSEDB
is called, the command PRINT $this->DBLink["TEST"] will print nothing when
the same line right after the variable is saved would produce something like
"Resource ID #38".

That's the brain twister.

Thanks though!


::Lewis

"Tom Rogers" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hi,
>
> Thursday, October 3, 2002, 6:01:53 PM, you wrote:
> O> You know...maybe I should mention where this code is...
>
> O> I have my main file which loads using 'require.once' a second file
called
> O> 'everything.php'.
>
> O> Inside everything.php is a class called 'mainclass' which is called by
the
> O> mail file.
>
> O> This class ('mainclass') loads the MySQL class from the previous post
which
> O> is stored in yet another file, using require.once.
>
> O> MainClass then calls the MySQL->CONNECT and MySQL->CHOOSEDB functions.
>
> O> I know this sounds a bit over the top, but it works...at least it
> O> did...until now. I thought I'd mention the circumstances in case that
makes
> O> a difference, which I suspect it will.
>
> O> Thanks again!
>
> O> Lewis
>
> O> "Orangehairedboy" <[EMAIL PROTECTED]> wrote in message
> O> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> >> Hi everyone! I can't figure out why this doesn't work. The call to the
> >> CONNECT function works and it connects with no problem, and it does
save
> O> the
> >> Resource ID in $this->DBLink[]...however, when CHOOSEDB is called, the
> >> Resource ID just saved is gone. $this->DBLink is just empty, and I
can't
> >> figure out why...
> >>
> >> Can anyone offer insight on this one?
> >>
> >> class MySQL
> >>  {
> >>  var $DBLink = array();
> >>  function CONNECT ( $MyVars , $MyContents )
> >>   {
> >>   $host = ( $MyVars[PORT] ) ? $MyVars[HOST] . ":" . $MyVars[PORT] :
> >> $MyVars[HOST];
> >>   $this->DBLink[$MyVars[NAME]] = mysql_connect( $MyVars[HOST] ,
> >> $MyVars[USERNAME] , $MyVars[PASSWORD] );
> >>   }
> >>  function CHOOSEDB ( $MyVars , $MyContents )
> >>   {
> >>   mysql_select_db( $MyVars[DATABASE] , $this->DBLink[$MyVars[LINK]] );
> >>   }
> >>  }
> >>
> >>
> >> Thanks!
> >>
> >>
> >> Lewis
> >>
> >>
>
> Looks like you change the name of the index from NAME to LINK
> and it should be  $this->DBLink[$MyVars['LINK']]
>
> --
> regards,
> Tom
>



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




Re: [PHP] Re: MySQL Problem

2002-10-03 Thread Tom Rogers

Hi,

Thursday, October 3, 2002, 6:01:53 PM, you wrote:
O> You know...maybe I should mention where this code is...

O> I have my main file which loads using 'require.once' a second file called
O> 'everything.php'.

O> Inside everything.php is a class called 'mainclass' which is called by the
O> mail file.

O> This class ('mainclass') loads the MySQL class from the previous post which
O> is stored in yet another file, using require.once.

O> MainClass then calls the MySQL->CONNECT and MySQL->CHOOSEDB functions.

O> I know this sounds a bit over the top, but it works...at least it
O> did...until now. I thought I'd mention the circumstances in case that makes
O> a difference, which I suspect it will.

O> Thanks again!

O> Lewis

O> "Orangehairedboy" <[EMAIL PROTECTED]> wrote in message
O> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
>> Hi everyone! I can't figure out why this doesn't work. The call to the
>> CONNECT function works and it connects with no problem, and it does save
O> the
>> Resource ID in $this->DBLink[]...however, when CHOOSEDB is called, the
>> Resource ID just saved is gone. $this->DBLink is just empty, and I can't
>> figure out why...
>>
>> Can anyone offer insight on this one?
>>
>> class MySQL
>>  {
>>  var $DBLink = array();
>>  function CONNECT ( $MyVars , $MyContents )
>>   {
>>   $host = ( $MyVars[PORT] ) ? $MyVars[HOST] . ":" . $MyVars[PORT] :
>> $MyVars[HOST];
>>   $this->DBLink[$MyVars[NAME]] = mysql_connect( $MyVars[HOST] ,
>> $MyVars[USERNAME] , $MyVars[PASSWORD] );
>>   }
>>  function CHOOSEDB ( $MyVars , $MyContents )
>>   {
>>   mysql_select_db( $MyVars[DATABASE] , $this->DBLink[$MyVars[LINK]] );
>>   }
>>  }
>>
>>
>> Thanks!
>>
>>
>> Lewis
>>
>>

Looks like you change the name of the index from NAME to LINK
and it should be  $this->DBLink[$MyVars['LINK']]

-- 
regards,
Tom


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




Re: [PHP] Re: MySQL Problem with PHP

2002-06-26 Thread Erik Price


On Wednesday, June 26, 2002, at 08:58  AM, John Holmes wrote:

>> I just preg_replace("/\'/","\'",$text) and all was good :o)
>
> That's what addslashes() is for. It handles single and double quotes,
> backslashes, and nulls, so you won't have any problems...

Plus IIRC it's a C extension so it'll run faster anyway.


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] Re: MySQL Problem with PHP

2002-06-26 Thread John Holmes

> I just preg_replace("/\'/","\'",$text) and all was good :o)

That's what addslashes() is for. It handles single and double quotes,
backslashes, and nulls, so you won't have any problems...

---John Holmes...


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