Re: [PHP-DB] Define constants: awkward usage?

2005-01-26 Thread Jochem Maas
tony wrote:
Hi all,
I got this sets(20) of defined constants which using them as keys to an
array
eg
define(FNAME, fname);
farray = array( FNAME = hello ,...);
my question is how do I insert that directly into a javascript(to do
some client validation)
I need this:
var fname = document.addrform.fname.value
var fname = document.addrform.{FName}.value//don't work
var fname = document.addrform.{'FName'}.value//don't work
var fname = document.addrform.[FName].value//don't work
I know this work, but messey
$tmp = FNAME;
var fname = document.addrform.{$tmp}.value
you could try sprintf()/printf():
$output = sprintf('var fname = document.addrform.%s.value', FNAME );
or
printf('var fname = document.addrform.%s.value', FNAME );
I'am finding the use of define constants rather awkward. does anyone
make much use of them?
yes. :-) for...
session varnames
post/get varnames
bitwise flags
er...?
Thanks
Tony
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] Define()

2003-03-18 Thread Edwin Boersma
Where is the $-sign in front of the vars???

Edwin

Jonathan Villa wrote:
Jim, 
 
I don't think that matters.  One can escape into PHP in several ways
(depending on the php.ini config of course)
 
1.	?php
2.	?
3.	script language=php
4.	%
5.	?= (to echo something right away)
 
Anyway, I tried that and it still doesn't work. 
 
--- Jonathan
 
 
 
-Original Message-
From: Jim Hunter [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, March 12, 2003 2:59 PM
To: [EMAIL PROTECTED]
Subject: RE: [PHP-DB] Define()
 

Looking at your source you are still missing the php in the script. it
has to look like:
 
form action=?php echo CTL_HOME_ROOT ? method=POST
note the php |||
 
add this and try it again.
Jim

 

 
 
 
 
 
 
 

 
 
 
 



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


RE: [PHP-DB] Define()

2003-03-18 Thread Jonathan Villa
Edwin, 

There is no $ in front of the vars because it's a constant.  $ signifies
a variable.  A variable's value can change, a constant's value cannot.

 
--- Jonathan
 
 
 
-Original Message-
From: Edwin Boersma [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, March 18, 2003 2:43 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] Define()

Where is the $-sign in front of the vars???

Edwin

Jonathan Villa wrote:
 Jim, 
  
 I don't think that matters.  One can escape into PHP in several ways
 (depending on the php.ini config of course)
  
 1.?php
 2.?
 3.script language=php
 4.%
 5.?= (to echo something right away)
  
 Anyway, I tried that and it still doesn't work. 
  
 --- Jonathan
  
  
  
 -Original Message-
 From: Jim Hunter [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, March 12, 2003 2:59 PM
 To: [EMAIL PROTECTED]
 Subject: RE: [PHP-DB] Define()
  
 
 Looking at your source you are still missing the php in the script. it
 has to look like:
  
 form action=?php echo CTL_HOME_ROOT ? method=POST
 note the php |||
  
 add this and try it again.
 Jim
 
  
 
 
  
  
  
  
  
  
  
 
 
  
  
  
  
 


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


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



Re: [PHP-DB] Define()

2003-03-12 Thread Jim Hunter
The reason it doesn't work may go beyond PHP. You are trying to make an HREF
point to an exact location on your hard drive. When the user of your web
page clicks the link, they do not have that location on their system so it
will fail. Always use relative locations for links. Then once you get that
ironed out, skip the defines, just use the variables. Change the code to be:
 
$doc_dir = /store/;
$image_dir = /images/;
$control_dir = /control/;

?php echo $control_dir ?verify_login.php
a href=?php echo $doc_dir ?click here/a
 
and don't forget the 'php' after the ?
 
Jim Hunter
 
---Original Message---
 
From: [EMAIL PROTECTED]
Date: Wednesday, March 12, 2003 10:51:04 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Define()
 
I am developing an app which needs 3 constants. The value of these
constants comes from a database result.

This works fine. My problem is that they do not work very well. I am
developing on both windows/Linux (depending what I boot into).

This is the effect I want

$doc_dir = the string of d:/is/clients/client/web/store/
$image_dir = the string of d:/is/clients/client/web/images/
$control_dir = the string of d:/is/clients/client/web/control/ 

define(HOME_DOC_ROOT,$doc_dir);
define(IMAGE_DOC_ROOT,$image_dir);
define(CONTROL_DOC_ROOT,$control_dir);

The outcome is that 

1. I cannot submit pages using action=? echo CONTROL_DOC_ROOT
?verify_login.php
2. I cannot use links as a href=? echo $DOC_HOME_ROOT ?click
here/a

Has anyone had a lot of use with define and in my scenario. I don't the
problem is with the db results, I think it's more of the define().

Like I said above, I am using this on linux as well as windows.



==
Every chance I get, I try to incorporate 
Open Source resources into my everyday
work. Maybe instead of of paying Microsoft
for software, the money can added to my
salary.
==



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

. 

RE: [PHP-DB] Define()

2003-03-12 Thread Jonathan Villa
Jim,

Thanks for reply.

I haven't moved this into production yet, the d:/is/ was just for
testing as well as because when I use /client_name, the links do not
work.

I will to use the variable names instead of the define and see where
this gets me.

Just to note, I tried 

define(IMG_HOME_ROOT, /client_name/web/images/);

and it didn't work

What would be the difference between using that and

$img_dir = /client_name/web/images/;

 
--- Jonathan
 
 
 

-Original Message-
From: Jim Hunter [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, March 12, 2003 12:58 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re: [PHP-DB] Define()

The reason it doesn't work may go beyond PHP. You are trying to make an
HREF
point to an exact location on your hard drive. When the user of your web
page clicks the link, they do not have that location on their system so
it
will fail. Always use relative locations for links. Then once you get
that
ironed out, skip the defines, just use the variables. Change the code to
be:

 

$doc_dir = /store/;

$image_dir = /images/;

$control_dir = /control/;



?php echo $control_dir ?verify_login.php

a href=?php echo $doc_dir ?click here/a

 

and don't forget the 'php' after the ?

 

Jim Hunter

 

---Original Message---

 

From: [EMAIL PROTECTED]

Date: Wednesday, March 12, 2003 10:51:04 AM

To: [EMAIL PROTECTED]

Subject: [PHP-DB] Define()

 

I am developing an app which needs 3 constants. The value of these

constants comes from a database result.



This works fine. My problem is that they do not work very well. I am

developing on both windows/Linux (depending what I boot into).



This is the effect I want



$doc_dir = the string of d:/is/clients/client/web/store/

$image_dir = the string of d:/is/clients/client/web/images/

$control_dir = the string of d:/is/clients/client/web/control/ 



define(HOME_DOC_ROOT,$doc_dir);

define(IMAGE_DOC_ROOT,$image_dir);

define(CONTROL_DOC_ROOT,$control_dir);



The outcome is that 



1. I cannot submit pages using action=? echo CONTROL_DOC_ROOT

?verify_login.php

2. I cannot use links as a href=? echo $DOC_HOME_ROOT ?click

here/a



Has anyone had a lot of use with define and in my scenario. I don't the

problem is with the db results, I think it's more of the define().



Like I said above, I am using this on linux as well as windows.







==

Every chance I get, I try to incorporate 

Open Source resources into my everyday

work. Maybe instead of of paying Microsoft

for software, the money can added to my

salary.

==







-- 

PHP Database Mailing List (http://www.php.net/)

To unsubscribe, visit: http://www.php.net/unsub.php



. 


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



RE: [PHP-DB] Define()

2003-03-12 Thread Jonathan Villa
For starters, and in general, does anyone know why a view source would
not work in IE 6?  This hasn't worked for weeks, so I usually have to
use Mozilla to view the source.  
 
Anyway, Jim, this is my basic page setup.
 
?php
include_once(../common/store_config.php);
include_once(HOME_DOC_ROOT.common/header.php);
?
This is where my HTML codes goes.
So for example, a link to another page would look like this
a href=? echo DOC_HOME_ROOT ?stuff/index.phplink/a
 
a form would look like this
 
form action=? echo CTL_HOME_ROOT ? method=POST
/form
?php
include_once(HOME_DOC_ROOT.common/footer.php);
?
 
Note: within store_config.php I am declaring the constants along with
including some other files which I reference. For example, there is a
file called system_messages.php from which I pull system messages like
Item was added to your cart, Please enter in all the required
information, etc.
 
Currently I have the constant IMG_HOME_PATH set to
/killerspin/web/images/ and everything is fine.
 
For DOC_HOME_PATH I have /killerspin/web/store/ but I get all kinds of
errors like could not create stream.
 
Specifically
 
Here is the code.
 
?php
include_once(common/store_config.php);
include_once(DOC_HOME_PATH.common/header.php);
?
p class=contentThis is the index page./p
?php
include_once(DOC_HOME_PATH.common/footer.php);
?
 
 and here is the output
 
Warning: main(/killerspin/web/store/common/header.php) [function.main
http://www.php.net/function.main ]: failed to create stream: No such
file or directory in D:\is\clients\killerspin\web\store\index.php on
line 3
 
So I replace the code with this, 
 
include_once(/killerspin/web/store/common/header.php);
 
Same thing happens, but if I put
 
include_once(http://localhost/killerspin/web/store/common/header.php;);
then it's fine BUT the images don't show and I haven't changed a thing
on the for IMG_HOME_PATH!!
 
So in summary, maybe my question should have started with
 
How can I correctly use constants/variables to substitute for the
directory path so that I don't have to always include the entire path.
For example, in the event that my image directory changes or a directory
changes from login to register, then I don't want to have to go into
EVERY SINGLE  page and line of code to change it.
 
 
--- Jonathan
 
 
 


RE: [PHP-DB] Define()

2003-03-12 Thread Hutchins, Richard
Yes! I ran into this once and it stumped me for a while. You need to delete
the temporary internet files directory on the machine where you're viewing
the source. Took me three days of looking on microsoft.com to figure that
one out. 

I'm not proud.

 -Original Message-
 From: Jonathan Villa [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, March 12, 2003 3:21 PM
 To: [EMAIL PROTECTED]
 Subject: RE: [PHP-DB] Define()
 
 
 For starters, and in general, does anyone know why a view source would
 not work in IE 6?  This hasn't worked for weeks, so I usually have to
 use Mozilla to view the source.  
  
 Anyway, Jim, this is my basic page setup.
  
 ?php
 include_once(../common/store_config.php);
 include_once(HOME_DOC_ROOT.common/header.php);
 ?
 This is where my HTML codes goes.
 So for example, a link to another page would look like this
 a href=? echo DOC_HOME_ROOT ?stuff/index.phplink/a
  
 a form would look like this
  
 form action=? echo CTL_HOME_ROOT ? method=POST
 /form
 ?php
 include_once(HOME_DOC_ROOT.common/footer.php);
 ?
  
 Note: within store_config.php I am declaring the constants along with
 including some other files which I reference. For example, there is a
 file called system_messages.php from which I pull system 
 messages like
 Item was added to your cart, Please enter in all the required
 information, etc.
  
 Currently I have the constant IMG_HOME_PATH set to
 /killerspin/web/images/ and everything is fine.
  
 For DOC_HOME_PATH I have /killerspin/web/store/ but I get all kinds of
 errors like could not create stream.
  
 Specifically
  
 Here is the code.
  
 ?php
 include_once(common/store_config.php);
 include_once(DOC_HOME_PATH.common/header.php);
 ?
 p class=contentThis is the index page./p
 ?php
 include_once(DOC_HOME_PATH.common/footer.php);
 ?
  
  and here is the output
  
 Warning: main(/killerspin/web/store/common/header.php) [function.main
 http://www.php.net/function.main ]: failed to create stream: No such
 file or directory in D:\is\clients\killerspin\web\store\index.php on
 line 3
  
 So I replace the code with this, 
  
 include_once(/killerspin/web/store/common/header.php);
  
 Same thing happens, but if I put
  
 include_once(http://localhost/killerspin/web/store/common/hea
 der.php);
 then it's fine BUT the images don't show and I haven't changed a thing
 on the for IMG_HOME_PATH!!
  
 So in summary, maybe my question should have started with
  
 How can I correctly use constants/variables to substitute for the
 directory path so that I don't have to always include the 
 entire path.
 For example, in the event that my image directory changes or 
 a directory
 changes from login to register, then I don't want to have to go into
 EVERY SINGLE  page and line of code to change it.
  
  
 --- Jonathan
  
  
  
 

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



RE: [PHP-DB] Define()

2003-03-12 Thread Hutchins, Richard
Let me amend that, you need to delete the FILES from the temporary internet
files directory, not the directory itself. Sorry.

 -Original Message-
 From: Hutchins, Richard [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, March 12, 2003 3:25 PM
 To: '[EMAIL PROTECTED]'; [EMAIL PROTECTED]
 Subject: RE: [PHP-DB] Define()
 
 
 Yes! I ran into this once and it stumped me for a while. You 
 need to delete
 the temporary internet files directory on the machine where 
 you're viewing
 the source. Took me three days of looking on microsoft.com to 
 figure that
 one out. 
 
 I'm not proud.
 
  -Original Message-
  From: Jonathan Villa [mailto:[EMAIL PROTECTED]
  Sent: Wednesday, March 12, 2003 3:21 PM
  To: [EMAIL PROTECTED]
  Subject: RE: [PHP-DB] Define()
  
  
  For starters, and in general, does anyone know why a view 
 source would
  not work in IE 6?  This hasn't worked for weeks, so I 
 usually have to
  use Mozilla to view the source.  
   
  Anyway, Jim, this is my basic page setup.
   
  ?php
  include_once(../common/store_config.php);
  include_once(HOME_DOC_ROOT.common/header.php);
  ?
  This is where my HTML codes goes.
  So for example, a link to another page would look like this
  a href=? echo DOC_HOME_ROOT ?stuff/index.phplink/a
   
  a form would look like this
   
  form action=? echo CTL_HOME_ROOT ? method=POST
  /form
  ?php
  include_once(HOME_DOC_ROOT.common/footer.php);
  ?
   
  Note: within store_config.php I am declaring the constants 
 along with
  including some other files which I reference. For example, 
 there is a
  file called system_messages.php from which I pull system 
  messages like
  Item was added to your cart, Please enter in all the required
  information, etc.
   
  Currently I have the constant IMG_HOME_PATH set to
  /killerspin/web/images/ and everything is fine.
   
  For DOC_HOME_PATH I have /killerspin/web/store/ but I get 
 all kinds of
  errors like could not create stream.
   
  Specifically
   
  Here is the code.
   
  ?php
  include_once(common/store_config.php);
  include_once(DOC_HOME_PATH.common/header.php);
  ?
  p class=contentThis is the index page./p
  ?php
  include_once(DOC_HOME_PATH.common/footer.php);
  ?
   
   and here is the output
   
  Warning: main(/killerspin/web/store/common/header.php) 
 [function.main
  http://www.php.net/function.main ]: failed to create 
 stream: No such
  file or directory in D:\is\clients\killerspin\web\store\index.php on
  line 3
   
  So I replace the code with this, 
   
  include_once(/killerspin/web/store/common/header.php);
   
  Same thing happens, but if I put
   
  include_once(http://localhost/killerspin/web/store/common/hea
  der.php);
  then it's fine BUT the images don't show and I haven't 
 changed a thing
  on the for IMG_HOME_PATH!!
   
  So in summary, maybe my question should have started with
   
  How can I correctly use constants/variables to substitute for the
  directory path so that I don't have to always include the 
  entire path.
  For example, in the event that my image directory changes or 
  a directory
  changes from login to register, then I don't want to have to go into
  EVERY SINGLE  page and line of code to change it.
   
   
  --- Jonathan
   
   
   
  
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

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



RE: [PHP-DB] Define()

2003-03-12 Thread Jonathan Villa
Jim, 
 
I don't think that matters.  One can escape into PHP in several ways
(depending on the php.ini config of course)
 
1.  ?php
2.  ?
3.  script language=php
4.  %
5.  ?= (to echo something right away)
 
Anyway, I tried that and it still doesn't work. 
 
--- Jonathan
 
 
 
-Original Message-
From: Jim Hunter [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, March 12, 2003 2:59 PM
To: [EMAIL PROTECTED]
Subject: RE: [PHP-DB] Define()
 

Looking at your source you are still missing the php in the script. it
has to look like:
 
form action=?php echo CTL_HOME_ROOT ? method=POST
note the php |||
 
add this and try it again.
Jim

 


 
 
 
 
 
 
 


 
 
 
 


Re: [PHP-DB] define variable by querying MySQL

2001-07-02 Thread Dobromir Velev

Hi,
I'm not sure what were you trying to do but there are some very obvious
errors

1. You cannot embed one php openning tag (?) in another
2. mysql_numrows() is not a valid mysql function - may be you were trying to
use mysql_num_rows()

If you are trying to put all fields my_name into the $WELCOME variable (I
can't think of a reason to do this) and then echo it may be you could use
this code

#start code
?
$link = mysql_connect(localhost,username,password) or die (Could not
connect to MySQL!);
mysql_select_db(database,$link);
$result = mysql_query(select * from table_name);
while ($row=mysql_fetch_array($result)){
$WELCOME.=$row[my_name];
}
echo $WELCOME;
?
#end code

Dobromir Velev


-Original Message-
From: Matt Nigh [EMAIL PROTECTED]
To: [EMAIL PROTECTED] [EMAIL PROTECTED]
Date: Monday, July 02, 2001 1:01 AM
Subject: [PHP-DB] define variable by querying MySQL


hello list. i have a problem that is relatively simple, but I can't seem to
figure it out.
is there any way to define a variable by querying a MySQL database?
here's an example of code I tried using:


?
$WELCOME = 
echo ?php
$link = mysql_connect(localhost,username,password);
if(!$link) die (Could not connect to MySQL!);
mysql_select_db(database,$link);
$result = mysql_query(select * from table_name);
$num=mysql_numrows($result);
for($x=0;$x$num;$x++) {
$row=mysql_fetch_object($result);
print $row-my_name;
}
mysql_close($link);
?
;
;
?

? echo($WELCOME); ?





it kept coming up with the following :


Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or
`T_NUM_STRING' in c:\apache group\apache\htdocs\page.php on line 5



i can't figure out what to do, so if anyone can assist me, i'd be greatful.
I have a feeling it's something with some quotes but i can't figure out
which ones.


Thanks a lot,


Matt Nigh
[EMAIL PROTECTED]








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