[PHP] Class returning more than one value

2006-10-14 Thread Deckard
Hi,

How can i code a class with a function that returns more than one value ?

Any help would be appreciated.

Warm Regards,
Deckard

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



Re: [PHP] Detected a pattern that malfunctions includes

2006-10-06 Thread Deckard
Hi,

I've already set my include_path to /var/www/html and good :(

Best Regards,
Deckard

Richard Lynch wrote:
> On Fri, October 6, 2006 11:17 am, Deckard wrote:
>> I see now that only when the inclu function "has to scale up in the we
>> tree", it fails.
>>
>> For example:
>>
>> This works:
>> include_once("classes/database/dBInsert.php");
>>
>> This don't:
>> include_once('../adodb/adodb.inc.php');
> 
> safe_mode and that other security restriction on what you can/can't
> include do this, I think...
> 
> Which is probably hack to save you from somebody pushing
> '../../../../../etc/passwd' into:
> include $myfile;
> but so it goes.
> 
> Meanwhile, back at the ranch, if you set include_path you'd be able to
> move on to something productive :-) :-) :-)
> 

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



[PHP] Detected a pattern that malfunctions includes

2006-10-06 Thread Deckard
Hi,

I see now that only when the inclu function "has to scale up in the we
tree", it fails.

For example:

This works:
include_once("classes/database/dBInsert.php");

This don't:
include_once('../adodb/adodb.inc.php');

Any ideas ?

Warm Regards,
Deckard

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



Re: [PHP] Re: Really strange / TYPO

2006-10-05 Thread Deckard
Hi Richard,

Thank you so much for your answer.

dbInsert.php is in /var/www/html/classes while config.inc.php is in
/var/www/html

With your code, the file is always searched in /var/www/html/classes and
not in /var/www/html

Warm Regards,
Deckard

Richard Lynch wrote:
> On Thu, October 5, 2006 2:34 am, John Wells wrote:
>> [code]
>> // Consider *where* you create this
>> // Define it as a constant if you'd like...
>> define('BASE_PATH', dirname(__FILE__));
>>
>> // Now build the path, like (assuming it was created
>> // in  a file located at /var/www/html
>> include_once(BASE_PATH . '/config.inc.php');
>> [/code]
> 
> Gah!
> 
> Now you've made it even HARDER to move the include files out of the
> web tree, or wherever is more convenient and safer.
> 
> include_path is a much more powerful and flexible construct which will
> save you an inordinate amount of trouble if you just figure out how it
> works and use it...
> 

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



Re: [PHP] See if this makes any sense / Att. Richard Lynch

2006-10-05 Thread Deckard
Hi Richard,

Richard Lynch wrote:
> I'm baffled why you'd be rolling your own instead of using an existing
> abstraction layer, and even more baffled why you wouldn't just skip
> all this and just do:
I'm already using AdoDB, which is excelent, but somethings requires a
lot of code.
I'm trying to wrote classe that allow me to reduce the code.

Richard: it's also a matter of learning something i don't know yet.

I consider myself as an expert in qmail servers.
If you go to the qmail mailing list, you'll see lots of responses from
me to other people.

That's what i'm seeking here: help. Not that someone do the my job for me.

Best Regards,
Deckard

> 
> $query = "insert ...";
> $insert = mysql_query($query, $connection);
> 
> It's not like you can take your MySQL user-creating queries and
> directly map them to ANY other database on the planet...
> 
> So what does the DB abstraction and class OOP stuff gain you?
> 
> Nada.
> 
> On Thu, October 5, 2006 2:18 pm, Deckard wrote:
>> Hi,
>>
>> I've burned my brain, checked other sites and come to a code that
>> works.
>>
>> I ask you, please, to see if this makes any sense and/or can be
>> improved.
>>
>> I'd really appreciate.
>>
>> Warm Regads,
>> Deckard
>>
>> dbInsert.php:
>> ---
>> >
>> /*
>> *class to make inserts
>> *
>> */
>>
>>
>>  // includes
>>  include_once('/var/www/html/config.inc.php');
>>  include_once('adodb/adodb.inc.php');
>>
>>  class dBInsert
>>  {
>>   // global variables
>>   var $table;
>>   var $sql;
>>
>>  // constructor
>>  function dBInsert($table, $sql)
>>  {
>>   $this->table = $table;
>>   $this->sql   = $sql;
>>
>>   return(TRUE);
>>  }
>>
>>
>>   // function that constructs the sql and inserts it into the database
>>   function InsertDB($table, $sql)
>>{
>>
>> print($sql);
>> // connect to MySQL
>> $conn = &ADONewConnection('mysql');
>>  $conn->debug=1;
>> $conn->PConnect('localhost', 'gamito', 'ble', 'wordlife');
>>
>>  // execute the insert
>>  if ($conn->Execute($sql) === false)
>>   print 'error inserting: '.$conn->ErrorMsg().'';
>>
>>  return (TRUE);
>>
>>}
>>
>> }
>>
>> ?>
>> --
>>
>> testedb.php
>> --
>> >
>>  include_once("classes/dBInsert.php");
>>
>>  $sql = "INSERT INTO wl_admins VALUES ('',3)";
>>  $dBInsert = new dBInsert('wl_admins', $sql);
>>  $dBInsert->InsertDB('wl_admins', $sql);
>>
>> ?>
>> --
>>
>> --
>> 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



[PHP] See if this makes any sense

2006-10-05 Thread Deckard
Hi,

I've burned my brain, checked other sites and come to a code that works.

I ask you, please, to see if this makes any sense and/or can be improved.

I'd really appreciate.

Warm Regads,
Deckard

dbInsert.php:
---
table = $table;
  $this->sql   = $sql;

  return(TRUE); 
 }


  // function that constructs the sql and inserts it into the database
  function InsertDB($table, $sql)
   {

print($sql);
// connect to MySQL
$conn = &ADONewConnection('mysql');
$conn->debug=1;
$conn->PConnect('localhost', 'gamito', 'ble', 'wordlife');

// execute the insert
if ($conn->Execute($sql) === false)
 print 'error inserting: '.$conn->ErrorMsg().'';

return (TRUE);

   }

}

?>
--

testedb.php
--
InsertDB('wl_admins', $sql);

?>
--

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



Re: [PHP] Re: Really strange / TYPO

2006-10-04 Thread Deckard
Yes, permissions are fine :(

Ben Ramsey wrote:
> On 10/4/06 9:14 PM, Deckard wrote:
>> It's a typo.
>> The file is really config.inc.php everywhere
> 
> Check the file permissions. Does the Webserver have permission to read
> from the /var/www/html (it probably does, but it wouldn't hurt to
> check)? Does the Web server have permission to read
> /var/www/html/config.inc.php? Do you happen to have PHP running in
> safe_mode? If so, is the owner of /var/www/html/classes/dBInsert.php the
> same owner of /var/www/html/config.inc.php?
> 
> These are just the things I can think of off the top of my head that
> would block your script from being able to include a file one directory
> above it.
> 
>>
>> Ben Ramsey wrote:
>>> On 10/4/06 8:32 PM, Deckard wrote:
>>>> Hi,
>>>>
>>>> I have this line of code:
>>>> include_once('../config.inc.php');
>>>>
>>>> I'm 100% sure that the file config.inc.php is a directory up.
>>>>
>>>> config.inc.php is in /var/www/html
>>>> and the file that calls it is in
>>>> /var/www/html/classes
>>>>
>>>> nevertheless, i'm getting the error:
>>>> "Warning: main(../config.inc): failed to open stream: No such file or
>>>> directory in /var/www/html/classes/dBInsert.php on line 10
>>>>
>>>> Warning: main(): Failed opening '../config.inc' for inclusion
>>>> (include_path='.:/usr/share/pear') in
>>>> /var/www/html/classes/dBInsert.php
>>>> on line 10"
>>> The first thing that jumps out at me is that your error says it failed
>>> to open ../config.inc, but you say the file is named config.inc.php.
>>> Check your code to ensure that you have:
>>>
>>> include_once('../config.inc.php');
>>>
>>> and not:
>>>
>>> include_once('../config.inc');
>>>
>>> If config.inc.php is the correct file you want to include and you're
>>> trying to include config.inc, then it obviously can't find it because it
>>> doesn't exist. :-)
>>>
> 
> 

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



[PHP] Help on objects

2006-10-04 Thread Deckard
Hi,

I'm trying to lay my hands on PHP OOP, but it's not easy :(
I've read several examples in the web, but cannot transpose to may case.

I'm trying to set a class to make SQL inserts in mysql.

I have the class:
-
table = $table;
  $this->sql   = $sql;

  return(TRUE); 
 }


  // function that constructs the sql and inserts it into the database
  function InsertDB($sql)
   {

print($sql);
// connect to MySQL
$conn->debug=1;
$conn = &ADONewConnection('mysql');
    $conn->PConnect('localhost', 'deckard', 'ble', 'wordlife');

if ($conn->Execute($sql) === false)
print 'error inserting: '.$conn->ErrorMsg().'';

return (TRUE);
   }
}


and the code that calls it:

InsertDB('$sql');

?>


but it's not working ?

Can anyone give me a hand here ?

I've read the manuals, examples, etc.

Any help would be appreciated.

Best Regards,
Deckard

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



Re: [PHP] Re: Really strange / TYPO

2006-10-04 Thread Deckard
Hi,

It's a typo.
The file is really config.inc.php everywhere

Regards,
Deckard

Ben Ramsey wrote:
> On 10/4/06 8:32 PM, Deckard wrote:
>> Hi,
>>
>> I have this line of code:
>> include_once('../config.inc.php');
>>
>> I'm 100% sure that the file config.inc.php is a directory up.
>>
>> config.inc.php is in /var/www/html
>> and the file that calls it is in
>> /var/www/html/classes
>>
>> nevertheless, i'm getting the error:
>> "Warning: main(../config.inc): failed to open stream: No such file or
>> directory in /var/www/html/classes/dBInsert.php on line 10
>>
>> Warning: main(): Failed opening '../config.inc' for inclusion
>> (include_path='.:/usr/share/pear') in /var/www/html/classes/dBInsert.php
>> on line 10"
> 
> The first thing that jumps out at me is that your error says it failed
> to open ../config.inc, but you say the file is named config.inc.php.
> Check your code to ensure that you have:
> 
> include_once('../config.inc.php');
> 
> and not:
> 
> include_once('../config.inc');
> 
> If config.inc.php is the correct file you want to include and you're
> trying to include config.inc, then it obviously can't find it because it
> doesn't exist. :-)
> 

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



[PHP] Really strange

2006-10-04 Thread Deckard
Hi,

I have this line of code:
include_once('../config.inc.php');

I'm 100% sure that the file config.inc.php is a directory up.

config.inc.php is in /var/www/html
and the file that calls it is in
/var/www/html/classes

nevertheless, i'm getting the error:
"Warning: main(../config.inc): failed to open stream: No such file or
directory in /var/www/html/classes/dBInsert.php on line 10

Warning: main(): Failed opening '../config.inc' for inclusion
(include_path='.:/usr/share/pear') in /var/www/html/classes/dBInsert.php
on line 10"

I'm boggled!

Any help would be appreciated.

Best Regards,
Deckard

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



Re: [PHP] Breaking lines - att. Richard Lynch

2006-10-03 Thread Deckard
Hi Richard,

Richard Lynch wrote:
> First, you're scaring the [bleep] out of me from a security standpoint
> writing mysql passwords into files...
I'm curious.
What would you do ?

No kidding intended. I'm serious.

Warm Regards,
Deckard

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



Re: [PHP] Breaking lines

2006-10-03 Thread Deckard
Hi Richard,

Richard Lynch wrote:
> First, you're scaring the [bleep] out of me from a security standpoint
> writing mysql passwords into files...
It's not that unusual.
It's a matter of securing the web server.


> If you are NOT an expert in this stuff, stop now, please...
I'me not an expert, but also not a nerd :)


> Next, you are missing the ';' at the end of each line to make valid
> PHP code.
I know. I missed it.

Best Regards,
Deckard

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



Re: [PHP] Breaking lines / STILL :(

2006-10-03 Thread Deckard
Hi,

Yes, it worked, but there's this strange thing.

The output of in to the file is:

$stringData = "";

is:



i. e., the variable $mysql_user_password within quotes is assuming its
value, not the string $mysql_user_password, while the others are ok.

*sigh*

Warm Regards,
Deckard


Brad Bonkoski wrote:
> Deckard wrote:
>> Hello,
>>
>> I have this code to write three lines in a file (config.php):
>>
>> $stringData = '$hostname = ' . $hostname . '\n' . '$mysql_username = ' .
>> $mysql_username . '\n' . '$mysql_user_password = ' .
>> $mysql_user_password . '\n';
>>
>> but instead of breaking a line, it appears in the file the string \n
>>
>> How can i make the line break ?
>>
>> Any help would be appreciated.
>>
>> Best Regards,
>> Deckard
>>
>>   
> 
> $stringData = '$hostname = ' . $hostname . "\n" . '$mysql_username = ' .
> $mysql_username . "\n" . '$mysql_user_password = ' .
> $mysql_user_password . "\n";
> 
> (double quotes around the \n character.)
> -B
> 

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



Re: [PHP] Breaking lines

2006-10-03 Thread Deckard
Hi

Yes, it worked, but there's this strange thing.

The output of in to the file is:

$stringData = "";

is:



i. e., the variable $mysql_user_password within quotes is assuming its
value, not the string $mysql_user_password, while the others are ok.

*sigh*

Warm Regards,
Deckard


Brad Bonkoski wrote:
> Deckard wrote:
>> Hello,
>>
>> I have this code to write three lines in a file (config.php):
>>
>> $stringData = '$hostname = ' . $hostname . '\n' . '$mysql_username = ' .
>> $mysql_username . '\n' . '$mysql_user_password = ' .
>> $mysql_user_password . '\n';
>>
>> but instead of breaking a line, it appears in the file the string \n
>>
>> How can i make the line break ?
>>
>> Any help would be appreciated.
>>
>> Best Regards,
>> Deckard
>>
>>   
> 
> $stringData = '$hostname = ' . $hostname . "\n" . '$mysql_username = ' .
> $mysql_username . "\n" . '$mysql_user_password = ' .
> $mysql_user_password . "\n";
> 
> (double quotes around the \n character.)
> -B
> 

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



Re: [PHP] Breaking lines / NEW

2006-10-03 Thread Deckard
Hi Brad,

Thanks a lot for your answer and the other guys too.
It worked.

Now i have another doubt:

$stringData = '';

The variables contents should be written in the files within quotes, like:

$mysql_username = 'deckard';

This is getting me nuts.

Any ideas ?

Warm Regards,
Deckard

Brad Bonkoski wrote:
> Deckard wrote:
>> Hello,
>>
>> I have this code to write three lines in a file (config.php):
>>
>> $stringData = '$hostname = ' . $hostname . '\n' . '$mysql_username = ' .
>> $mysql_username . '\n' . '$mysql_user_password = ' .
>> $mysql_user_password . '\n';
>>
>> but instead of breaking a line, it appears in the file the string \n
>>
>> How can i make the line break ?
>>
>> Any help would be appreciated.
>>
>> Best Regards,
>> Deckard
>>
>>   
> 
> $stringData = '$hostname = ' . $hostname . "\n" . '$mysql_username = ' .
> $mysql_username . "\n" . '$mysql_user_password = ' .
> $mysql_user_password . "\n";
> 
> (double quotes around the \n character.)
> -B
> 

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



[PHP] Breaking lines

2006-10-03 Thread Deckard
Hello,

I have this code to write three lines in a file (config.php):

$stringData = '$hostname = ' . $hostname . '\n' . '$mysql_username = ' .
$mysql_username . '\n' . '$mysql_user_password = ' .
$mysql_user_password . '\n';

but instead of breaking a line, it appears in the file the string \n

How can i make the line break ?

Any help would be appreciated.

Best Regards,
Deckard

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



[PHP] Breaking lines

2006-10-03 Thread Deckard
Hello,

I have this code to write three lines in a file (config.php):

$stringData = '$hostname = ' . $hostname . '\n' . '$mysql_username = ' .
$mysql_username . '\n' . '$mysql_user_password = ' .
$mysql_user_password . '\n';

but instead of breaking a line, it appears in the file the string \n

How can i make the line break ?

Any help would be appreciated.

Best Regards,
Deckard

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



[PHP] Breaking lines

2006-10-03 Thread Deckard
Hello,

I have this code to write three lines in a file (config.php):

$stringData = '$hostname = ' . $hostname . '\n' . '$mysql_username = ' .
$mysql_username . '\n' . '$mysql_user_password = ' .
$mysql_user_password . '\n';

but instead of breaking a line, it appears in the file the string \n

How can i make the line break ?

Any help would be appreciated.

Best Regards,
Deckard

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



[PHP] Strange error in PHP/MySQL

2006-10-01 Thread Deckard
Hello,

I have this code:

 // insert new user in mysql user table
  $sqlInsertUser = "INSERT INTO user (Host, User , Password ,
Select_priv, Insert_priv, Update_priv, Delete_priv) VALUES ('$hostname',
'$mysql_username', '$mysql_password', 'N', 'N', 'N', 'N')";

  if (mysql_query($sqlInsertUser, $conn))
   $messagesqlInsertUser = 'Success...';
  else
   $messagesqlInsertUser = 'Error: ' . mysql_error();
  $result = mysql_query($sqlInsertUser);

that gives me the error:
"Error: Duplicate entry 'localhost-' for key 1"

I can't see nothing wrong with it and if i run it in MySQL's prompt
everything's fine.

Any ideas ?

Besta Regards,
Deckard.

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



[PHP] Problems creating a user in MySQL

2006-10-01 Thread Deckard
Hello,


I have this code:
---
  // use mysql database
  mysql_select_db('mysql') or die('Cannot select MySQL database.' .
mysql_error());

  // insert new user in mysql user table
  $sqlInsertUser = "INSERT INTO user (Host, User , Password ,
Select_priv, Insert_priv, Update_priv, Delete_priv) VALUES ('$hostname',
'$mysql_username', '$mysql_password', 'N', 'N', 'N', 'N')";

  if (mysql_query($sqlInsertUser, $conn))
   $messagesqlInsertUser = 'Success...';
  else
   $messagesqlInsertUser = 'Error: ' . mysql_error();
  $result = mysql_query($sqlInsertUser);
---

that gives me the error:
---
Error: Duplicate entry 'localhost-gamito' for key 1
---

although the pair 'localhost-gamito' is not duplicated and i can be
assured os this, because it works perfectly well in the MySQL prompt.

Can someone help me, please ?

Best Regards,
Deckard

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



Re: [PHP] How to check if a session exists

2002-01-07 Thread Deckard Q.

if (session_is_registered("variable"))
{
...
}

- Original Message - 
From: "Alex Shi" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, December 20, 2001 11:34 PM
Subject: [PHP] How to check if a session exists


> If a sesson_id is known, how can check if the session exists?
> 
> Alex
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]