Re: [PHP] Problem with inserting values into database through php

2002-09-05 Thread Brad Bonkoski

The best way IMHO, to debug problems like this is to echo out your 
insert query to the screen and not actually run the query, or run it and 
make sure you use:
$sql = INSERT INTO employees (first,last,address,position) VALUES
('$first','$last','$address','$position');
$result = mysql_query($sql)
or die(Invalid query: $sql);

(This is always good practice anyways, especially if the page depends 
upon that query's execution)

Anyhow, echo out the query: $sql to the screen and then run it against 
your actual MySQL database and see how it responds?  Chances are there 
is some error there, and you'll get more meaningful feedback from the 
database backend.

HTH
-Brad

Olli Sinerma wrote:
 Hi,
 I´m having a weird problem with getting my forms work within
 php. I have a running MySQL server, php installed on a apache server
 and I can make SQL queries through php, but I´m unable to insert
 any data into it through forms.
 
 This is an example file that I´m using
 (it´s from
 http://hotwired.lycos.com/webmonkey/99/21/index3a_page4.html?tw=programming 
 )
 
 __
 
 html
 
 body
 
 
 
 ?php
 
 
 
 if ($submit) {
 
   // process form
 
   $db = mysql_connect(localhost, root, mypassword);
 
   mysql_select_db(mydb,$db);
 
   $sql = INSERT INTO employees (first,last,address,position) VALUES
 ('$first','$last','$address','$position');
 
   $result = mysql_query($sql);
 
   echo Thank you! Information entered.\n;
 
 } else{
 
 
 
   // display form
 
 
 
   ?
 
 
 
   form method=post action=?php echo $PHP_SELF?
 
   First name:input type=Text name=firstbr
 
   Last name:input type=Text name=lastbr
 
   Address:input type=Text name=addressbr
 
   Position:input type=Text name=positionbr
 
   input type=Submit name=submit value=Enter information
 
   /form
 
 
 
   ?php
 
 
 
 } // end if
 
 
 
 ?
 
 
 
 /body
 /html
 
 
 I have set the database in working order according to the manual, but after
 I enter some writing into the
 text fields and press submit: It refreshes the page and doesn't add any
 information into the db.
 
 I recon that the problem might be within the $php_self command, for I got
 all the previous php/mySQL tutorials
 working, but when this command appeared...problems started...or more
 accurate word would be: nothing
 happened.
 
 I have phpMyAdmin 2.3.0 running on my apache server and it can send/receive
 data from the db normally, so the problem shouldn't
 be in the db server or in the php, so it´s in me or in the code :) I have
 read through all the FAQ:s and manuals that I have found and I still
 can´t understand what is the problem in this one!
 
 -Olli
 
 
 
 
 



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




Re: [PHP] Re: HTTP_SERVER_VARS not working. Please help

2002-09-06 Thread Brad Bonkoski

that's: $_SEVER['HTTP_HOST']

Cirstoiu Aurel Sorin wrote:
 I also tried $_HTTP['HTTP_HOST']. Not working. The host has php 4.1.2
 version
 
 --
 
 Cirstoiu Aurel Sorin
 InterAKT Support
 
 http://www.interakt.ro
 
 Erwin [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 
Cirstoiu Aurel Sorin wrote:

I tried to use $HTTP_SERVER_VARS['HTTP_HOST'] but the result is null.
Is there an option so I can turn it on?

If PHP  4.1.0:
try $_SERVER['HTTP_HOST'] instead. You can also set register_globals = On
 
 in
 
the php.ini file (not recommended!)

HTH
Erwin


 
 
 
 



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




Re: [PHP] MySQL and Array's REALLY simple question but I'm notGETTING it .. Ugh..

2002-09-06 Thread Brad Bonkoski

Well, when you run the command:

$sql2_results = mysql_fetch_array($top_level);

The first time, it automatically increments the result...
so you fetch the data bu do nothing with it...
so when you get to your loop, you are already at the second entry in 
your database..

So, remove the first instance of that and see how it works..
HTH
-Brad

Steve Gaas wrote:

Can anyone tell me what's wrong with my code?  All I get output from this is
the LAST row of data from my Database.  There are 2 rows, how do I make it
pull data from all of the rows?  It's not going through the loop like it
should  I need to be able to tell the mysql_fetch_array which row I want
in each it iteration of the for loop.  The For loop increments counter, but
there is no syntax to add $counter to the result_type.  The same goes with
fetch_row...  

What am I forgetting!!??  I know it's something simple


***

$sql2 = mysql_connect(localhost, eweb, dbfun)
   or die(Could not connect BR);

mysql_select_db(actionregs, $sql2);

$top_level = mysql_query(SELECT * FROM williams, $sql2)
   or die(Could not do query BR);

$sql2_results = mysql_fetch_array($top_level);
$query_sql2_rows = mysql_num_rows($top_level);

echo $query_sql2_rows;
// echo's 2 rows

print table style=\font-family:Verdana; font-size:10pt\ border=0
cellpadding=4 width=90%;

print tr bgcolor=\#c0c0c0\th width=50Action ID/thth
width=100Owner/thth width=250Technology/ththSummary/th/tr;

for ($counter=0; $counter  $query_sql2_rows; $counter++) {
   $tabledata = mysql_fetch_array($top_level);
   echo td$tabledata[0]/td;
   echo td$tabledata[6]/td;
   echo td$tabledata[2]/td;
   echo td$tabledata[3]/td;
   echo /tr;
   }
print /table;

Thanks.



  




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




Re: [PHP] MySQL and Array's REALLY simple question but I'm not GETTING it .. Ugh..

2002-09-06 Thread Brad Bonkoski

It doesn't matter what variables you assign to fetch the data, one of 
the effects of mysql_fetch_array() is to increment the database result 
variable.  It does this without you even knowing it.  check out the 
mysql_data_seek() function to see how you can make the adjustments 
yourself.  i.e. mysql_data_seek($result, 0) would set you back at the 
beginning, record one.

-Brad

Steve Gaas wrote:
 OK, this works.. This is wonderful.. But I don't get it.. I assigned two
 separate variables to that array function..  I don't understand why this
 works now, but thanks a lot for the help. 
 
 I hope I don't inadvertently run into this again...
 
 -steve
 
 
 $sql2 = mysql_connect(localhost, eweb, dbfun)
   or die(Could not connect using default username and password LINE
 14 BR);
 
 mysql_select_db(actionregs, $sql2);
 
 $top_level = mysql_query(SELECT * FROM williams, $sql2)
   or die(Could not do query sql1 to find username. Link might not
 have been made. What's up? LINE 19 BR);
 
 // $sql2_results = mysql_fetch_array($top_level);
 $query_sql2_rows = mysql_num_rows($top_level);
 $rows = 0;
 echo $query_sql2_rows;
 
 
 print table style=\font-family:Verdana; font-size:10pt\ border=0
 cellpadding=4 width=90%;
 print tr bgcolor=\#c0c0c0\th width=50Action ID/thth
 width=100Owner/thth width=250Technology/ththSummary/th/tr;
 
 for ($counter=0; $counter  $query_sql2_rows; $counter++) {
   $tabledata = mysql_fetch_array($top_level);
   echo td$tabledata[0]/td;
   echo td$tabledata[6]/td;
   echo td$tabledata[2]/td;
   echo td$tabledata[3]/td;
   echo /tr;
   }
 print /table;
 -Original Message-
 From: Brad Bonkoski [mailto:[EMAIL PROTECTED]] 
 Sent: Friday, September 06, 2002 3:34 PM
 To: Steve Gaas
 Cc: [EMAIL PROTECTED]
 Subject: Re: [PHP] MySQL and Array's REALLY simple question but I'm not
 GETTING it .. Ugh..
 
 Well, when you run the command:
 
 $sql2_results = mysql_fetch_array($top_level);
 
 The first time, it automatically increments the result...
 so you fetch the data bu do nothing with it...
 so when you get to your loop, you are already at the second entry in 
 your database..
 
 So, remove the first instance of that and see how it works..
 HTH
 -Brad
 
 Steve Gaas wrote:
 
 
Can anyone tell me what's wrong with my code?  All I get output from this
 
 is
 
the LAST row of data from my Database.  There are 2 rows, how do I make it
pull data from all of the rows?  It's not going through the loop like it
should  I need to be able to tell the mysql_fetch_array which row I
 
 want
 
in each it iteration of the for loop.  The For loop increments counter, but
there is no syntax to add $counter to the result_type.  The same goes with
fetch_row...  

What am I forgetting!!??  I know it's something simple


***

$sql2 = mysql_connect(localhost, eweb, dbfun)
  or die(Could not connect BR);

mysql_select_db(actionregs, $sql2);

$top_level = mysql_query(SELECT * FROM williams, $sql2)
  or die(Could not do query BR);

$sql2_results = mysql_fetch_array($top_level);
$query_sql2_rows = mysql_num_rows($top_level);

echo $query_sql2_rows;
// echo's 2 rows

print table style=\font-family:Verdana; font-size:10pt\ border=0
cellpadding=4 width=90%;

print tr bgcolor=\#c0c0c0\th width=50Action ID/thth
width=100Owner/thth width=250Technology/ththSummary/th/tr;

for ($counter=0; $counter  $query_sql2_rows; $counter++) {
  $tabledata = mysql_fetch_array($top_level);
  echo td$tabledata[0]/td;
  echo td$tabledata[6]/td;
  echo td$tabledata[2]/td;
  echo td$tabledata[3]/td;
  echo /tr;
  }
print /table;

Thanks.



 

 
 
 



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




Re: [PHP] How to set the file premission by using CHMOD?

2002-09-07 Thread Brad Bonkoski

man chown
(change ownership) (i.e. chown my_username:my_groupname directory)
-or-
man chmod
(change permissions)(i.e. chmod uga+w file_name -or- chown 4777 
file_name)

-Brad

Bryan wrote:
 Situation:
 I want to create a file to a directory, but the premission denied, how to
 solve this problem by using CHMOD?
 
 Bryan
 
 
 



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




Re: [PHP] How to do pass on information...

2002-09-07 Thread Brad Bonkoski

Can't you make a form?
Lets say you have a lexical database for categories like:
IDNAME
1 Anime
2 Action
etc...

then in the form so:
select name='cat'
?php
$query = select * from categories;
$result = run_query($query);
while($row = fetch_array($result)
{
echo option value=$row[0]$row[1]/option;
}
free_result($result)
?
/select

This would send to the form action page the numerical representation of 
the categoried selected from the drop down list.

-Brad

Chuck PUP Payne wrote:
 Hi,
 
 I would like to know if there is a way that I can pass on an information
 from a pull down menu into a sql query. Right now I have to right a PHP page
 for each piece I am wanting to pass on. Example I have a movie database and
 now if I want to see what is in my Anime Category that starts with A I
 have to create a page like this:
 
 Select * FROM database WHERE category = 'anime' AND title like 'A%'
 
 I know I have to do an array? Would it be like this?
 
 $category 
 $letter 
 
 Select * FROM database WHERE category = '$category' and title is like
 '$letter'
 
 But it get to the sql statement is where I am lost.
 
 Chuck Payne
 Magi Design and Support
 
 



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




Re: [PHP] Calling info from mySQL inside flash

2002-09-08 Thread Brad Bonkoski

How about giving this page a look over:
http://www.macromedia.com/desdev/topics/php.html

Here's an article especially for using PHP and MySQL with Flash MX
http://www.macromedia.com/desdev/mx/flash/articles/flashmx_php.html

HTH
-Brad

Thomas Edison Jr. wrote:
 
 I have a mySQL db, and a bunch of tables in it.
 What i want to do, is to pick up some data, and
 display in my Flash Movie.
 
 For example. I have a table with a list. Now on my
 main page, i display the total number of people in the
 list so far (By counting the rows). Now i want to
 display the same in my Flash movie.
 
 How can we exactly insert PHP Coding inside Flash
 Movie to make the code work? Any tips...
 
 Thanks,
 T. Edison Jr.
 
 __
 Do You Yahoo!?
 Yahoo! Finance - Get real-time stock quotes
 http://finance.yahoo.com
 
 --
 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] turn register_globals on

2002-09-08 Thread Brad Bonkoski

I think it is a global configuration setting, so it would not be
possible to turn it off for an individual script.

Just use the $_SERVER['variable_name'] 

-Brad

Anup wrote:
 
 Hello I am working on a PHP server which has register_globals off. In my
 script is there anyway to turn it on, just for my script?
 
 --
 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] Troubles Inserting into MYSQL

2002-09-08 Thread Brad Bonkoski

Shoudn't it be:

if ($update_type == update_Williams) {
mysql_query(INSERT INTO events_Williams ('user', 'detaildesc', 'index',
'reference', 'date_added') VALUES
('$cookiewho','$add_Williams','','$row_num','$last_update'), $sql4)
or print mysql_error();
}
You need the '(' and ')' in your query to group VALUES

(And what's with all the escaping with '\'?  They don't appear to be
needed and make it look very cluttered, i.e. not very readable.

HTH
-Brad

Steve Gaas wrote:
 
 This syntax fixes the syntax error..
 
 if ($update_type == update_Williams) {
 mysql_query(INSERT INTO events_Williams ('user', 'detaildesc', 'index',
 'reference', 'date_added') VALUES \'$cookiewho\',
 \'$add_Williams\',\'\',\'$row_num\',\'$last_update\', $sql4)
 or print mysql_error();
 }
 
 this is the output
 You have an error in your SQL syntax near ''user', 'detaildesc', 'index',
 'reference', 'date_added') VALUES \'sgaas-wil\', ' at line 1
 
 Steve Gaas
 Sr. Systems Engineer, Carrier Markets
 Riverstone Networks
 972.668.8329 (follow-me)
 877.713.7063 (pager analog dial)
 [EMAIL PROTECTED] (interactive pager)
 
 http://www.rstn.net / Nasdaq: RSTN
 
 Wisdom begins in wonder.   -Socrates
 
 -Original Message-
 From: Steve Gaas
 Sent: Sunday, September 08, 2002 2:26 PM
 To: 'Paul Nicholson'; Steve Gaas; [EMAIL PROTECTED]
 Subject: RE: [PHP] Troubles Inserting into MYSQL
 
 Parse error: parse error, unexpected T_ECHO in
 /var/www/html/actionreg/doupdate.php on line 24
 
 Forgot I had that function..  I don't understand the error though..
 
 Steve Gaas
 Sr. Systems Engineer, Carrier Markets
 Riverstone Networks
 972.668.8329 (follow-me)
 877.713.7063 (pager analog dial)
 [EMAIL PROTECTED] (interactive pager)
 
 http://www.rstn.net / Nasdaq: RSTN
 
 Wisdom begins in wonder.   -Socrates
 
 -Original Message-
 From: Paul Nicholson [mailto:[EMAIL PROTECTED]]
 Sent: Sunday, September 08, 2002 2:21 PM
 To: Steve Gaas; [EMAIL PROTECTED]
 Subject: Re: [PHP] Troubles Inserting into MYSQL
 
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1
 
 Hey,
 Send the results of mysql_errno() please. :)
 ~Pauly
 
 if ($update_type == update_Williams) {
 mysql_query(INSERT INTO events ('user', 'detaildesc', 'index',
 'reference', 'date_added') VALUES (\'$cookiewho\',
 \'$add_Williams\',\'\',\'$row_num\',\'$last_update\'), $sql4)
 or echo mysql_errno()/*die (could not do update)*/;
 }
 
 On Sunday 08 September 2002 03:07 pm, you wrote:
  Hello,
 
  My code below always dies!  I've tried just about every iteration of the
  values, etc..  Can anybody show me how to insert into MySQL a value?
 
  INSERT INTO events ('user','detaildesc') VALUES ('$user','$details')
 
  I just don't get it!
 
 
  if ($update_type == update_Williams) {
  mysql_query(INSERT INTO events ('user', 'detaildesc', 'index',
  'reference', 'date_added') VALUES (\'$cookiewho\',
  \'$add_Williams\',\'\',\'$row_num\',\'$last_update\'), $sql4)
or die (could not do update);
}
 
 - --
 ~Paul Nicholson
 Design Specialist @ WebPower Design
 The webthe way you want it!
 [EMAIL PROTECTED]
 
 It said uses Windows 98 or better, so I loaded Linux!
 Registered Linux User #183202 using Register Linux System # 81891
 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1.0.6 (GNU/Linux)
 Comment: For info see http://www.gnupg.org
 
 iD8DBQE9e6McDyXNIUN3+UQRAriZAKCTPYsBfypW7N6k8vpG+UDJEZ77BQCfVtEi
 BmSkmFZDBbXuAm+g3nvw/tc=
 =InFX
 -END PGP SIGNATURE-
 
   
 --
 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: turn register_globals on

2002-09-08 Thread Brad Bonkoski

Does this work for the original poster?

Does not work for me (of course I am going the opposite way, wanting to
test scripts one-by-one to verify they work with register_globals off)
running: ini_set(register_globals, 0);
(and, tried both) ini_set(register_globals, Off);

According to the docs it says:
register_globals   0PHP_INI_PERDIR|PHP_INI_SYSTEM
Stating that this variable can only be changed in .htaccess, or php.ini

It does seem to return the correct value, but it does not make the same
changes to my script that setting this value to Off in php.ini does.

So, is this allowable to set in user scripts?  Or is the dosumentation
correct in saying it cannot?
-Brad


Jome wrote:
 
  Hello I am working on a PHP server which has register_globals off. In my
  script is there anyway to turn it on, just for my script?
 
 ini_set(register_globals, 1); at the top of your script.
 
   Jome
 
 --
 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] installing php-4.2.3

2002-09-11 Thread Brad Bonkoski

unzip that and cd into it and read the INSTALL file
tar -xzvf php-4.2.3.tar.gz
cd php-4.2.3
less INSTALL

HTH
-Brad

Anil Garg wrote:
 
 hi,
 
 i am a newbie to php...
 i have downloaded php-4.2.3.tar.gz from http://www.php.net/downloads.php
 can someone please point me to the right documentaion from where i can know
 what to do next..
  I am using FreeBSD-4.2.
 
 thanx and regards
 anil
 
 --
 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: Extracting Numbers from a string.

2002-09-11 Thread Brad Bonkoski

Of course they may not always know that the user would insert a '$' or a
'.' which is what you are keying off of.  I am not all that familiar
with ereg* functions, I might attack it with stepping through charater
by charater and is is_numeric($c) returns true, place it applend it to
another variable, which at the end would have strictly the numbers...
That would be my initial approach, but I'm sure there are many,many
others...
-Brad

M1tch wrote:
 
 it doesn't use ereg, but it (should) would work:
 
 $mystring = I have $56.55 dollars, don't you know;
 $mystring = substr($mystring, strpos($mystring, $));//strip out after
 the $ sign
 $mystring = substr($mystring, 0, strpos($mystring,  ));//keep only
 till first space
 
 //mystring now contains $56.55
 if you want it split into two variables, of '$56', and '55' use:
 $a = explode(., $mystring);
 //$a[0'] = $56
 //$a[1] = 55
 
 (by the way, there may be functions that work better than using the
 substr+strpos functions, I just can't remember off the top of my head!)
 
 Of course, ereg might well work better!
 
 Jason Caldwell [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  I need to extract the numbers only from a field.
 
  For example:  I have an AMOUNT field and so that I can filter out any user
  typo's I would like to extract the numbers only.
 
  If the user enters $56.55 for example or just $56 then I would like to be
  able to remove the $ and the . keeping just the 56 or 5655.
 
  Can I use eregi_replace() to do this -- I've been trying but it doesn't
 seem
  to work right.
 
  Thanks.
  Jason
 
 
 
 --
 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] fopen()

2002-09-19 Thread Brad Bonkoski

I would say that is the best way, or if you have other information
there, write to abother directory that is owned by apache

-Brad

Donahue Ben wrote:

 I have a php script that tries to write files in a
 particular directory.  When the script writes files
 the ownership is apache.  The problem I have is the
 particular directory that the script is trying to
 create files in, it cannot, because it does not own
 that directory and it is not part of the group.  So is
 the only way to get around this problem is by changing
 the ownership of the directory to apache?

 Ben

 __
 Do you Yahoo!?
 New DSL Internet Access from SBC  Yahoo!
 http://sbc.yahoo.com

 --
 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] Editor

2002-09-21 Thread Brad Bonkoski

I like textpad, because it will write files in a Unix friendly way, i.e. none of that 
annoying ^M at the
end of lines! :-)

Bryan McLemore wrote:

 Hi guys, just wondering if anyone could recomend a good editor that is based on 
windows.  Thanks, Bryan


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




Re: [PHP] Encrypted MySQL passwords

2002-09-26 Thread Brad Bonkoski

There are common one-way encryption, like md5, this is commonly what I do, I
encrypt with md5 when I insert the password into my database on the DB
server, and then I encrypt with PHP on the Web server side, so therefore, I
am only ever sending my md5 encrypted password over the wire.  Since it is
the same every time it is like doing string compares on the same encrypted
value so it authenticates, of course this is also the vulnerability of md5.
I suppose that with cracking software and time, someone could get it, but it
also might be better then sending it in the clear.

-Brad

Adam Voigt wrote:

 Maybe you could somehow setup your SSH tunnel before-hand
 (at server start up or something) and use that instead.

 Adam Voigt
 [EMAIL PROTECTED]

 On Thu, 2002-09-26 at 12:40, John Holmes wrote:
   I am connecting to  a mysql server on a remote machine, and opened up
  port
   3306 for this purpose. But, I am concerned about sending a clear text
   password, via the mysql_pconnect() call. My question is, what is the
   procedure for connecting to a remote server with an encrypted
  password?
   Or, does mysql_pconnect handle this?
 
  Nope, it's all in the clear. MySQL 4.0 has support for doing this over
  SSL, I think.
 
  ---John Holmes...
 
 
  --
  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 General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Assigning data to fields

2002-09-27 Thread Brad Bonkoski

I think this should be a good reference for you:
http://www.php.net/manual/en/function.mysql-fetch-array.php

HTH
-Brad

Ken wrote:

 I am kind of new to PHP. I know how to use a select statement and a query to
 get data out of a table in MySQL, but how do I assign those fields to
 variables? I know this must be easy! Thanks in advance!!

 --
 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] Edinburgh, Scotland: PHP Developer Position

2007-06-18 Thread Brad Bonkoski

Jochem Maas wrote:

Edward Kay wrote:

...

  

But the advert is for a GRADUATE developer ;) Whilst your messages to this
list show you know a lot about PHP, I doubt you've managed to fit a degree
in yet :)



What does a graduate php developer earn in Scotland? and is it
the the piece of paper that's important or is it a reference to the
general skill level (personally I don't see much direct corellation
between academic capabilities and practical coding/sysadmin skill).

just thinking out loud guys :-)

  
This is always beat around...and my 2 cents are that all the piece of 
paper is worth is showing you have a certain level of commitment needed 
to complete the degree program (important for any job), and that you 
have the ability to learn.  Granted...there are always exceptions to the 
rule...


Plus, at least in the US, it [a degree] always opens the door for more 
money! ;-)



Edward




  


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



Re: [PHP] subtracting time from date and time

2007-06-18 Thread Brad Bonkoski
Something like this will get it into a time stamp...and then you can do 
your calculations with ease, and reformat...

?php
   $str = 20070617T193500;
   list($date, $time) = explode(T,$str);

   $year = substr($date, 0, 4);
   $mon = substr($date, 4, 2);
   $day = substr($date, 6,2);
   echo $year - $mon - $day\n;

   $h = substr($time, 0, 2);
   $m = substr($time, 2, 2);
   $s = substr($time, 4,2);
   echo $h : $m: $s\n;

   $ts = mktime($h,$m,$s,$mon,$day,$year);
?

-Brad

Richard Kurth wrote:

I am trying to figure out what is the most accurate way to find the time
after I subtract 5 min,15 min, 30 min 1 hour 2 hours and 5 hours from a date
and time that is formatted like this 
20070617T193500 this is the way it has to be formatted to work in a

vcalendar
 
 
 

  


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



Re: [PHP] best technique to get the ID of the last inserted value

2007-07-20 Thread Brad Bonkoski

One easy solution would be to get the ID before you do the insert
i.e. in Oracle you would run the query:
select some_id_generating_seq.nextval from dual

and then you would use that id to insert and you would know the id after 
that...and the DB would take care of locking and such.
So, check the help pages for your DB of choice to see what support they 
have for something like that.


-B

Marcelo Wolfgang wrote:

Hi all,

I'm a newbie in PHP, and I want to know what's the best technique you 
guys use when you need to get the id of the last inserted value in the 
database.


My first thought is to do a SELECT on the db and get the last id, but 
I know that if I have two almost simultaneous connections I may get 
the wrong one, so that's the why of my question.


TIA
Marcelo Wolfgang



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



Re: [PHP] I'm prepared to feel like an idiot... But I just simply need the answer :)

2007-08-01 Thread Brad Bonkoski
I would start with suppling the entire path of for php in the cron.  The 
path in the cron environment may be vastly different then the path in 
your shell environment...

so: /path/to/php file.php
See how that works for you, of course I am assuming it runs fine from 
your command line...

-B

Jason Pruim wrote:

Hi All :)

I have a php script that I am attempting to run from the CLI to 
connect to a MySQL database and update a field. but when I run it with 
this command: php cronjob.php it prints out the script on screen but 
doesn't process it...


Running: php-rphpinfo(); prints out the standard phpinfo screen.. 
and I don't think I should have to write it differently to make it run 
from the command line right?


HELP! I'm desperate... I would offer to name my first born after 
you... But he's already been born :)



--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]





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



Re: [PHP] I'm prepared to feel like an idiot... But I just simply need the answer :)

2007-08-01 Thread Brad Bonkoski

Brad Bonkoski wrote:

Jason Pruim wrote:


On Aug 1, 2007, at 9:55 AM, Michael Preslar wrote:


@mysql_connect('localhost', 'user', 'password') or die(Cannot
connect to DB! . mysql_error());

..

cannot connect to DB!Can't connect to local MySQL server through
socket '/var/mysql/mysql.sock' (2)qs:/volumes/raider/webserver/
documents/tests/ticklers japruim$


MySQL is running right? (I know, silly question, but have to make sure)

If it is.. grep sock /etc/my.ini .. Bet the socket file its creating
is in /tmp or /var/lib/mysql


Okay, so the command didn't work.. couldn't find my.ini... But I just 
cd'ed into /tmp and there is a file mysql.sock in there... Do I need 
to move that somewhere else? I realize that this is starting to get 
off topic for this list... So Maybe I should take this to a mysql 
list since it looks like php isn't at fault?



I *think* the mysql config file is named: my.cnf
so run a slocate or find on your system to see where it is and look at 
the line:
socket  = 
/var/run/mysqld/mysqld.sock


You can also go into your php.ini file and check out the line:
mysql.default_socket =
and perhaps setting that to where it is located in your /tmp directory 
will do the trick...


-B


As a quick follow up...
the command:
$ php -i | grep mysql

will spit out info on how php thinks mysql is set up currently...
one of the items is:
MYSQL_SOCKET = ...
So just make sure that is in tune with where the socket really is running
-B



--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]

--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] I'm prepared to feel like an idiot... But I just simply need the answer :)

2007-08-01 Thread Brad Bonkoski

Jason Pruim wrote:


On Aug 1, 2007, at 9:55 AM, Michael Preslar wrote:


@mysql_connect('localhost', 'user', 'password') or die(Cannot
connect to DB! . mysql_error());

..

cannot connect to DB!Can't connect to local MySQL server through
socket '/var/mysql/mysql.sock' (2)qs:/volumes/raider/webserver/
documents/tests/ticklers japruim$


MySQL is running right? (I know, silly question, but have to make sure)

If it is.. grep sock /etc/my.ini .. Bet the socket file its creating
is in /tmp or /var/lib/mysql


Okay, so the command didn't work.. couldn't find my.ini... But I just 
cd'ed into /tmp and there is a file mysql.sock in there... Do I need 
to move that somewhere else? I realize that this is starting to get 
off topic for this list... So Maybe I should take this to a mysql list 
since it looks like php isn't at fault?



I *think* the mysql config file is named: my.cnf
so run a slocate or find on your system to see where it is and look at 
the line:
socket  = 
/var/run/mysqld/mysqld.sock


You can also go into your php.ini file and check out the line:
mysql.default_socket =
and perhaps setting that to where it is located in your /tmp directory 
will do the trick...


-B




--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]

--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] Question about passing date in sql...

2007-08-01 Thread Brad Bonkoski

Payne wrote:

Guys,

Got a quick question.  I got a sql statement works when I pass it from 
the cli. but if I try in php I get nothing.


This is the statement.

Select ip, date, time, CONCAT(city, ', ',country) as location from ips 
where country !=' ' and date='`date +%Y%m%d`' order by country asc;


I know it has to do with date='`date +%Y%m%d`', because if I remove it 
works.


Any clue as to why?

Payne


why not use the PHP function to format the date?

http://www.php.net/date
-B

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



Re: [PHP] Numbers, Numbers everywhere! Need some Dollar help.

2007-08-02 Thread Brad Bonkoski

Dan Shirah wrote:

Greetins all,

In my form I have an area where the user enters in the payment amount:

input type=Text value= size=20 maxlength=16 name=payment_amount

This is all fine and dandy and works as generically as it can. BUT, the
problem is that I need to make sure the user didn't fat finger any of the
numbers.  For instance, in my generic text field the user types 600 in the
payment amount and clicks submit.

This works and the user is charged $600.  But, come to find out the user
meant to enter 6.00 not 600. Can I add a check using PHP to force the user
to put in the dollar AND cents? This way if a number such as 600 is entered
and the user hits save, the check will notice there isn't a .00 on the end
and prompt the user for more information.

Could I incorporate something like:

if ($payment_amount != number_format($payment_amount, 2)) {
  error here
}

Or, do you think I would be better off using two text areas?  One for the
dollar value and one for the cents?

Or, do you think I would be better off trying to find some kind of
javascript function that would check the value upon submit?

Any help is appreciated.

Dan

  
If you want it squarely on the client side, then use javascript.  There 
are easy functions to split a text string (like php's explode).
Then you can split on the '.' and then do some logical stuff like the 
cents is between 00 and 99, and anything else you think necessary.
If there are no cents, then you can issue a confirmation box.  So, my 
vote is to handle it within javascript, as it should not be too difficult.

-B

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



Re: [PHP] adding Back to Search results link

2007-08-15 Thread Brad Bonkoski

Something like this might work:
a href=javascript:history.go(-1)
(To go back 1 page)
Of course if this is a form post, it would repost the data resulting in 
that annoying pop-up on most browsers indicating the page is being 
re-posted.


Maybe you could write out the post variables to the session variables, 
and have your page 2 look for the $_POST and $_SESSION for the variables 
in question...


-B

Derek Moon wrote:

I am trying to imporve a web application that my group uses.

Basically there are 3 forms that work together Form 1  form 2

Form 1 - searchs for enterend values
Form 2 - returns search results, letting you individually select any item
Form 3 - lets you edit a specific individual item

I want to make a link on the Form 3 that returns you to form Form 2
basically a Back to Search results link.

I'm thinking that there is a way to pass the query string, but I am a newbie 
and I'm not sure that I am going about this the right way.


Anyone have any advice or knowledge to share? 

  


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



Re: [PHP] Silly varible question

2006-07-13 Thread Brad Bonkoski

Why not just have another array...

$bag = array();
$item[] 

array_push($bag, $item);

then store the bag in the session.
so, you would have count($bag) items in your shopping cart, and you 
would be able to easily access them.

Just a thought, instead of munging variable names.

-B

Ed Curtis wrote:


I know this is probably simple as all get out but it's early and I can't
find an answer anywhere after searching for a while


I need to assign a number to a variable and then use that variable in a
session to store an array. It's for a shopping cart system I'm building.

What I've got is:

$count = 1; //First item in the cart passed from form to form

$item = array();

$item[] = $_POST['phone'];
$item[] = $_POST['category'];
$item[]  = $_POST['copy'];
$item[] = $_POST['pic_style'];
$item[] = $cost;
$item[] = $image;

session_register('item');

In the session the item is known as 'item'. What I need for it to be is
'item1' so when the customer chooses another product I can increase $count
by 1 and have the next array with values stored as 'item2'.

Thanks for any help,

Ed

 



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



[PHP] Error Loading php module

2006-07-31 Thread Brad Bonkoski

Any insights or tips into this?

httpd: Syntax error on line 232 of /home/www/conf/httpd.conf: Cannot 
load /home/www/modules/libphp5.so into server: 
/home/www/modules/libphp5.so: undefined symbol: _pcre_ucp_findprop


TIA.
-Brad

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



Re: [PHP] Dynamically assigning var namesi

2006-08-01 Thread Brad Bonkoski

Hi Bob,

Based on what you said, I would say the normal coding way of handling 
this is with an array.
If you are unfamiliar with them, www.php.net/array would be a good place 
to start.

-Brad

bob pilly wrote:

Hi all

Does anyone know if you can assign a new variable name based on the contents of 
another variable in PHP? If so whats the syntax to do this?

 I am parsing a text file that has tens of preset attributes and some of these 
have hundreds of sub attributes. For example the text file contains flight 
details, on every flight there can be up to 500 passengers but there are 
generally only 50 so i dont want to have declare 500 vars when i hardly ever 
use them. What i am trying to do is count the amount of pasengers present and 
dynamically create the variables based on this.$surname1,$surname2 etc...

 Im not sure whether this is a sane way to approach this problem or not. Any 
advice or pointing to relevant documentation about either syntax for this or 
ways of tackling this sort of problem (im sure it must be a regular occurance 
in the coding world??) would be greatly appreciated!!

Thanks in advance for any help or advice.

Cheers

Bob


-
 All new Yahoo! Mail The new Interface is stunning in its simplicity and ease of 
use. - PC Magazine
  


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



Re: [PHP] Documentation of PHP sourcecode

2006-08-02 Thread Brad Bonkoski

www.phpdoc.org
similar to javadocs, and works pretty well.
-Brad

Paul Zwiers wrote:

Dear all,

With a growing base of previous PHP work (not to be be mistaken for a 
framework :) ) I also find myself recoding and reinventing the wheel. 
Something I really do not want to do.


I am looking in some possibilities for automatically documenting my functions 
and classes. Preferably with some markup in the sourcecode and easy to 
implement. I am running Linux on my desktop so w* stuff won't do it for me :)


Can anyone point me in the right direction?

Thanks in advance!

  


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



Re: [PHP] writing to fild on another server

2006-08-04 Thread Brad Bonkoski



blackwater dev wrote:

I have a web server and an images server.  My web server doesn't have
enought space for the images, hence the images server.  I have to 
download
properties from a realty database hourly and the data goes in to a db 
on my
webserver while the image needs to be taken from a MSSQL db and 
written to
the images server as an actual .jpg or .gif file.  Fopen, however, 
won't let

me write using the http protocol.  How can I open and write files between
servers?

Thanks!


Couple of options come to mind, and I'm sure there are many others...

Option 1: nfs mount / share your partition drive(s) on your web server.
Option 2: Write the files out locally and then have a backend process 
that moves them to the image server.


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



Re: [PHP] I only want x number of lines of data

2006-08-09 Thread Brad Bonkoski



Ross wrote:

At the mometn I have this


function display_result($module_no) {

  

   $count = 0; //Of course you *should* initialize $count
   $start = 1;
   $end = 3;

if ($module_no != ) {
$module_no =unserialize ($module_no);
foreach ($module_no as $number = $data) {

$count=$count+1;

  

   if( $count = $start  $count = $end ) { ?

Q.?=$count; ?- span style=font-weight:bold?=$data;?/spanBR /
  
?
  

   }

}
  
}


which outputs all the data in the array..typically..

Q.1- pass
Q.2- pass
Q.3- pass
Q.4- pass
Q.5- pass


but what if i only want q1-q3 output? any ideas how I can modify the script 
to give me x number of outputted answers? 

  


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



Re: [PHP] Best way to get PHP5

2006-08-09 Thread Brad Bonkoski



Chris W. Parker wrote:

Hello,

Generally (well, actually 100%) I just use whatever version of PHP is
included with a certain distro (Redhat pre-Fedora, Fedora Core, CentOS).
None of the versions I've used have come with PHP5 and I'd really like
to get with the times and use PHP5.

I know that Fedora Core 5 offers PHP 5.1.2 but I've heard some negative
things about it in general (FC5).

I've never compiled PHP myself so admittedly I'm a bit skeered... Is the
recommended path to just go with whatever distro I prefer and then
download PHP5 from php.net and install it myself?



Thanks,
Chris.
  
Build PHP from sourceno reason to be scared, it really is quite 
painless, and the docs are fairly easy to follow.
(and I *believe* php 5.1.2 has some security issues, as well as none of 
the nice updates for the Oracle driver if you are using Oracle, so go 
with 5.1.4)


-Brad

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



Re: [PHP] calendar Q

2006-08-10 Thread Brad Bonkoski

Really depends on how you display the calendar...
if you go day by day building the table cells, then it should be easy 
enough because you should already have the date you are working with...
so a query like select count(*) from events where date='date' and if 
count is  0 then display it differently.
On the other hand if you are using pre-canned functions to dump out the 
entire month, then it would prove more difficult.


-B

William Stokes wrote:

Hello,

I have a calendar script that displays a simple mini calendar view one month 
at a time. User can click any date and the calendar opens another page that 
displays that date's events. I would like to highlight to the mini calendar 
view dates that have an event in database. So what would be a simple way to 
check for events while the selected months days are printed to screen?


Thanks
-Will 

  


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



[PHP] Capturing System output

2006-08-15 Thread Brad Bonkoski

Hello All..

Had this problem in the past, and always programmed around it, but 
wondering if there is an easier way.


Good Example:
Creating a setup for connecting to a mysql database.  Want to do 
something simple to make sure they have entered a valid 
username/password for the database.

So, the idea is something like:
$rc = exec(mysql -u $user -p{$pass}, $output);
The problem is one error, the stderr does not go to the output array, 
but rather to the screen.


Previously I would redirect the stderr to a file, and then evaluate the 
contents of the file, but is there an easier way to get this into the 
PHP variable with no risk of having the output make it through to the 
screen?


Thanks
-Brad

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



Re: [PHP] Capturing System output

2006-08-15 Thread Brad Bonkoski



Stut wrote:

Brad Bonkoski wrote:
Had this problem in the past, and always programmed around it, but 
wondering if there is an easier way.


Good Example:
Creating a setup for connecting to a mysql database.  Want to do 
something simple to make sure they have entered a valid 
username/password for the database.

So, the idea is something like:
$rc = exec(mysql -u $user -p{$pass}, $output);
The problem is one error, the stderr does not go to the output array, 
but rather to the screen.


Previously I would redirect the stderr to a file, and then evaluate 
the contents of the file, but is there an easier way to get this into 
the PHP variable with no risk of having the output make it through to 
the screen?


I may be missing something, but why in the name of all that is holy 
would you want to shell out to try connecting to mysql? Why not use 
mysql_connect and avoid the potentially massive security hole you're 
building?


-Stut

Perhaps poor illustration of the question...the question being how to 
issue system like commands in PHP which would allow you to trap not only 
stdout, but also stderr.

-Brad

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



Re: [PHP] Setting flags versus checking for existing/nonexisting values

2006-08-15 Thread Brad Bonkoski



Chris W. Parker wrote:

Hello,

Is it a better practice to set flags to determine the action of your
code or is it perfectly acceptable to have your code determine what it
should do based on the existence (or lack thereof) of data?

For example:

?php

if($value == 1)
{
$flag = true;
}

if($flag === true)
{
echo I wish I could come to the PHP meetup in Chicago! :(;
}

?

versus:

?php

if($value == 1)
{
echo I wish I could come to the PHP meetup in Chicago! :(;
}

?

Of course this is an overly simplistic example but you get the idea.

Are there pros and cons to both sides or should I just avoid the latter
example all together?



Thanks,
Chris.

  

Pros: potentially more readable code.
Cons: Wasted energy typing unnecessary lines of code.
Really I would say it comes down to coder preference.

(and why would you avoid the latter all together?  Testing a boolean may 
be cleaner, but setting the boolean still relies on the value of $value, 
so if that value was fubar then the boolean would be too.)

-Brad

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



Re: [PHP] --with-openssl on x64

2006-08-22 Thread Brad Bonkoski

Hmm..

in my system, /usr/lib is a sym link to /usr/lib64...

but..
Try this configure option:
--with-openssl[=DIR]
-B

Marten Lehmann wrote:

Hello,

openssl is compiled for x86 on my system, so the libs are in 
/usr/lib64 rather than /usr/lib. But configure only looks in /usr/lib 
and gives me


configure: error: Cannot find OpenSSL's libraries

How can I change this?

Regards
Marten



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



Re: [PHP] Overriding core functions

2006-08-22 Thread Brad Bonkoski

Some already good workarounds given for this question...
BUT.
Is it even possible to override a core function?
Like I wrote a function called 'exit' and I got a parser error, which 
leads me to believe it is not even possible to override the core 
functions.  Is this true of ALL PHP functions?

-B

Alex Turner wrote:
It may be possible to override the core function - I don't  actually 
know.  If you just define a new function with the same function it might

work OK.

The snag I see coming at you like a tonne of bricks is 'how do you 
call the original function once you have overridden it.'.  This like 
like calling SUPER. in Java.


AJ

Peter Lauri wrote:

Yes, that could solve it. However, my question was if I can override the
core functions :) Similar that I can do Parent::myFunction() in a 
subclass,

I want to do that, but with core functions :)

-Original Message-
From: Jochem Maas [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 
22, 2006 7:27 PM

To: Peter Lauri
Cc: php-general@lists.php.net
Subject: Re: [PHP] Overriding core functions

Peter Lauri wrote:

Hi,

 


I want to add some functionality when calling the mysql_query():

 



function my_query($Query) {

 //do stuff before

 mysql_query($Query);

 //do things after

}

// or something like:

class PeteDB {
   var $conn;

   function PeteDB($db, $usr, $pwd, $etc) {
$this-conn = mysql_connect($db, $usr, $pwd, $etc);
if (!is_resource($this-conn)) die('db is useless'); //
trigger_error()
   }

   function query($qry/*, $args*/) {
// do stuff
$r = mysql_query($qry, $this-conn);
// do more stuff
return $r;
   }
}

/*
tada!

hint: always use some kind of wrapper for things like db related 
functions

(because it allows for stuff like this and, for instance, makes it alot
easier to
switch dbs - because you only have to change code in one place, not 
counting

any db-specific
sql floating around your app)
*/

 

This would just be for one project where I want to record all 
Queries and

the result of them, creating an own logging function.
 

I did a lot of Google, but no article that I found that take care of 
this

subject.

 


/Peter

 

 

 







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



Re: [PHP] php - mysql query issue

2006-09-15 Thread Brad Bonkoski

Have you tried echoing out your query to run on the backend itself?
Maybe there is some problem with how your join is being constructed...
Perhaps a left outer join is called for?  Hard to tell without having 
knowledge of your table structure and table data...


-B

Dave Goodchild wrote:
Hi all. I am building an online events listing and when I run the 
following

query I get the expected result set:

SELECT events.id AS eventid, name, postcode, start_time, dates.date FROM
events, dates_events, dates WHERE dates_events.event_id = events.id and
dates_events.date_id = dates.id AND dates.date = '$start_string' AND
dates.date = '$end_string' ORDER BY date ASC

...however, when I look for a one-off event the following query fails:

SELECT events.id AS eventid, name, postcode, start_time, dates.date FROM
events, dates_events, dates WHERE dates_events.event_id = events.id and
dates_events.date_id = dates.id AND dates.date = '$start_string'  
ORDER BY

date ASC

...if I query for that date in the dates table using this:

SELECT * FROM dates WHERE date = '$start_string'

I get the date record I expect. The second query above cannot seem to 
look
for a date that equals the supplied string (BTW, all data has been 
escaped

prior to interpolation in the query string!)

Any ideas why not? I know it's more of a mySQL question so apologies in
advance!



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



Re: [PHP] +AFs-OT+AF0- Working with version control

2006-09-21 Thread Brad Bonkoski


Chris W. Parker wrote:
 Hello,

 This is off topic but I wanted to get the list member's opinions on the
 subject as it will probably benefit someone else.

 Currently I don't use version control at all. What I do instead is have
 one directory that contains my development website and one directory
 that contains the live website which I do not directly modify. When I
 need to fix something or add a new feature I edit the development site
 and copy the files that I've changed.

 Sometimes I will start on a new feature before I am able to finish a
 previous one. This is a major problem when the features overlap and I
 have to edit the same file for both features. Even if I finish one of
 the features I cannot publish the files because the other feature is not
 ready yet.

 What I'm looking to the list for is how I can overcome this through
 version control.

 What I'm thinking I'd do is create a base level (say v1.0) that I then
 create a branch for every new feature and then merge those things
 together. The issue I see in this case is the merging.

 Is this a sound strategy or should I just realize that I can't publish
 until all current features enhancements are completed?


 Thanks,
 Chris.

   
What you are currently doing would be similar if you were using source
control, only you would have the ability to revert to previous
functions, and have better logging for changes to your files  So, I
would advocate using some source control, like subversion to make life a
little more orderly.

As for your problem... of course it is always *ideal* to complete one
branch/feature before you start a new branch/feature, but often times we
do not live in *ideal* worlds, so merging becomes a necessary evil. 
source control / configuration management will not really solve this
problem, but it will provide better tools to attack the problem.

So, I would sit down and google for the Subversion Red Book and read
through some of that to get your started.
As I said before you will find some of the method similar to what you
are currently doing, it will just document your journey a little better.
-B

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



Re: [PHP] Override php.ini

2006-09-22 Thread Brad Bonkoski

the ini directive for this is: asp_tags
and it appears you can set them in the .htaccess file on a per directory 
basis.


See the user contributed notes on www.php.net/ini_set
HTH
-B

Beauford wrote:

Is there a way I can use % % instead of ? ? for the opening and closing
tags of a php script. I thought I read this somewhere but can't find
anything on it now.

Is there something that I could do with override php.ini command? I don't
have access to the php.ini file on this server.

Thanks

B

  


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



Re: [PHP] class usage

2006-09-29 Thread Brad Bonkoski



benifactor wrote:

ok, about five minutes ago i decided to learn classes and delve into php's oop 
side.

what i came up with was this...

//start example code

class newsletter {
 function send ($email,$subject,$message) {
 if ($email) {
  echo(the following message was sent to: $email br subject: 
$subjectbrbr $message);
 }  
 else {

  echo(failure);
 }
 }
}
$new = new newsletter();
$new-send([EMAIL PROTECTED], test class, test class worked, i have passed and 
failed the test.);

//end code example

..and this seems to work fine, i could easily add  the mail function and insert 
real variables into send() but what i don't understand is i could also easily 
do this without a class... so i guess the real question is what are some real 
life examples of class usage and why is it used as  opposed to regular non oop? 
thank you for any input into the subject that you may have.
  
Pick up a general book on OOA/D development.  IMHO, the advantage of OO 
is to modularize your code with encapsulation(buzz word).  Basically 
meaning that as long as your interface to an object does not change, it 
does not matter to the *outside world* what you do behind the scenes.  
This is especially beneficial for abstracting layers (as someone else 
pointed out with the DB abstraction), as well as working within teams of 
developers.
Done right it enhances all the *ilities* of software development, done 
wrong it is a horrific mess of spaghetti!  
Another advantage could be design *might* be easier because UML exists 
as a nicely featured modeling language which maps very nicely to classes 
in OO.
When all is said and done it is another tool in software development.  
It has its purposes and when wielded by persons who know how best to use 
it, it is quite a good method.  But be your own judge, and read some 
about it!


Another *real world* example might be taking the DB abstraction a little 
further. 
Represent all your tables as classes.  This gives you the ability to 
properly scrub, validate data before assigning it, allows you to 
automatically persist the data  (if you choose) when the class goes out 
of scope, gives easy access of data to people who need not concern 
themselves with the DB schema, etc..
Really a nice tool for this case, especially when you inherit a schema 
which is less the obvious ;-)


-B

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



Re: [PHP] how do I get this line to work inside double quotes

2006-10-02 Thread Brad Bonkoski

Ross wrote:
 $mail_body .= font size=\2\ face=\Verdana, Arial, Helvetica, 
sans-serif\ stripslashes($mail_text) /font;


this just returns

{stripslashes(it\'s

a


testss}

  

$mail_body .=font size=\2\ face=\Verdana, Arial, Helvetica,

sans-serif\ .stripslashes($mail_text). /font;

--
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 Brad Bonkoski

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 Brad Bonkoski

Deckard wrote:

Hi Brad,

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

Now i have another doubt:

$stringData = '?php' .  \n\n . '$hostname = ' . '$hostname' . \n .
'$database = wordlife' . \n .
 '$mysql_username = ' . $mysql_username . \n .
'$mysql_user_password = ' . $mysql_user_password . \n\n . '?';

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




  

Simplify your life!
$stringData = ?php \n\n \$hostname = '$hostname'\n
\$database = wordlife \n \$mysql_username = $mysql_username \n
\$mysql_user_password = $mysql_user_password \n\n ?;

the '\' character is the escape...
so
if $var = string
echo $var; // output string
echo \$var; //output $var
-B

--
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

2006-10-05 Thread Brad Bonkoski

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:
---
?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().'BR';

return (TRUE);

   }

}

?
--

testedb.php
--
?php

 include_once(classes/dBInsert.php);

 $sql = INSERT INTO wl_admins VALUES ('',3);
 $dBInsert = new dBInsert('wl_admins', $sql);
 $dBInsert-InsertDB('wl_admins', $sql);

?
--

  
#1. If $table and $sql are class variables, why are you passing them as 
params to the InsertDB method?

#2. You don't even us the $table param.

Otherwise, not sure what this buys you...

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



Re: [PHP] need help to build a query

2006-10-09 Thread Brad Bonkoski

[EMAIL PROTECTED] wrote:

hi to all,

I have table orders with primary key order_id. I have table uploaded_files
with primary key ufid and uploaded files are linked to orders by order_id
column.

I have to list all orders and uploaded files. this works fine:

$query = mysql_query(
  select order_id, order_date, order_status
  from orders
  order by order_id desc
  limit 100);
while($result=mysql_fetch_array($query))
{
  echo ID: . $result['order_date'].|;
  echo DATE: . $result['order_date'] .|;
  echo STATUS: . $result['order_status'] .|;
  echo UPLOADED FILES: ;
  $query2 = mysql_query(
select uf.file_name
from uploaded_files as uf
where uf.order_id = $result['order_id']
  );
  while($result2=mysql_fetch_array($query2))
  {
echo $result2['file_name'].|;
  }
  echo hr;
}

but I know there must be much better solution then this one.

thanks for any help.

-afan

  


Perhaps something like this: (not sure how this would play with the 
limit key word, but you could play around with it...)
If you can guarantee that a record (order_id) will appear in both 
tables, a simple join will work...
but if a record in table A exists but not in table B, a join will not 
return that record, which is why there is a left outer join.


select o.order_id, o.order_date, o.order_status, uf.file_name
 from orders o left outer join uploaded_files uf on uf.order_id = o.order_id
 order by o.order_id desc

Not sure if mysql supports this..??

select * from (select o.order_id, o.order_date, o.order_status, uf.file_name
 from orders o left outer join uploaded_files uf on uf.oerder_id = o.order_id
 order by o.order_id desc ) LIMIT 100

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



Re: [PHP] foreach

2006-10-10 Thread Brad Bonkoski

João Cândido de Souza Neto wrote:

Hello.

In the follow code:

$numbers=array(1,2,3,4,5);
foreach ($numbers as number) {
...
}

Inside foreach, could i know if i am in the last element of the array 
$numbers?


  
Sure, maintain a count in the foreach and then compare to 
count($numbers)..but why not just use a for loop?


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



Re: [PHP] mysqldump problem from PHP

2006-10-23 Thread Brad Bonkoski

Edward Kay wrote:

hi all,

Im doing the following dump through PHP:

$output = shell_exec('mysqldump '. $db_database .'  '.
$backup_path.$filename);

It doesnt seem to work but when I run the exact same command (with
appropriate values) in the command line it creates the dump file. What
could be the reason for this?

Thanks in advance.

regards



  

It appears that it could be because the user that runs the scripts is
not allowed to. When I run them on the commandline, I run them as the
root user. Is this a common problem? What would the best way be to sort
this out keeping in mind security on the server?




If you are trying to automate backups of you database, set up a
  

cron job. I


have a shell script that dumps my databases, zips them and then
  

sends them


via FTP to a remote server. This is automatically run every 12 hours by
cron.

See http://en.wikipedia.org/wiki/Crontab for more info.

Edward




  

hi Edward,
yes I know of CRONtabs but wont this still leave us with the user
permission of running mysqldump? because essentially it will still be a
PHP file to run the shell command to create the dump file?

thanks



No, cron will typically run as root. You don't need to involve PHP.

It looks to me as if you are trying to use web scripting (PHP) to do the
sysadmin on your server, for which other methods are more suitable.

Edward

  
#1. You can run mysqldump with the same flags a the mysql command 
line... i.e. -u=user --password=password

#2. Crons run as the user that owns the crontab, not always root.
#3. Edward is right, PHP is a wonderful tool, not sure the tool was 
meant to do the types of things you are trying to do...unless you could 
fill us in with more details of what the purpose is, then we might be 
able to give more insight into how.


-B

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



Re: [PHP] only one at atime

2006-10-30 Thread Brad Bonkoski

Ahmad Al-Twaijiry wrote:

Hi everyone,

I create a php script that will run every minute (by cronjob) and
update some database tables (php 5, database mysql 5, tables type
innodb)

the problem is that I want this script to run only one at atime (only
one process from this script can run )

for example, if the cronjob start the script and the script takes more
than one minute, then after this one minute the cronjob start another
process from this script, it should exit once it find there is an old
process of it running)

what I do now is that when the script start it will check for a tmp
file (/tmp/script.pid) and if it fine it it will exit.
if the file  (/tmp/script.pid) is not exists, it will create it and
start doing the database update
and when the script finish it will remove the file


any better idea ?

Thanks

Nope, typically this is how you solve the problem you mentioned... (just 
make sure the /tmp directory (or specifically your file are remove when 
you boot up)
I have seen instances where the machines reboot in the middle of the 
script and then don't execute for a while because of this *lock file*.

-B

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



Re: [PHP] Looping through array

2006-11-16 Thread Brad Bonkoski

Ashley M. Kirchner wrote:


   Say I have an array containing ten items, and I want to display 
them in a table as follows:


5 4 3 2 1
   10 9 8 7 6

   What's the best way to loop through that array to do that?  My 
thinking gets me to create a loop for 5 through 1, repeated twice, and 
the second time I add '5' to the index value.  There's got to be a 
saner way...



Something like this perhaps...

$arr = array(...);
$per_row = 5;
$elem = count($arr);
for($i=0; $i$elem; $i++) {
   if( $i == 0 )
  echo tr;
   if( $i % $per_row == 0 )
  echo /trtr;
   echo td$arr[$i]/td;
}

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



Re: [PHP] Looping through array

2006-11-16 Thread Brad Bonkoski

Ashley M. Kirchner wrote:


   Say I have an array containing ten items, and I want to display 
them in a table as follows:


5 4 3 2 1
   10 9 8 7 6

   What's the best way to loop through that array to do that?  My 
thinking gets me to create a loop for 5 through 1, repeated twice, and 
the second time I add '5' to the index value.  There's got to be a 
saner way...



Something like this perhaps...

$arr = array(...);
$per_row = 5;
$elem = count($arr);
for($i=0; $i$elem; $i++) {
   if( $i == 0 )
  echo tr;
   else if( $i % $per_row == 0 )
  echo /trtr;
   echo td$arr[$i]/td;
}

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



Re: [PHP] Additional query for number of records in table

2006-11-17 Thread Brad Bonkoski

[EMAIL PROTECTED] wrote:

hi,
I have query to select products for specific category from DB, something
like:
SELECT prod_id, prod_name,...
FROM products
LIMIT $From, $To

where $From and $To values depend of on what page you are. let say there
are 100 products and I'm listing 25 products per page. for page 1 $From=0,
$To=24. for page 2 $From=25 and$To=49, etc.

works fine.

though, to calculate how many pages I have I need total number of records.
do I have to run first a query (something like SELECT COUNT(*) as
NoOfRecords FROM products) and then query above or there is solution to
have both info using one query?

as a solution, I can run a query to grab all records and then list just 25
products but I think it's not so smart idea :)

thanks for any help.

-afan

  
I would say the select count(*) from ... query would be a fairly low 
cost query.
Perhaps you could store off the number of rows in a session variable so 
you don't have to execute the count query when you move to the next page.

-B

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



Re: [PHP] inheritance php4

2006-12-12 Thread Brad Bonkoski

bruce wrote:

hi...

haven't used php classes.. so this might not pertain.. but do php classes
have the concept of public/private functions? 

Not in PHP 4

are the parent functions that
you're trying to access public/private?



-Original Message-
From: blackwater dev [mailto:[EMAIL PROTECTED]
Sent: Tuesday, December 12, 2006 11:00 AM
To: php-general@lists.php.net
Subject: [PHP] inheritance php4


Ok,

I have a class which inherits from a parent class.  My first thought is that
the child class inherits all of the functions of the parent but that doesn't
seem to be the case, do I really have to put parent::somefunction() to call
each one?  Why can't I just use $this-parentfunction(); within the child
class?

Thanks!


class Parent{

 function getAddress(){}

}

class Child extends Parent{

function getInfo(){

$this-getAddress(); //throws error

}

}

  


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



Re: [PHP] md5

2007-01-17 Thread Brad Bonkoski

[EMAIL PROTECTED] wrote:

MD5 is a hasing algorithm.. one-way..  really only good for checking known 
values and keeping them 'private', like storing passwords in a database.  That 
way, if someone breaks into your database, they don't get the passwords, only 
the non-reversible MD5 hashes of the passwords.

To check a user's login credentials, you take the database value for password 
and you compare it to md5($password) that the user entered and see if they 
match.

So the fact that MD5 is a well known algorithm doesn't really make a difference 
as far as security goes.
  
Except for the fact of the growing number of databases that will map the 
hashes back to the clear text (for example: http://md5.benramsey.com/)
Of course it is nice because it is a common implementation, and can be 
done on the server side, as well as the client side.



Then again, RSA, Blowfish, etc are well known algorithms and are considered at 
least fairly secure too.. and are reversible.

-TG


= = = Original message = = =

Hi,

Does md5 really offer much in terms of protection?

The algorithm is really well known.

I would like to hear your thoughts and poosible alternatives (mcrypt?)

R. 

  


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



Re: [PHP] md5

2007-01-17 Thread Brad Bonkoski

[EMAIL PROTECTED] wrote:
Still.. that has nothing to do with how well known MD5 is (so I stand by my point).
Was not trying to refute your point.  Just pointing something out with 
regards to the security of MD5 hashes, and what being well known or 
at least popular does for you.  What you say is true...and at the end of 
the day locks only keep honest people out...
(but something like this could be a decent way to check for strength of 
passwords..)

-B

All these databases are is a giant list of pre-MD5'd strings.  Brute force 
stuff, no magic behind it that allows for reversing MD5. You could technically 
do that with just about any crypto or hashing system.  Just happens that MD5 is 
one that's been focused on and more complicated systems would require 
exponentially more variables in what you'd have to enter.   For instance, you 
could do this with PGP, but I'm guessing you'd have to have at least two pass 
phrases and how many things go into generating the public and private keys, 
plus the message/file that was encrypted.  So for one short text string, you 
could possibly have a database as large as all the MD5 projects put together... 
but you could potentially do the same thing.   At that point it's highly 
prohibitive though.

I got the idea that MD5 really wasn't what he was looking for anyway, so going 
into detail about the security of it didn't seem fruitful.  I talk too much as 
it is. hah

This is a good point though.  MD5 isn't great security, particuarly with the 
databases like the one you mentioned, but most of us aren't storing national 
security documents.   As with security since the dawn of time, it's all a 
matter of how valuable is what you're protecting versus the cost of 
implementing a protection scheme.   7-11 doesn't hire secret service to protect 
against midnight robberies.

-TG



= = = Original message = = =

[EMAIL PROTECTED] wrote:
  
So the fact that MD5 is a well known algorithm doesn't really make a difference 
as far as security goes.

  
Except for the fact of the growing number of databases that will map the 
hashes back to the clear text (for example: http://md5.benramsey.com/)
Of course it is nice because it is a common implementation, and can be 
done on the server side, as well as the client side.





___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.


  


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



[PHP] Oracle Execute Function

2007-01-18 Thread Brad Bonkoski

Hello All,

I have this Oracle function, and within my code I call it like this:

$sql = BEGIN :result := my_funtion_name('$parm1', $parm2, null, null, 
null); END;;

   $stmt = $db-parse($sql);
   $rc = null;
   ocibindbyname($stmt, :result, $rc);
   $db-execute($stmt, $sql);

The problem is that the execute function spits back an error/warning 
message, but the Oracle function properly executes and the data is in 
the Database.

The execute function looks like this:
(This function enters the conditional where ii executes the die() function)

public function execute($stmt, $query = ) {
   if( $this-trans)
   $result = @ociexecute($stmt, OCI_DEFAULT);
   else
   $result = @ociexecute($stmt);
   if (!$result ) {
   $error = ocierror($this-link);
   $this-report('Invalid Statement: ' . $stmt 
.'('.$query.')'. '  '

   . htmlentities($error['message']));
   die('Invalid Statement: ' . $stmt 
.'('.$query.')'. '  ' . htmlentities($error['message']));

   }
   return $result;
   }

I use this wrapper class for many things, and the execute function for 
many things, without any problems.

Now, this is an initial run at calling Oracle functions within PHP.
Any words of wisdom as to what could be causing this problem, or any 
other insight?


TIA
-Brad

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



Re: [PHP] Displaying Results on different rows in tables

2007-01-18 Thread Brad Bonkoski

Dan Shirah wrote:

Hello all,

I am trying to pull data and then loop through the multiple results 
display

in seperate rows.
My database contains several tables which are all tied together by the
credit_card_id.  After running the query, it ties the unique record 
together

by matching the credit_card_id in both tables.  How would I go about
displaying the results of this query in a table with a single row for 
each

unique record?

Each row of the result will have 5 columns: Request ID, Date/Time 
Entered,

Status, Payment Type, Last Processed By.

If I assign the results of the query to variables (Such as $id =
$row['credit_card_id'];) how would I display that data?

Would it be something like this:

foreach($row as $data)
{
echo table
   tr
tda href=$item-link$id/a/td
   /tr;
 echo tr
td$dateTime/td
   /tr
 /table;
 echo tr  td$Status/td
   /tr
 /table;

 }
Below is the code I have so far.

?php
$database = database;
$host = host;
$user = username;
$pass = password;
 // Connect to the datbase
 $connection = mssql_connect($host, $user, $pass) or die ('server
connection failed');
 $database = mssql_select_db($database, $connection) or die ('DB
selection failed');
 // Query the table and load all of the records into an array.
 $sql = SELECT
child_support_payment_request.credit_card_id,
  credit_card_payment_request.credit_card_id,
  date_request_received
   FROM child_support_payment_request,
credit_card_payment_request
 WHERE child_support_payment_request.credit_card_id =
credit_card_payment_request.credit_card_id;
First of all, if you are joining on the credit_card_id, you only need to 
select one of them.  So your query would be:
select child_support_payment_request.credit_card_id, 
table_name.date_request_received

from child_support_payment_request, credit_card_payment_request
where child_support_payment_request.credit_card_id = 
credit_card_payment_request.credit_card_id

 $result = mssql_query($sql) or die(mssql_error());
 while ($row=mssql_fetch_array($result));

echo table;
while ($row = mssql_fetch_array($result)) {
   $id = $row['credit_card_id'];
   $dateTime = $row['date_request_received'];
   echo trtd$id/tdtd$dateTime/td/tr;
}
echo /table;

 $id = $row['credit_card_id'];
 $dateTime = $row['date_request_received'];

?



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



Re: [PHP] Oracle Execute Function

2007-01-18 Thread Brad Bonkoski

Roman Neuhauser wrote:

# [EMAIL PROTECTED] / 2007-01-18 11:46:10 -0500:
  

Hello All,

I have this Oracle function, and within my code I call it like this:

$sql = BEGIN :result := my_funtion_name('$parm1', $parm2, null, null, 
null); END;;

   $stmt = $db-parse($sql);
   $rc = null;
   ocibindbyname($stmt, :result, $rc);
   $db-execute($stmt, $sql);

The problem is that the execute function spits back an error/warning 
message, but the Oracle function properly executes and the data is in 
the Database.



And the warning is...?

  

Nothing of real use from what I can see..
It falls into this statement:
die('Invalid Statement: ' . $stmt .'('.$query.')'. '  ' . 
htmlentities($error['message']));


So, I get this message back (and the error['message'] part is blank.

It gets there from this:
$result = @ociexecute($stmt);
if(!$result) {
   ...
}
so the return from ociexecute appears to be FALSE.

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



Re: [PHP] Oracle Execute Function

2007-01-18 Thread Brad Bonkoski

Brad Bonkoski wrote:

Roman Neuhauser wrote:

# [EMAIL PROTECTED] / 2007-01-18 11:46:10 -0500:
 

Hello All,

I have this Oracle function, and within my code I call it like this:

$sql = BEGIN :result := my_funtion_name('$parm1', $parm2, null, 
null, null); END;;

   $stmt = $db-parse($sql);
   $rc = null;
   ocibindbyname($stmt, :result, $rc);
   $db-execute($stmt, $sql);

The problem is that the execute function spits back an error/warning 
message, but the Oracle function properly executes and the data is 
in the Database.



And the warning is...?

  

Nothing of real use from what I can see..
It falls into this statement:
die('Invalid Statement: ' . $stmt .'('.$query.')'. '  ' . 
htmlentities($error['message']));


So, I get this message back (and the error['message'] part is blank.

It gets there from this:
$result = @ociexecute($stmt);
if(!$result) {
   ...
}
so the return from ociexecute appears to be FALSE.


After removing the '@' from the ociexecute ... I get this:
PL/SQL: numeric or value error: character string buffer too small
Does this trigger any ideas?

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



Re: [PHP] Magic quotes good or Bad?

2006-04-05 Thread Brad Bonkoski

IMHO,
it really depends on a couple of things...
1). how you use it
and 2). How much control you want...

If you have a single point of entry for database actions, like a class 
that mimics the database structure and handles updates, inserts, 
deletes, then it makes sense to turn them off to give you the control, 
as with the single point of entry you can easily add/strip slashes.  But 
if your design allows for many points of entry it becomes problematic to 
make sure you are adding/stripping slashes in all the appropriate areas. 

So, I would say that magic_quotes is a tool, it has some limitations, 
but can also be helpful.  So it really depends on the wielder of the 
tool if it should be used or not.


-Brad

Angelo Zanetti wrote:


Hi guys.

I've just read an article that gives a good explanation about escaping 
single quote characters with slashes, the author then says that 
magic_quotes_gpc can do this for you if enabled on your server, he 
then he also mentions how if your magic_quotes_gpc are not turned 
on/enabled that you could use addslashes() with the same result and 
when retrieving info from the database that we need to use 
stripslashes().


All seems hunky dory but then he concludes that magic_quotes_gpc that 
they are evil as we have less control over the information we receive. 
Which does make sense. So should i avoid magic_quotes_gpc all 
together? my local development server has them enabled and when 
testing the input of a textfield that does a select query I input 
'hello' (including single quotes) and it works really well with the 
single quotes escaped. But my live server has them disabled and 
therefore the single quotes break the SQL statement. So on my live 
server should I enable magic_quotes_gpc or should I use addslashes() 
and stripslashes()?


Thanks in advance.


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



Re: [PHP] problem using mysql_connect function under windows XP

2006-04-05 Thread Brad Bonkoski

Create a page like this:
?php
   phpinfo();
?

and see what the output tells you about mysql...might shed some light on it.
-B

Alain Roger wrote:


i've seen that non of extension are activated...neither mysql.dll nor
mysqli.dll

after uncommenting them and restarting Apache, it still does not work :-(

On 4/5/06, Jochem Maas [EMAIL PROTECTED] wrote:
 


Alain Roger wrote:
   


Hi,

i wrote a simple testing page. it should test if it can connect to MySQL
 


db.
   


however, i have an error message as followed :
*Fatal error*: Call to undefined function mysql_connect() in *F:\Mes
documents\Development\Website\Immense\checklogin.php* on line *23

*on line 23, i have the following thing :

mysql_connect($host, $username, $password) or die(cannot
 


connect);
   


where is the problem ?
 


line 23.

you don't have the mysql extension installed/loaded.
maybe your php build has the mysqli extension?


   


thansk a lot,

Alain

 

   



 



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



Re: [PHP] problem using mysql_connect function under windows XP

2006-04-05 Thread Brad Bonkoski

One alternative is to try this:
http://www.en.wampserver.com

Otherwise, make sure the php.ini file you are editing is the one pointed 
to by the line:

Configuration File (php.ini) Path from the phpinfo generated file

Also, you could check any Apache log files to see if they output any 
errors when you restart the web server.


-B

Alain Roger wrote:


nothing about MySQL...only what is in my path variable :-(
1. i stopped apache server
2. i uncomment -- extension=php_mysql.dll and extension=php_mysqli.dll in
my php.ini file
3. i updated my extension_dir like that -- extension_dir =
F:\WebServer\PHP511\ext
4. i restarted apache
5. phpinfo still provide no info regarding MySQL

what should i do ?


On 4/5/06, Brad Bonkoski [EMAIL PROTECTED] wrote:
 


Create a page like this:
?php
   phpinfo();
?

and see what the output tells you about mysql...might shed some light on
it.
-B

Alain Roger wrote:

   


i've seen that non of extension are activated...neither mysql.dll nor
mysqli.dll

after uncommenting them and restarting Apache, it still does not work :-(

On 4/5/06, Jochem Maas [EMAIL PROTECTED] wrote:


 


Alain Roger wrote:


   


Hi,

i wrote a simple testing page. it should test if it can connect to
 


MySQL
   

 


db.


   


however, i have an error message as followed :
*Fatal error*: Call to undefined function mysql_connect() in *F:\Mes
documents\Development\Website\Immense\checklogin.php* on line *23

*on line 23, i have the following thing :

mysql_connect($host, $username, $password) or die(cannot


 


connect);


   


where is the problem ?


 


line 23.

you don't have the mysql extension installed/loaded.
maybe your php build has the mysqli extension?




   


thansk a lot,

Alain



 

   



 



 



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



Re: [PHP] Php Script Stumped!

2006-04-06 Thread Brad Bonkoski

1. Look at this: http://javascript.internet.com/forms/form-focus.html

2. See Below

3. Take a look at this function: 
http://www.php.net/manual/en/function.date.php


-B

marvin hunkin wrote:


Hi.
doing this script for an assignment, and got it basically working.
the only problems are:


1. wen i load the user form, the focus goes to the login button, and 
not the first form field.

did try putting one it, did not like it.
so how do i do this?
is there a basic dom example, how to set focus on a form field, when 
the form loads?

2. got a user name and password.
and enter username and password, and when the php script loads, it 
shows the user name and the password.
want to hide this, and only have the message, now how do i accomplish 
this?
tried things on the web and tried on google, but could not find any 
thing for this.
3. and got to provide the time, but how do i format it say for 
australian east standard time?

just got the standard time, and jaws reads it out, as one line of text.
will paste the user form and php code.
if any one can offer code snippets, or point me to links, and 
examples, let me know.
sorry about this, but these are stumping me and banging my head up 
against the brick wall, so, would ask.

cheers Marvin.




User Form:

html
head
titleUser Login Form/title
/head
body
form action=UserDetails.php method=post
pUser Name: input type=text name=username /p br
pPassword: input type=text name=password /p br


I would make this: pPassword: input type=password 
name=password/pbr
 -use the password 
input type^



pinput type=submit value=Login /p
/form
/body
/html


Php Script:

?php
echo $_POST['username'];
echo $_POST['password'];


Just say:
   $user = $_POST['username'];
   $pass = $_POST['password'];
echo $user has successfully logged into the Tafe network. br\n;
/* This will STORE your username/password instead of printing them out 
to the screen */
(Of course there are security considerations sending a clear text 
password accross page loads, but it may be outside the scope of the 
assignemnt)


echo Marvin Hunkin has successfully logged into the Tafe network. 
br\n;

echo Please Wait ... Loading Your Personal Settings ... br\n;
echo time();
?but



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



Re: [PHP] ?=? style

2006-04-06 Thread Brad Bonkoski

short_open_tag

Dallas Cahker wrote:


What is that called and where in the php.ini file do I enable it?  Sorry if
this is a stupid question but since I dont know what its called it makes it
difficult to google it.

 



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



Re: [PHP] Oracle stored procedures

2006-04-06 Thread Brad Bonkoski

I am using PHP with Oracle, but not executing stored procedures.
I assume you are already validating the contents of the $addr variable 
before you bind it?

Otherwise, no real ideas here...
-B

Jay Blanchard wrote:


[snip]
I have a stored procedure in Oracle;

p_BILL_TO_ADDRESS1 IN CONT_ADDRESS.ADDRESS1%TYPE
Default NULL,  --VC(50)

With a condition;
IF p_BILL_TO_ADDRESS1 is NULL THEN
   Raise_Application_Error(-20100,'BILL TO Address cannot be a NULL
Value');
 END IF;


I have some PHP code that tries to insert the data;

$addr = '1234 Main';
$sth = oci_parse($conn, begin D_ACCT_NEW(:p_BILL_TO_ADDRESS1,
:P_Error_Return );end;);

oci_bind_by_name($sth, :p_BILL_TO_ADDRESS1, $addr, -1);
oci_bind_by_name($sth, :P_Error_Return, $errorcode, -1);
oci_execute($sth);

echo $errorcode;

And I always get the following error;

Warning: oci_execute() [function.oci-execute]: ORA-06502: PL/SQL:
numeric or value error ORA-06512: at SYSADM.D_ACCT_NEW, line 483
ORA-20100: BILL TO Address cannot be a NULL Value ORA-06512: at line 1
in /home/foo/bar/glorp.php on line 25

If anyone on the list understands the intricacies of Oracle, could you
sooth my aching head and help me to understand what is going on here? I
have RTFM and the following article from the PHP Oracle Cookbook;

http://www.oracle.com/technology/pub/articles/oracle_php_cookbook/fuecks
_sps.html


;and I still am clueless. Thanks a million in advance!
[/snip]

I hate to bring this up again, but is anyone on the list using PHP with
Oracle?

 



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



[PHP] Handling Large Select Boxes

2006-04-07 Thread Brad Bonkoski

Hello,

I have a form for user interaction and part of it is a select box with a 
large number of options from a database ~12K options.
Currently I have a function which queries the DB to get fresh data and 
loads the HTML (option value=XY/option) into a string, so the DB is 
only hit once,
but the page still takes a while to load. 

Anyone else have any experience with something like this, or any other 
helpful suggestions for making the page load time a little less cumbersome?


Thanks!
-B

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



Re: [PHP] Handling Large Select Boxes

2006-04-07 Thread Brad Bonkoski

Good point...
Maybe the gods of usability can kick the user's in the butt to get them 
to clean up the data!
Previously they used a free text field, which is why the problem is as 
bad as it is currently


All the data has to be available, so the only other option I can think 
of is to select 1 letter and then have Javascript populate the 
sub-select box...

unless someone has any other ideas?

-B

Jay Blanchard wrote:


[snip]
I have a form for user interaction and part of it is a select box with a

large number of options from a database ~12K options.
Currently I have a function which queries the DB to get fresh data and 
loads the HTML (option value=XY/option) into a string, so the DB is 
only hit once,
but the page still takes a while to load. 

Anyone else have any experience with something like this, or any other 
helpful suggestions for making the page load time a little less

cumbersome?
[/snip]

If you are loading 12000 entries into a select box then that is way too
much. The gods of usability frown on you. Is there no way to make the
data selection slimmer?

 



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



Re: [PHP] microtime questions

2006-04-07 Thread Brad Bonkoski

Interesting...
as for your first question...
Know that PHP/Apache does not have free reign to your CPU, so the times 
could be different based on the scheduling going on in the OS kernel.


As for the second one...
No idea why you would get a negative number, I just copied and ran from 
the command line and did not encounter 1 negative time for about 30 runs


Do you get negative times if you run it from the command line as well?
-B

tedd wrote:


Hi gang:

I'm getting elapsed time results I can't believe.

Would anyone care to check out:

http://www.xn--ovg.com/microtime.php

And answer a couple questions posted there?

Thanks.

tedd


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



Re: [PHP] Completing forms offline with PHP/MySQL

2006-04-07 Thread Brad Bonkoski

If your users are using Windows, then something like
http://www.hypervisual.com/winbinder/
might be good on the user side, as you can bundle the PHP binary and 
everything else needed into one executable (with some work of course)
And then they can create a file formatted to your specifications to 
upload sometime later.


Or you can use some other UI like QT to create the XML document on the 
client side which would be cross-platform.


The only way to re-use what you have in an offline web environment would 
be like Jay said to install the required software on the client's / 
user's computers, and is that really something that is maintainable?


The key question: is the additional work required really beneficial? 


Jay Blanchard wrote:


[snip]
Apologies if this is the wrong place for this question, but I'm sure
there
are some experts out there who might be able to point me in the right
direction... :)

I'm doing some work at the moment where remote teams can submit reports
through to our database when connected over the internet to our server.
However, I've been asked to look in the possibility of the teams
completing
the form offline, and uploading when they have access to a connection.

It looks like I might be able offer something like Microsoft InfoPath
forms
(better recommendations?) to generate an XML file, and then use a PHP
file
to upload the file into the database. Additionally, I could also do with
this process uploading a number of other files (e.g. images, text files)
to
the server. 


Does anyone have any experience in this area, and would be able to
recommend
a solution?
[/snip]

The first part: completing a web-based form offline would mean having
some way to process the result 'locally', so how would you do that? You
don't want to install copies of Apache  PHP on each machine and have
those services run each time the machine starts, so how would you get a
form to save the necessary data client side? I searched offline forms on
Google and came up with several third party solutions, YMMV.

The second part: making the network aware that a machine has connected
to it and performing the proper steps or make the machine aware that it
has connected to the network and have it initiate the process. Of course
this could be taken care of by the user by having them click something.

 



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



Re: [PHP] microtime questions

2006-04-07 Thread Brad Bonkoski

How is the CPU not in question?  Does this script run on air?
It may not be YOUR CPU, but it is still a CPU bound by the sceduling 
algorithm of the Operating System, so the time differentials are too be 
expected.

-B

tedd wrote:


At 12:24 PM -0400 4/7/06, Brad Bonkoski wrote:


Interesting...
as for your first question...
Know that PHP/Apache does not have free reign to your CPU, so the 
times could be different based on the scheduling going on in the OS 
kernel.


As for the second one...
No idea why you would get a negative number, I just copied and ran 
from the command line and did not encounter 1 negative time for about 
30 runs


Do you get negative times if you run it from the command line as well?
-B


RE:

http://www.xn--ovg.com/microtime.php



Brad:

Thanks for looking.

My questions are with regard to what happens on the site, not via my 
command line. As such, my command line and my CPU are not involved.


Can you answer the questions as they pertain to the site in question?

Thanks.

tedd



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



Re: [PHP] Parse Error on SQL Insert

2006-04-07 Thread Brad Bonkoski

why do you have single quotes around year?
-B

Tom Chubb wrote:


I'm working on an insert record page with a multiple file upload script of
which I understand the fundamentals.
However, on submission I am getting the following error:

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting
T_STRING or T_VARIABLE or T_NUM_STRING in
C:\apache2triad\htdocs\damotors\admin\insertnew.php on line 34

Where line 34 is...

$insertSQL = INSERT INTO cars (model, `year`, details, price, image1,
image2, image3, forsale) VALUES ($_POST['model'], $_POST['year'],
$_POST['details'], $_POST['price'], $_FILE['image']['name'][0],
$_FILE['image']['name'][1], $_FILE['image']['name'][2], $_POST['forsale']);


For info, the HTML for the form is as follows:

   tr valign=baseline
 td nowrap align=rightImage1:/td
 tdinput type=file name=image[]/td
   /tr
   tr valign=baseline
 td nowrap align=rightImage2:/td
 tdinput type=file name=image[]/td
   /tr
   tr valign=baseline
 td nowrap align=rightImage3:/td
 tdinput type=file name=image[]/td
   /tr

I've been slaving away for an hour and it's probably something really
obvious but I'd really appreciate it if someone could point it out to me
please?
Previously I was getting an image1 cannot be null error which I couldn't
work out either. That's gone, but I still can't work out what's going on.

Many thanks,

Tom



--
Tom Chubb
[EMAIL PROTECTED]
07915 053312

 



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



Re: [PHP] Parse Error on SQL Insert

2006-04-07 Thread Brad Bonkoski
thanks for the clarification, I guess the other solution would be to 
avoid using names with special meaning for column names...

-B

Ray Hauge wrote:


On Friday 07 April 2006 12:53, Joe Henry wrote:
 


On Friday 07 April 2006 1:37 pm, Tom Chubb wrote:
   


$insertSQL = INSERT INTO cars (model, `year`, details, price, image1,
 


Not sure if this is your problem, but those look like backticks around year
instead of single quotes. Should there even be quotes there?

HTH
--
Joe Henry
www.celebrityaccess.com
[EMAIL PROTECTED]
   



The backticks should be fine.  They tell MySQL that you mean the column year 
of the table cars and not the MySQL special word year which can be used 
in date calculations.  The same thing would apply if you wanted a column 
named create.


I would agree with John on the POST data.  Make sure you at least run 
mysql_real_escape_string().


 



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



Re: [PHP] microtime questions

2006-04-08 Thread Brad Bonkoski



tedd wrote:


-B

At 12:51 PM -0400 4/7/06, Brad Bonkoski wrote:


How is the CPU not in question?  Does this script run on air?



I did not say that. I said that it was not MY CPU that was involved 
and it isn't.



Who cares, it is irrelavent who's CPU it is runing on.

It may not be YOUR CPU, but it is still a CPU bound by the sceduling 
algorithm of the Operating System, so the time differentials are too 
be expected.



Negative times are expected? Incorrect times are expected? What's the 
point of microtime if you can't reply on it?


Please explain.


Please tell me where it say Negative times are expected??  I don't 
see it. 
And take a class on Operating System Theroy!  If you want a real time 
OS, then get a real time OS, otherwise realize that although you MAY be 
executing the same code, it may take different amounts of time to 
execute that code.  That's how scheduling works.  If you want 
performance measurements then take a sample and average them out.




tedd

--- previous ---


-B

tedd wrote:


At 12:24 PM -0400 4/7/06, Brad Bonkoski wrote:


Interesting...
as for your first question...
Know that PHP/Apache does not have free reign to your CPU, so the 
times could be different based on the scheduling going on in the OS 
kernel.


As for the second one...
No idea why you would get a negative number, I just copied and ran 
from the command line and did not encounter 1 negative time for 
about 30 runs


Do you get negative times if you run it from the command line as well?
-B


RE:

http://www.xn--ovg.com/microtime.php



Brad:

Thanks for looking.

My questions are with regard to what happens on the site, not via my 
command line. As such, my command line and my CPU are not involved.


Can you answer the questions as they pertain to the site in question?

Thanks.

tedd







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



Re: [PHP] Handling Large Select Boxes

2006-04-08 Thread Brad Bonkoski

Thanks for the responses to this...

The AJAX thing would probably not work as this is a critical piece to 
the UI, so even though the form would load faster, the users would still 
really need to wait for the select options to come through before they 
could actually do any *work* on the page.


The problems are horrific data, in that it has not been cleaned and 
validated, and there are not linkages, or layers to the data either, so 
there is literally no way to sub-select, which of course is poor 
planning by people before me. 

So, before I can fix the real problem, my stop gap solution was to load 
the list exactly once, as well as loading the contents into JS, 
therefore the users can search through to narrow down the list, and then 
using JS they can select an option and place in the the form element 
they are dealing with.  Load time are much better, but still not great.  
I guess this is what happens when people get a ton of data before they 
properly planned to get that much data


-Brad

Brad Ciszewski wrote:


Perhaps try implementing some AJAX on the page. Therefore, once the page has
loaded, the select tag is populated with different options, without actually
lagging the page.


Jay Blanchard [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
[snip]
I have a form for user interaction and part of it is a select box with a

large number of options from a database ~12K options.
Currently I have a function which queries the DB to get fresh data and
loads the HTML (option value=XY/option) into a string, so the DB is
only hit once,
but the page still takes a while to load.

Anyone else have any experience with something like this, or any other
helpful suggestions for making the page load time a little less
cumbersome?
[/snip]

If you are loading 12000 entries into a select box then that is way too
much. The gods of usability frown on you. Is there no way to make the
data selection slimmer?

 



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



Re: [PHP] how to assign a value to a variable inside a class

2006-04-10 Thread Brad Bonkoski

How about this:

class foo {
   var $name;

   function setName($value) {
  $this-name = $value;
   }
}

-B

Merlin wrote:



Hi there,

I would like to assign a value inside a class like this:

var $db_username = $old_name;

Unfortunatelly this does not work and I do get following error:
Parse error: syntax error, unexpected T_VARIABLE, expecting 
T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}'


Thank you for any hint on how to place a correct syntax on this.

Merlin



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



Re: [PHP] how to assign a value to a variable inside a class

2006-04-11 Thread Brad Bonkoski



Merlin wrote:


chris smith schrieb:


On 4/11/06, Merlin [EMAIL PROTECTED] wrote:


chris smith schrieb:


On 4/11/06, Merlin [EMAIL PROTECTED] wrote:


Hi there,

no much simpler. I do not need to assign the value from outside 
the class. This
is just inside the class. I have the login data for a database 
saved in a file
and would like to use simply the variable $DB_login inside this 
class.


This does not work:

$this-db_username = $DB_login;


That's the right way to do it.

What are you seeing?

--
Postgresql  php tutorials
http://www.designmagick.com/


The following code:
 class search_helper extends AjaxACApplication
 {
var $db_username;
$this-db_username  = $DB_LOGIN;



Try it like this:

class search_helper extends AjaxACApplication
{
  var $db_username;
...

function SetDBUsername($db_username) {
  $this-db_username = $db_username;
}


If you want to set a default:

var $db_username = '';

--
Postgresql  php tutorials
http://www.designmagick.com/



That looks like to much for just assigning value to a variable?!
I would need 4 of those functions just to set the value of 4 variables 
to a value saved inside another variable. If I do understand you 
right, I would

also have to call that function inside the class to get that value set?:

 function SetDBUsername($db_username) {
   $this-db_username = $db_username;
 }
 SetDBUsername();

Is there not something more easy than that. For example $var1 = $var2;

Merlin



You're right...
This is the wonders of OOP.  Some people see this as nice because only 
your class has direct access to set your variables...so inside your 
'set' function you can do validation, formatting, etc... to make sure 
you are setting the variable to a proper value


Some people like the control, others think it is too much work with 
little gain, this is largely a political issue though, so we won't get 
into it too much.


Basically if you want to use classes you have to play by the rules of 
OOP.  To set and get a member variable within a class you need to define 
a function to do so. 


-Brad

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



Re: [PHP] Session_id within URL

2006-04-11 Thread Brad Bonkoski

session_start();
$s = SID; //get Session ID
echo a href=\page.php?$s\Page/a;

Mostly for passing the session as a GET variable to another page, like 
for anything from authentication tokens to form data etc...
Of course for form data it would probably be better to encapsulate the 
session veriables within the form.


-B

Alain Roger wrote:


Hi,

I would like to understand the purpose of placing SESSION_ID within the URL.
I suppose it is for security improving... However, how to do it ?

i mean how can it be useful ? how can i use it ?

thanks a lot,

Alain

 



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



Re: [PHP] PHP with Oracle

2006-04-19 Thread Brad Bonkoski
Assuming the PHP web page is available, anyone else having problems 
connecting to php.net?

-B

Jay Blanchard wrote:


[snip]
is there a ready script that handle entering user name and password for
authentication by extracting the Data from Oracle10g DB without showing
the
URL in the address bar...I am thinking of using a popup window
Spec.
[/snip]

Please RTFM at http://www.php.net/oracle and have a look at oci_connect

 



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



Re: [PHP] Re: no offense to Rasmus... are you kidding me

2006-04-20 Thread Brad Bonkoski


Maybe it is just me, but I think these types of discussions/debates 
concerning opposing view points on the direction of web programming is 
as imperative to the general PHP community (i.e. this list) as the 
dangers of register globals and magic quotes etc


At least more relevant then the infamous PHP Interview thread a week or 
so ago ;-)


-B

Martin Alterisio El Hombre Gris wrote:




Matt Todd wrote:


There's nothing wrong with staying true to the philosophy at all, I
just think that it may well be detrimental in the end. And that is
what I said in the (toilet)paper, that there will be (emphasis on the
eventuality, not on the present actuality) a time that PHP will become
the old stuff because it did not evolve with the philosophies.
 

It's true that a language that doesn't evolve with the market will 
die, but still you can expect us to follow any new trend because they 
believe it's the way to salvation. Try to think first if the new 
philosophies can be properly applied to this market, if they can bring 
a proper solution to our problems (if not they will become a new 
problem and we don't want that). Anyway, programming languages have 
proved to live longer that one could ever expect. Before attending to 
PHP's funeral, I'm pretty sure we'll be burying another die harder 
language, like the C language, in a very emotional ceremony (I can 
almost see it, someone will cry loudly: I'll miss using your 
precompiler macros!).



These philosophies are new and I can understand thinking that it's
hype, but it's important to recognize it as legitimate. Agile
Development (and the broader term Web 2.0) is, right now, the bleeding
edge of development, and I and many others see it as the future of
development philosophies.
 

Don't say it's good, prove it! All I can see in Web 2.0 is those 
guys are making more money than us, let's copy them!
Those guys are exploring uncharted area in web development and 
they're more worried in making their software work rather than 
worrying if the philosophy is appropiate or not. Still, marketing 
rules say no mather how unappropiate your company's philosophy is, 
it's the best. Of course they will say Web 2.0 is the best, is what 
they're doing and they don't want anyone to think they aren't giving 
the clients the best there is. And now we have to deal with even 
crazier request from our clients, like making an AJAX application in a 
week that supports all imaginable browsers in the market. They really 
believe that AJAX is a fucking walk in the park! AJAX is a fricking 
cocktail of death! Bring out the spaghetti code and let us feast on an 
eternal reengeneering cycle!



I'm not saying that Rasmus can't see, but that he will easily choose
to stay with how he sees the forest – understandable as I choose to
stay with what I see, but I think he has a lot invested in his view
and may not open up as easily.
 

Stop blaming the poor guy! He only made a tool he needed and was kind 
enough to share it with the world. If you want to blame someone for 
what direction PHP has taken, blame us! That's the whole point of PHP 
being open source, isn't it? All the current problems in PHP are 
directly or indirectly caused by whining developers and their 
extravagant requests. Magic quotes are bad? Well, teach those bastards 
to properly quote their sql's strings!


You think that currently PHP is being lead to unavoidable doom? By all 
means, be my guest and make PHP++, for all I care. The code it's there.



To Stut:

Honestly, I'd love to see basic variables be objects, as models of
real world data with properties for the data such as a $number-length
or $word-as_array() giving you letters.

 

Have you stop to think what the efficiency cost would be to make 
everything an object? We're already suffering much to avoid the 
waiting 2.5 second it's way too much cutline (they say we can't do 
real time applications) and you want to keep adding functionality that 
will deteriorate this? I love the way basic types are handled by PHP, 
I specially love PHP arrays, if you touch them, I fucking kill you!



I know that PHP is a functional language, and secondly, an OO
language, but I think that you can blend these things better and have
the OO brought to the forefront a bit more. Yes, I'm a fan of OO, but
I know that many people aren't and don't use PHP's OO (and don't when
it's appropriate). But I know you can integrate OO without having to
force the functional programmers to give up their way.

 

Have you been attending to your CS lessons? PHP is an *IMPERATIVE* 
language, and secondly, that the language provides OOP features 
doesn't make it an OO language. Maybe you have chosen your language 
wrongly, you should try JSP or any other Java based web server 
technology.


PS: I think you have the terms wrong. What you're calling functional 
programming may be what is usually known as procedural programming.



This is just ONE thing that could make PHP better and allow for more

[PHP] Validating XML

2006-04-21 Thread Brad Bonkoski

Hello,
Anyone have pointers to good tutorials out there for validating XML with 
DTD?

I have looked at the top comment on:
http://www.php.net/manual/en/ref.xmlreader.php#xmlreader.constants

Where you set the parser property to validate, but it is kind of like a 
black box...what is it using the validate the XML schema?  I am working 
with an XML document and a DTD file which is separate, do the files have 
to share a name with a different extension, or does the DTD somehow have 
to be embedded?


TIA
-Brad

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



Re: [PHP] how to get the absolute path of an included file?

2006-04-27 Thread Brad Bonkoski



Bing Du wrote:


Hello,

Here are the two scripts.  The result is 'var is' rather than 'var is
foo'.  My suspect is I did not set the file path right in 'include'.  So
in file2.php, how should I get the actual absolute path it really gets for
file1.php?  Is it stored in some environment variable or something?  I'd
appreciate any help.

file1.php

==
?php
$var = 'foo';
?
==

file2.php

==
?php

include '/some/path/file1.php';
 

global $var; //you have to declare it as a global otherwise it will 
assume a local value



echo var is $var;
?
==

Thanks,

Bing

 



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



Re: [PHP] chop x amount of characters from the begining of a string

2006-05-02 Thread Brad Bonkoski

Perhaps this will work..
http://www.php.net/manual/en/function.substr.php


Ross wrote:

I have a word say 'example' I want to chop of two or 3 chacters from the 
front to leave 'ample' or 'mple'. Is there a php function to do this?



Ross 

 



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



Re: [PHP] Searching and getting values out of array maps

2006-05-03 Thread Brad Bonkoski

Here's a stab...

$colors = array(red=#ff,gree=#00ff00,blue=#ff);
echo $colors[blue];

should output #ff
HTH
-Brad

Jonas Rosling wrote:


Hi all,
I'm kind of new with PHP. I work alot with another language called Lasso,
reminds kind of PHP but not the same.
I trying to search after a desired value within an array map (think you call
it like that in PHP) and to get the value out as well.

Is this possible in any way? Like to show you how it works in Lasso while
I'm talking about.

Could look like this:

?LassoScript

   var: 'colors'=(map: 'red'='#ff',
'green'='#00ff00','blue'='#ff');
   output: $clors-(find: 'blue');

?

The result you get is #ff.

Can you do something like this with PHP. Would help me alot if anyone could
help me out a bit.

Thanks in advance // Jonas

 



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



Re: [PHP] array_push in array maps

2006-05-03 Thread Brad Bonkoski

I don't believe you 'push' to an associative array like this,
but if you want to add black for example...just do:
$colors['black'] = '#ff';

-Brad

Jonas Rosling wrote:


Need solve another case regarding array maps. Is it possible to insert more
values like with array_push in arrays as bellow?

$colors = array(
 'red' = '#ff',
 'green' = 'X00ff00',
 'blue' = '#ff'
  );

Tanks in advance // Jonas

 



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



Re: [PHP] array_push in array maps

2006-05-03 Thread Brad Bonkoski

or white ;-)

Stut wrote:


Brad Bonkoski wrote:


$colors['black'] = '#ff';




Black? Are you sure?

-Stut




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



Re: [PHP] array_push in array maps

2006-05-03 Thread Brad Bonkoski

What kind of values are stored in $row[2] and $row[5]?

You might need to keep the single quotes
$test['$row[2]'] = $row[5];

-Brad

Jonas Rosling wrote:


There's allways mutch to learn. :-) I'm very happy for all help I can get.
I ran into another problem when trying to insert a value.
I had no problem with:

   $test['something'] = '2500';

But when I want to have a value from a special column i a row the followint
doesn't work:

   $test[$row[2]] = $row[5];

Or:

   $test[$row(2)] = $row[5];

Do I need to do some kind of concatenating?

Thanks again // Jonas



Den 06-05-03 15.46, skrev Jochem Maas [EMAIL PROTECTED]:

 


Jonas Rosling wrote:
   


Need solve another case regarding array maps. Is it possible to insert more
 


Jonas - in php we just call these things arrays (no 'map') - the array
datatype in php is a mash up (and we love it :-) of the 'oldschool'
numerically
indexed array and what is commonly known as a hash (or arraymap) - you can mix
numeric and associative indexes freely (that might seem odd and/or bad when
coming
from another language but it really is fantastic once you get your head round
it).

   


values like with array_push in arrays as bellow?

$colors = array(
 'red' = '#ff',
 'green' = 'X00ff00',
 'blue' = '#ff'
  );

 


sure:

$colors['grey'] = '#dedede';

the position of the 'inserted' (actually appended) is often not
important - if it is there are plenty of functions that allow you to
manipulate
arrays in more a complex fashion e.g. array_splice(). and all sorts of sorting
functions are also available e.g. asort().

check out the vast number of array related function and introductory texts
here:

http://php.net/array
http://php.net/manual/language.types.array.php

   


Tanks in advance // Jonas

 



   



 



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



Re: [PHP] Avoiding user refresh of pages with forms

2006-05-03 Thread Brad Bonkoski
Is there a way to key off of the data inserted?  Like some unique value 
or set of values that you can do a quick lookup before you 
insert/update/delete again...
Or you could venture into an AJAX style of submission keyed off of a 
button click then a refresh to a 'report' page, in which case no POST 
variables are actually passed to the report page, so refreshing it will 
just present the same data...


-Brad

Jeff wrote:


Is there a way to prevent a re-posting of the form data when a user
pushes the refresh button on the browser?

I have a page that has a form to enter credit's or debit's to a user
account.  The top of the page displays the users account history and at
the bottom is a form to add an adjustment. I just had a situation where
a user came in complaining that the database is out of control every
time I REFRESH the page the credit I put in gets added again and
again!!  He also claimed he was getting no warning message about that
which was of course false, he just didn't read it.

In any event, I need to make this more user proof.

Thanks,

Jeff

 



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



Re: [PHP] Echo a value from an arrays position

2006-05-04 Thread Brad Bonkoski
Will this also work with an associative array?  If this is what he is 
talking about, I tried it and it does not work


I put this together though and it works, not sure if it is the *best* 
way though...


?php
   $colors = 
array('white'='#ff','black'='#00','blue'='#ff');


   $count = 0;
   foreach( $colors as $k = $v) {
   $count++;
   if( $count == 2 )
   echo \$colors[$k] = $v.\n;
   }
?

-Brad

Jay Blanchard wrote:


[snip]
Is there any way to call for an element value in an array by the
position?
Like position 2 in the array and not the key name.
[/snip]

I hate to say this, but you really need to RTFM http://www.php.net/array

To get a value from position 2 in an array you use $arrayName[1] (all
array elements start numbering at 0, unless you do something to the
array to change it).

 



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



Re: [PHP] can't work out the syntax error

2006-05-04 Thread Brad Bonkoski



Ross wrote:


Hi,

The line was this.

  echo TD WIDTH=\25%\ ALIGN=\CENTER\
   A 
HREF=\javascript:open_window('$PHP_SELF?action=view_recorduserid=$userid');\View/A
   A HREF=\$PHP_SELF?action=delete_recorduserid=$userid\ 
onClick=\return confirm('Are you sure?');\Delete/A/TD\n;



I have registered globals off so tried this...

echo TD WIDTH=\25%\ ALIGN=\CENTER\
   A 
HREF=\javascript:open_window('$_SERVER['PHP_SELF']?action=view_recorduserid=$userid');\View/A


 


I would go with your second option here...

try this:

echo TD WIDTH=\25%\ ALIGN=\CENTER\
   A 
HREF=\javascript:open_window('.$_SERVER['PHP_SELF'].?action=view_recorduserid=$userid');\View/A


---^---^
concatenate the $_SERVER variable to the string...
HTH
-Brad


What is the problem with it?


R. 

 



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



Re: [PHP] Echo a value from an arrays position

2006-05-04 Thread Brad Bonkoski

I get nothing
do you get something different?

Jay Blanchard wrote:


[snip]
$colors =
array('white'='#ff','black'='#00','blue'='#ff');
[/snip]

What happens when you echo $colors[1]? 



 



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



Re: [PHP] Echo a value from an arrays position

2006-05-04 Thread Brad Bonkoski

Nope... dead air.

Of course getting an indexed value into an associative array seems a bit 
odd to me... maybe Jonas could shed some light on why he would go this 
route...



Jay Blanchard wrote:


[snip]
I get nothing
do you get something different?
[/snip]

Not even 'array'?


 



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



Re: [PHP] PHP URL query

2006-05-10 Thread Brad Bonkoski

?php
$var = $_GET['var'];
echo( Welcome to our Web site, $var! );
?

-B

IraqiGeek wrote:


Hi all,

I'm somewhat new to php, though I have played a bit with the language. 
I'm currently learning the language, and I'm having a problem passing 
variables through URL query. Here is what I have:


A simple HTML file that contains:
A HREF=test.php?var=test Hi, this is a test! /A

and a php file that contains:
?php
echo( Welcome to our Web site, $var! );
?

However, when I click on the link on the HTML file, I dont get the 
value of $var passed to the php script. I have also tried passing 
multiple variables separated by , and none of those gets passed to 
the php script.


The files are hosted on a local Debian etch server running apache 
2.0.54 and php 4.3.10.


Is there something I need to check/change in the config files of 
apache or php?



Regards,
IraqiGeek
www.iraqigeek.com

Boat: A hole in the water surrounded by wood into which one pours money.



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



Re: [PHP] Paged Results Set in MySQL DB with one result

2006-05-12 Thread Brad Bonkoski

In Exploder 7 beta 2 I actually get an access denied error...
but works in firefox.

Mike wrote:


I am not seeing a blank page here.

Porpoise wrote:



tedd [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]




Try this:

http://xn--ovg.com/ajax_page1

Please understand: a) It's a rough estimation as to how many 
characters will fit; b) It doesn't handle zoom levels well yet; c) 
There will be variations between browsers and OS's --  but the 
solution is within reach.




Eerrrm... Blank Page!?!





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



Re: [PHP] Back arrow button

2006-05-12 Thread Brad Bonkoski

Not really a PHP question...

But, since it is Friday ;-)
As our friend Google:
http://www.google.com/search?hl=enq=Javascript+disable+back+button

HTH
-Brad

Sugrue, Sean wrote:


Does anyone know how to launch a new page with having the back arrow
button grayed out?

Sean

 



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



Re: [PHP] Handling Large Check Box Data

2006-05-17 Thread Brad Bonkoski
Well, listing all the values in a comma separated list in the DB would 
be fairly simple to parse, check out:

http://www.php.net/manual/en/function.explode.php

As far as what is better depends on many things...
1). Maintaining the code, might be better to have each check box have 
its own field, will certainly cut down on development/debugging.
2). Performance...don't know if it is faster for PHP to parse through a 
comma separated list or parse through a larger DB record set. I guess if 
this is really important to you, you might want to attempt both ways to 
see on performance.


-Brad



Rahul S. Johari wrote:


Ave,

I¹m a little confused as to what¹s the best way to handle this.
I have a form which, apart from lots of other fields, has a set of 25 ­ 30
Check Boxes, each of which asks the user for some kind of information which
the user can check or leave unchecked.
The information each Check Box collects will also appear in the ³Listing²
for users to view once the user has completed  submitted the form.
Furthermore, there is an Advanced Search also available to users which will
also provide the same 25 - 30 check boxes which define the search criteria.
I¹m not sure what¹s the best, most efficient way to do this.

The tedious way to do this is to make 30 fields in the mySQL database, and
if the check box is checked, the data goes into the corresponding field...
And similarly listing the data from the field if field is non-empty And
similarly including each field in the Search options.

I want suggestions for a better/faster way to do this. I did think about
creating a single field and storing the data from each Œchecked¹ check box
as comma separated values in the single field. I¹m not sure how to do that
and if that¹s the best way But even if I can, I¹m not sure how to get
the data to display separately out of that field in the Listings view and
more importantly how to include that data in the Search options.

Any help would be appreciated.

Thanks, 


Rahul S. Johari
Coordinator, Internet  Administration
Informed Marketing Services Inc.
500 Federal Street, Suite 201
Troy NY 12180

Tel: (518) 687-6700 x154
Fax: (518) 687-6799
Email: [EMAIL PROTECTED]
http://www.informed-sources.com


 



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



Re: [PHP] storing single and double quote in MySQL

2006-05-22 Thread Brad Bonkoski

Looks good to me, just make sure you use:
http://www.php.net/manual/en/function.stripslashes.php
if you have to dump that information back to the users.
(you might want to check out: addslashes() to add the slashes before 
your DB insert, just to keep those things under your command)

-Brad

[EMAIL PROTECTED] wrote:


Hi to all!
After the form is submitted, some fields are filled with single and/or
double quote info (like: 1'2x2'4, or sky's blue, or cool stuff).
I validate what I got using mysql_real_escape_string() and then store the
result in MySQL. And, it will be stored as:1\'2\x2\'4\, and sky\'s blue,
and \cool\ stuff.
Is this correct way or correct way will be to convert quotes in html
entities? If yes, means have to use htmlentities($Size, ENT_QUOTES)?

Thanks for any thoughts!

-afan

 



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



Re: [PHP] storing single and double quote in MySQL

2006-05-22 Thread Brad Bonkoski



Richard Lynch wrote:


On Mon, May 22, 2006 11:37 am, Brad Bonkoski wrote:
 


http://www.php.net/manual/en/function.stripslashes.php
if you have to dump that information back to the users.
   



If you are using http://php.net/stripslashes on data coming out of
your database, you are DEFINITELY doing something wrong acquiring that
data.

Stripslashes is correctly used ONLY when:
1. You have Magic Quotes on, and
2. You need to display/use the incoming data for something other than
MySQL in the same script that does the INSERT


Even then, you really ought to turn off Magic Quotes and migrate to
http://php.net/mysql_real_escape_string

 

Thanks for your constructive criticism Sorry for the original bad 
advice.


So, when the magic_quotes goes away in future version, with 
stripslashes() also go away?


-Brad

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



Re: [PHP] getting subdirectory

2006-05-23 Thread Brad Bonkoski

Perhaps check out some of these
http://www.php.net/manual/en/reserved.variables.php#reserved.variables.server
-Brad

Dallas Cahker wrote:

how do I get the subdirectory that a page is being pulled from.

say I have three sites running the same script and I need to determine 
which

site is which.

http://www.domain.com/subdir1
http://www.domain.com/subdir2
http://www.domain.com/subdir3

and subdir1, subdir2 and subdir3 all need different header and 
different db

and so on.

how would i get that I am in site subdir3 and not in subdir1?



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



Re: [PHP] storing single and double quote in MySQL

2006-05-24 Thread Brad Bonkoski

in your php.ini file what is the value of:
magic_quotes_gpc?
(hint: should be off, if it is on, then you are add slashes twice...)
-Brad

[EMAIL PROTECTED] wrote:


ok. I just made one test and if you can then explain something to me:
I entered in form (textarea)
afan's crazy web
and stored in db using mysql-real_escape_string().
in DB, it's stored with slashes:
afan\'s \crazy\ web

Then I pulled that from DB on three different ways:
$query = mysql_query(select test from dbtest where rec_id = 5);
$result = mysql_fetch_array($query);
echo $result['gen_value'];  //  gives afan\'s \crazy\ web
echo stripslashes($result['gen_value']);//  gives afan's 
crazy web
echo htmlentities($result['gen_value']);//  gives afan\'s 
\crazy\ web

if stripslashes() is not correcct to use - what then?!?

-afan



 


[EMAIL PROTECTED] wrote:
   


after these very helpfull comments, I rad (again) Shiflett's (and few
others) Security articles about filtering input and output. And more I
read - less is clear :(

Before, I used addslash() before I insert data in database and
strislshe()
to show them on screen.

Later found it's not good and start using mysql_real_escae_string() to
add
to DB and stripslashe() to show on screen.
 


If you have to stripslashes() when you pull data out of the db, you're
doing something wrong (like running with magic_quotes* on, therefore
double escaping your data).

   


But, also, I thought, mysql_real_escape_string() is filter for
everything, e.g. lets have three links (add, delete, edit) as
 


mysql_real_escape_string() *only* escapes the data which needs to be
escaped for your particular db version.

   


a href=index.php?action=addrec_id=$rec_idAdd new/a
a href=index.php?action=editrec_id=$rec_idEdit/a
a href=index.php?action=deleterec_id=$rec_idDelete/a
and was doing this way:
#index.php
?php
if($_GET['action'])
{
$action = mysql_real_escape_string($_GET['action']);
$rec_id = mysql_real_escape_string($_GET['rec_id']);
switch($action)
{
case 'add':
// add new record
break;

case 'edit':
// edit record
break;

case 'delete':
// delete record
break;
}
}
?

it means that $action I will never store in DB, neither show on screen.
I
then wrong to
$action = mysql_real_escape_string($_GET['action']);
or I should
$action = htmlentities($_GET['action']);
or
$action = $_GET['action'];
is just fine?
 


If you're not going to display it or insert it...if all you're doing is
checking the value of it, then you don't need to modify it.

--
John C. Nichel IV
Programmer/System Admin (ÜberGeek)
Dot Com Holdings of Buffalo
716.856.9675
[EMAIL PROTECTED]

--
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



  1   2   3   >