RE: [PHP-DB] php variables to JS

2003-01-05 Thread Rich Hutchins
From what I have learned PHP and JS don't talk directly to each other.
Instead, you have to make hidden fields in your html that hold the values
from your database then access those hidden fields with JS. If you want to
take values from JS and use them in a PHP script, then the process is
reversed; make hidden fields, set their values with JS then pass the hidden
fields to a PHP script.

In your case the relevant (abbreviated and untested) PHP code might look
like this:
?php
//where $dbWindowHeight is avariable that has been assigned a value from
your db query
echo form.
input type=\hidden\ value=\.$dbWindowHeight.\.
/form;
?

The relevant JS might look something like this:
var height = document.form.windowHeight.value;

Then for your window.open JS call, you'd substitute the var named height
into the string with the rest of the chromeless information.

If anybody knows an easier way, please post it because I'd love an easier
alternative if one exists.

Hope this helps. If not, I know there's a wealth of info in the PHP archives
about this subject. That's where I learned.

Rich

-Original Message-
From: Bruce Levick [mailto:[EMAIL PROTECTED]]
Sent: Sunday, January 05, 2003 2:09 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] php variables to JS


Bruce Levick - VivamotionI am opening a chromless window with some JS code.
I need to pass some variables which come from rows in my database into the
jscript which will determine the size and URL of the window.

Before I go about drawing the info from the database I have set up some hard
code php variables just so i could test how to pass these into js.

Does anybody know how I can code these variables into my jscript??

Cheers

##
?php
$h = 600;
$w = 343;
$theURL = test.php;
$wname = test;
?
###

##
script language=javaScript type=text/javascript
SRC=js/java.js/SCRIPT

script
!--
function openIT() {
theURL=wesley.php//php variable here
wname =CHROMELESSWIN  //php variable here
W=300;  //php variable here
H=100;  //php variable here
windowCERRARa = images/close_a.gif
windowCERRARd = images/close_d.gif
windowCERRARo = images/close_o.gif
windowNONEgrf = images/none.gif
windowCLOCK = images/clock.gif
windowREALtit = nbsp;? Task title
windowTIT = font face=verdana size=1nbsp;your chromless/font
windowBORDERCOLOR = #00
windowBORDERCOLORsel = #00
windowTITBGCOLOR = #FF0033
windowTITBGCOLORsel = #FF0033
openchromeless(theURL, wname, W, H, windowCERRARa, windowCERRARd,
windowCERRARo, windowNONEgrf, windowCLOCK, windowTIT, windowREALtit ,
windowBORDERCOLOR, windowBORDERCOLORsel, windowTITBGCOLOR,
windowTITBGCOLORsel)
}
//--
/script
##



--
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] php variables to JS

2003-01-05 Thread Bryan McLemore
Could always pass it through a hidden form.

Bryan


-Original Message-
From: Bruce Levick [mailto:[EMAIL PROTECTED]] 
Sent: Sunday, January 05, 2003 1:09 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] php variables to JS

Bruce Levick - VivamotionI am opening a chromless window with some JS
code.
I need to pass some variables which come from rows in my database into
the
jscript which will determine the size and URL of the window.

Before I go about drawing the info from the database I have set up some
hard
code php variables just so i could test how to pass these into js.

Does anybody know how I can code these variables into my jscript??

Cheers

##
?php
$h = 600;
$w = 343;
$theURL = test.php;
$wname = test;
?
###

##
script language=javaScript type=text/javascript
SRC=js/java.js/SCRIPT

script
!--
function openIT() {
theURL=wesley.php//php variable here
wname =CHROMELESSWIN  //php variable here
W=300;  //php variable here
H=100;  //php variable here
windowCERRARa = images/close_a.gif
windowCERRARd = images/close_d.gif
windowCERRARo = images/close_o.gif
windowNONEgrf = images/none.gif
windowCLOCK = images/clock.gif
windowREALtit = nbsp;? Task title
windowTIT = font face=verdana size=1nbsp;your chromless/font
windowBORDERCOLOR = #00
windowBORDERCOLORsel = #00
windowTITBGCOLOR = #FF0033
windowTITBGCOLORsel = #FF0033
openchromeless(theURL, wname, W, H, windowCERRARa, windowCERRARd,
windowCERRARo, windowNONEgrf, windowCLOCK, windowTIT, windowREALtit ,
windowBORDERCOLOR, windowBORDERCOLORsel, windowTITBGCOLOR,
windowTITBGCOLORsel)
}
//--
/script
##



-- 
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] php variables to JS

2003-01-05 Thread Rich Hutchins
One minor error I found upon re-reading is that I neglected to assign a name
to the hidden field in HTML. Without doing so, the JS statement wouldn't
work. So, the hidden field would actually need to look like this:

echo input type=\hidden\ name=\windowHeight\
value=\.$dbWindowHeight.\.
etc...
-Original Message-
From: Rich Hutchins [mailto:[EMAIL PROTECTED]]
Sent: Sunday, January 05, 2003 9:35 AM
To: Bruce Levick; [EMAIL PROTECTED]
Subject: RE: [PHP-DB] php variables to JS


From what I have learned PHP and JS don't talk directly to each other.
Instead, you have to make hidden fields in your html that hold the values
from your database then access those hidden fields with JS. If you want to
take values from JS and use them in a PHP script, then the process is
reversed; make hidden fields, set their values with JS then pass the hidden
fields to a PHP script.

In your case the relevant (abbreviated and untested) PHP code might look
like this:
?php
//where $dbWindowHeight is avariable that has been assigned a value from
your db query
echo form.
input type=\hidden\ value=\.$dbWindowHeight.\.
/form;
?

The relevant JS might look something like this:
var height = document.form.windowHeight.value;

Then for your window.open JS call, you'd substitute the var named height
into the string with the rest of the chromeless information.

If anybody knows an easier way, please post it because I'd love an easier
alternative if one exists.

Hope this helps. If not, I know there's a wealth of info in the PHP archives
about this subject. That's where I learned.

Rich

-Original Message-
From: Bruce Levick [mailto:[EMAIL PROTECTED]]
Sent: Sunday, January 05, 2003 2:09 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] php variables to JS


Bruce Levick - VivamotionI am opening a chromless window with some JS code.
I need to pass some variables which come from rows in my database into the
jscript which will determine the size and URL of the window.

Before I go about drawing the info from the database I have set up some hard
code php variables just so i could test how to pass these into js.

Does anybody know how I can code these variables into my jscript??

Cheers

##
?php
$h = 600;
$w = 343;
$theURL = test.php;
$wname = test;
?
###

##
script language=javaScript type=text/javascript
SRC=js/java.js/SCRIPT

script
!--
function openIT() {
theURL=wesley.php//php variable here
wname =CHROMELESSWIN  //php variable here
W=300;  //php variable here
H=100;  //php variable here
windowCERRARa = images/close_a.gif
windowCERRARd = images/close_d.gif
windowCERRARo = images/close_o.gif
windowNONEgrf = images/none.gif
windowCLOCK = images/clock.gif
windowREALtit = nbsp;? Task title
windowTIT = font face=verdana size=1nbsp;your chromless/font
windowBORDERCOLOR = #00
windowBORDERCOLORsel = #00
windowTITBGCOLOR = #FF0033
windowTITBGCOLORsel = #FF0033
openchromeless(theURL, wname, W, H, windowCERRARa, windowCERRARd,
windowCERRARo, windowNONEgrf, windowCLOCK, windowTIT, windowREALtit ,
windowBORDERCOLOR, windowBORDERCOLORsel, windowTITBGCOLOR,
windowTITBGCOLORsel)
}
//--
/script
##



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


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




[PHP-DB] Storing Radio Buttons Checkboxes in MySQL

2003-01-05 Thread Tony Bollino
Greetings all.
Thank you to all those on the list who have been helpful in the past. 
I'm hoping you will be able to come through for me again.  Here is my 
conundrum.

I am using an app (GBSurvey) I downloaded from the web to create a 
survey for teachers at a school.  The application only allows for radio 
buttons in the surveys. The school wants some questions to have 
checkboxes so responders can select multiple answers for the question. 
I rewrote the code to allow the admin to select if the answers to a 
survey question will be radio buttons or checkboxes.  That displays 
properly.  When I test it with multiple check boxes selected in one of 
the questions only the value of the last checkbox selected is entered 
into the database.

Here is the code:

Explaination of VARS for this example
--
$survey_id = The id of the survey

DB Field Definitions
--
surveya_type = Radio or Checkbox
surveyq_id = The question id in the database
surveya_id = The answer id in the database
surveya_name = The answer itself
--

This is the code to create the questions:
--
function list_surveyq($survey_id) {
   echo bia 
href=\.$GLOBALS[PHP_SELF].?survey_id=.$survey_id.view_results=true\View 
results without taking the survey/a/i/bP\n;

   $strSQL = SELECT * From bug_public_survey WHERE 
survey_id=.$survey_id;
   $query1 = mysql_query($strSQL,$GLOBALS[dbconn]);
   $survey = mysql_fetch_array($query1);
   echo form method=\post\ action=\.$GLOBALS[PHP_SELF].\\n;
   echo input type=\hidden\ name=\votes\ value=\1\\n;
   echo input type=\hidden\ name=\survey_id\ 
value=\.$survey_id.\\n;
//Get all the questions
   $strSQL = SELECT * From bug_public_surveyq WHERE 
surveyq_surveyid=.$survey[survey_id]. ORDER By surveyq_id;
   $query2 = mysql_query($strSQL,$GLOBALS[dbconn]);
   while($surveyq = mysql_fetch_array($query2)) {
//Get all the answers
   echo b.$surveyq[surveyq_name]./bbr\n;
   $strSQL = SELECT * From bug_public_surveya WHERE 
surveya_surveyqid=.$surveyq[surveyq_id];
   $query3 = mysql_query($strSQL,$GLOBALS[dbconn]);
   echo ul\n;
   while($surveya = mysql_fetch_array($query3)) {

   //
   //THIS IS WHERE THE ANSWERS ARE PRINTED
   //print radio button or checkbox and answer 
title for each question
   //
echo input type=\.$surveya[surveya_type].\ 
name=\answer[.$surveyq[surveyq_id].]\ 
value=\.$surveya[surveya_id].\ .$surveya[surveya_name].br\n;
//original code - echo input type=\radio\ 
name=\answer[.$surveyq[surveyq_id].]\ 
value=\.$surveya[surveya_id].\ .$surveya[surveya_name].br\n;
   }
   echo hr/ul\n;
   }
   echo input type=\submit\ value=\Submit\\n;
   echo /form\n;

--

When the form is submitted, this is the SQL that is executed.   The 
value of $votes is set to 1.  The page will reload and check to see if 
$votes is set.

---

if (isset($votes)) {
   $strSQL = SELECT * From bug_public_surveyq WHERE 
surveyq_surveyid=.$survey_id;
   $query = mysql_query($strSQL,$GLOBALS[dbconn]);
   while($surveyq = mysql_fetch_array($query)) {
   $strSQL = INSERT INTO bug_public_surveyr 
(surveyr_surveyid, surveyr_surveyaid, surveyr_surveyqid) VALUES 
(.$survey_id., .$answer[$surveyq[surveyq_id]]., 
.$surveyq[surveyq_id].);
 echo $strSQL;
   mysql_query($strSQL,$dbconn);
   }
   mysql_free_result($query);
}
---

The name of each checkbox is the same but the values are different.  Do 
both the name and values have to be different?  When it is inserted into 
the DB it shouldn't matter since the record would not be a duplicate.

--
Tony Bollino
AdytumSolutions
Sales and Field Operations
301-788-6886
http://www.adytumsolutions.com
[EMAIL PROTECTED]


* Not just a solution ... an AdytumSolution. *



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



Re: [PHP-DB] Storing Radio Buttons Checkboxes in MySQL

2003-01-05 Thread Jason Wong
On Sunday 05 January 2003 14:15, Tony Bollino wrote:
 Greetings all.
 Thank you to all those on the list who have been helpful in the past.
 I'm hoping you will be able to come through for me again.  Here is my
 conundrum.

 I am using an app (GBSurvey) I downloaded from the web to create a
 survey for teachers at a school.  The application only allows for radio
 buttons in the surveys. The school wants some questions to have
 checkboxes so responders can select multiple answers for the question.
 I rewrote the code to allow the admin to select if the answers to a
 survey question will be radio buttons or checkboxes.  That displays
 properly.  When I test it with multiple check boxes selected in one of
 the questions only the value of the last checkbox selected is entered
 into the database.

 The name of each checkbox is the same but the values are different.  Do
 both the name and values have to be different?  When it is inserted into
 the DB it shouldn't matter since the record would not be a duplicate.

manual  FAQ  PHP and HTML

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *


/*
I have just one word for you, my boy...plastics.
- from The Graduate
*/


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




RE: [PHP-DB] php variables to JS

2003-01-05 Thread Doug Thompson
OK.  I consider this an easier way.  I use it to display fullsize
images when a thumbdnail is clicked.  Same principle.

From head

script
var pixNum=,winName=, mheight=, mwidth=

var pixURL=http://**someURL**/;

function viewPix(pixNum,winName,mheight,mwidth) {
 win =
window.open(pixURL+pixNum,winName,status=no,toolbar=no,location=no,menu
=no,scrollbars=yes,resizable=yes,width=+ mwidth + ,height= + mheight
+'');
}
/script


From body

(snip...)
td align=center
a href=#
onclick=viewPix('?=$imgpath.$line[fsimage]?','Gallery',
'?=$line[fs_vsize]+100?','?=$line[fs_hsize]+30?'); 

img
src=?=$imgpath2.$line[tnimage]? width=?=$line[tn_hsize]?
height=?=$line[tn_vsize]? border=0/abr?=$line[catalog]?
/td

(snip ...)


This is used to display a large image after clicking on a thumbnail. 
The principle is the same regardless what you want to pass to the
scripts.

Hope there is some inspiration here.

Regards,
Doug


On Sun, 5 Jan 2003 09:35:04 -0500, Rich Hutchins wrote:

From what I have learned PHP and JS don't talk directly to each other.
Instead, you have to make hidden fields in your html that hold the values
from your database then access those hidden fields with JS. If you want to
take values from JS and use them in a PHP script, then the process is
reversed; make hidden fields, set their values with JS then pass the hidden
fields to a PHP script.

In your case the relevant (abbreviated and untested) PHP code might look
like this:
?php
   //where $dbWindowHeight is avariable that has been assigned a value from
your dbquery
   echo form.
   input type=\hidden\ value=\.$dbWindowHeight.\.
   /form;
?

The relevant JS might look something like this:
var height = document.form.windowHeight.value;

Then for your window.open JS call, you'd substitute the var named height
into the string with the rest of the chromeless information.

If anybody knows an easier way, please post it because I'd love an easier
alternative if one exists.

Hope this helps. If not, I know there's a wealth of info in the PHP archives
about this subject. That's where I learned.

Rich

-Original Message-
From: Bruce Levick [mailto:[EMAIL PROTECTED]]
Sent: Sunday, January 05, 2003 2:09 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] php variables to JS


Bruce Levick - VivamotionI am opening a chromless window with some JS code.
I need to pass some variables which come from rows in my database into the
jscript which will determine the size and URL of the window.

Before I go about drawing the info from the database I have set up some hard
code php variables just so i could test how to pass these into js.

Does anybody know how I can code these variables into my jscript??

Cheers

##
?php
$h = 600;
$w = 343;
$theURL = test.php;
$wname = test;
?
###

##
script language=javaScript type=text/javascript
SRC=js/java.js/SCRIPT

script
!--
function openIT() {
theURL=wesley.php//php variable here
wname =CHROMELESSWIN  //php variable here
W=300;  //php variable here
H=100;  //php variable here
windowCERRARa = images/close_a.gif
windowCERRARd = images/close_d.gif
windowCERRARo = images/close_o.gif
windowNONEgrf = images/none.gif
windowCLOCK = images/clock.gif
windowREALtit = nbsp;? Task title
windowTIT = font face=verdana size=1nbsp;your chromless/font
windowBORDERCOLOR = #00
windowBORDERCOLORsel = #00
windowTITBGCOLOR = #FF0033
windowTITBGCOLORsel = #FF0033
openchromeless(theURL, wname, W, H, windowCERRARa, windowCERRARd,
windowCERRARo, windowNONEgrf, windowCLOCK, windowTIT, windowREALtit ,
windowBORDERCOLOR, windowBORDERCOLORsel, windowTITBGCOLOR,
windowTITBGCOLORsel)
}
//--
/script
##



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




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




[PHP-DB] Query with optional params

2003-01-05 Thread Rich Hutchins
I have a search page on which I place six fields into which users may enter
data to perform a search. For ease of explanation, the fields are:
Part Number
Title
Subtitle
Print Date
Status
Type

All of these fields reside in the same table, named docmeta, in a MySQL
database.

I'm running into a logic problem when a user enters data into only one or
two of the six fields. The question/problem is how do I write a MySQL query
when not all of the parameters are filled in each time? Is this a problem
that needs to be handled on the PHP side with a bunch of IF statements when
constructing the MySQL string or is there a MySQL command or syntax that
accommodates variable length parameter sets?

The problem is when a search parameter is left blank by the user. If I
include the empty parameter in the query (e.g. SELECT * FROM docmeta WHERE
partnum LIKE % AND title LIKE % AND subtitle LIKE ;) then an empty set
is returned when subtitle is not blank in the database. This is totally
understandable, since that's what subtitle LIKE  means, but it's not what
I want to send.

Essentially, I want to skip sending the subtitle LIKE  part when subtitle
field is not filled in by the user.

Incidentally, the query works fine if I use OR instead of AND, but switching
to an all OR query is not an option; I need to be able to perform both.

I've checked the archives and the MySQL manual (especially the language
reference) and I haven't found anything that answers my question.

I'm fairly certain I'll be able to figure this out if somebody points me in
the right direction, but I don't think I even know what (or where) to look
for the answer. Any help would be appreciated.

Thanks,
Rich


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




[PHP-DB] Sessions problems

2003-01-05 Thread Sabina Alejandr Schneider
Hello everybody
I was trying to use Sessions, but I had some problems. 

I have an old version of the Apache, that comes with the 
Red Hat 7.2.

when executing this in my page:

session_start();
if(!isset($_SESSION['s_test'])){
   $_SESSION['s_prueba']=1;
}

There appear this in the page:
Warning: Cannot send session cookie - headers already sent 
by (output started at /var/www/html/prueba/index.php:8) in 
/var/www/html/prueba/index.php on line 10

Warning: Cannot send session cache limiter - headers 
already sent (output started at 
/var/www/html/prueba/index.php:8) in 
/var/www/html/prueba/index.php on line 10

What can be the problem here? How can I solution this?

Thanks in advance






_

Tutopia - Acceso a Internet rápido, fácil y a los mejores precios.
http://www.tutopia.com

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



[PHP-DB] Session variable problems

2003-01-05 Thread Sabina Alejandr Schneider
Hello to everybody!!! I have a problem with the sessions 
variable registration. I register a variable with the
$_SESSION[] array and set it to 1, but when I try to
access that variable in another script it is emty...
What's the problem there??
  Thank you very much in advance!!!






_

Tutopia - Acceso a Internet rápido, fácil y a los mejores precios.
http://www.tutopia.com

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



RE: [PHP-DB] Session variable problems

2003-01-05 Thread dufronte
I've received your file.. and check it.. I think you missed something...
Try this one :D

?
   if($var1){
  session_start();
  if(!isset($_SESSION['s_prueba'])){
 $_SESSION['s_prueba']=1;
 echo($_SESSION['s_prueba']);
  }
  
   ?
  HTML
HEADER
TITLE
Session Test
   /TITLE
/HEADER
  BODY
  FORM ACTION=index.php
 INPUT TYPE=HIDDEN NAME=var VALUE=1
 INPUT TYPE=SUBMIT VALUE='Aceptar'
/FORM
   ? }
   else{
  session_start();// you forgot to put session_start here...
  echo(Variable s_prueba: .$_SESSION['s_prueba']);
   } ?
/BODY
/HTML


#Please join Open Community Forum... http://openity.tk  #We're free to
discuss anything
 
   ---DuFronte--- 
  http://kapsul.org
  No Fuckin' Shits !!

 -Original Message-
 From: Sabina Alejandr Schneider [mailto:[EMAIL PROTECTED]]
 Sent: Monday, January 06, 2003 4:23 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] Session variable problems
 
 Hello to everybody!!! I have a problem with the sessions
 variable registration. I register a variable with the
 $_SESSION[] array and set it to 1, but when I try to
 access that variable in another script it is emty...
 What's the problem there??
Thank you very much in advance!!!
 
 
 
 
 
 
 _
 
 Tutopia - Acceso a Internet rápido, fácil y a los mejores precios.
 http://www.tutopia.com
 
 --
 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] Storing Radio Buttons Checkboxes in MySQL

2003-01-05 Thread Ruprecht Helms
Hi  Jason Wong,

 manual  FAQ  PHP and HTML

Contents/answers for checkboxes, radiobuttons and/or option-boxes
usualy are stored in databases.

All other (the tags) are nonsense to store in a database, because these are 
typically templatestuff or written by taking a loop within a php-script. 

Regards,
Ruprecht

--
Ruprecht Helms IT-Service und Softwareentwicklung

Tel/Fax.:  +49[0]7621 16 99 16
Homepage:  http://www.rheyn.de
email:  [EMAIL PROTECTED]
--

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




[PHP-DB] Re: Passing variables through a page

2003-01-05 Thread Michael Mauch
Alex Francis [EMAIL PROTECTED] wrote:
 I have a page (dept_select) with two drop down lists populated from a table
 in a MySQL Database. If one item is selected in either of the lists I need
 to go to one page (5-14_select_area.php). If any other item is selected I
 need to go to another page (add_new_resources.php) but I need to pass the
 selected items to add_new_resources.php.

I don't think there are many other possiblities, at least if you don't
want to use JavaScript (and I hope you don't).

Instead of the redirect, you could perhaps use require() to include one
of the two possible pages, and thus avoid one server-client roundtrip.

 At the moment I have created a page between dept_select.php and the other
 pages and added the following code to it:
 ?php
 if ($department==5-14 Curriculum)
 {
 header(Location:5-14_select_area.php);
 }
 elseif ($level==5-14 Curriculum)
 {
 header(Location:5-14_select_area.php);
 }
 else
 {
 header(Location:add_new_resources.php);
 }
 ?

The Location header requires an absolute URI, e.g.
http://your_host/path/your_file.php.

I'm not sure whether this is a database question ;-)

Regards...
Michael

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




Re: [PHP-DB] Query with optional params

2003-01-05 Thread David Smith
Rich,

When I do searches with multiple fields, I construct the SQL string on
the PHP side. You can do something like this:

$sql = SELECT * FROM docmeta WHERE ;

if( $PartNumber )
$sql .= PartNumber='$PartNumber';

if( $Title )
$sql .=  AND Title='$Title';

and so on...

That has worked well for me in the past. You could make it more general
by creating an array of field names and iterating through that array
checking for the presence of the appropriate variables. Then, if you add
an additional field, just add it to the array of field names.

If there is a way to do this sort of optional search field with MySQL,
then I don't know about it.

--Dave

On Sun, 2003-01-05 at 12:52, Rich Hutchins wrote:
 I have a search page on which I place six fields into which users may enter
 data to perform a search. For ease of explanation, the fields are:
 Part Number
 Title
 Subtitle
 Print Date
 Status
 Type
 
 All of these fields reside in the same table, named docmeta, in a MySQL
 database.
 
 I'm running into a logic problem when a user enters data into only one or
 two of the six fields. The question/problem is how do I write a MySQL query
 when not all of the parameters are filled in each time? Is this a problem
 that needs to be handled on the PHP side with a bunch of IF statements when
 constructing the MySQL string or is there a MySQL command or syntax that
 accommodates variable length parameter sets?
 
 The problem is when a search parameter is left blank by the user. If I
 include the empty parameter in the query (e.g. SELECT * FROM docmeta WHERE
 partnum LIKE % AND title LIKE % AND subtitle LIKE ;) then an empty set
 is returned when subtitle is not blank in the database. This is totally
 understandable, since that's what subtitle LIKE  means, but it's not what
 I want to send.
 
 Essentially, I want to skip sending the subtitle LIKE  part when subtitle
 field is not filled in by the user.
 
 Incidentally, the query works fine if I use OR instead of AND, but switching
 to an all OR query is not an option; I need to be able to perform both.
 
 I've checked the archives and the MySQL manual (especially the language
 reference) and I haven't found anything that answers my question.
 
 I'm fairly certain I'll be able to figure this out if somebody points me in
 the right direction, but I don't think I even know what (or where) to look
 for the answer. Any help would be appreciated.
 
 Thanks,
 Rich
 
 
 -- 
 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] Query with optional params

2003-01-05 Thread Rich Hutchins
Dave,

Thank you so much for your suggestion. That will certainly do the trick. I
struggled with the concatenation of the sql string and IF statements similar
you wrote before I sent my original post, but couldn't get the concatenation
right. I wasn't sure if I was going about I the wrong way logically or if I
just wasn't getting the syntax right.

I'll code this up and things should be just fine from there.

Thanks again for your time.

Rich

-Original Message-
From: David Smith [mailto:[EMAIL PROTECTED]]
Sent: Sunday, January 05, 2003 5:33 PM
To: Rich Hutchins
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] Query with optional params


Rich,

When I do searches with multiple fields, I construct the SQL string on
the PHP side. You can do something like this:

$sql = SELECT * FROM docmeta WHERE ;

if( $PartNumber )
$sql .= PartNumber='$PartNumber';

if( $Title )
$sql .=  AND Title='$Title';

and so on...

That has worked well for me in the past. You could make it more general
by creating an array of field names and iterating through that array
checking for the presence of the appropriate variables. Then, if you add
an additional field, just add it to the array of field names.

If there is a way to do this sort of optional search field with MySQL,
then I don't know about it.

--Dave

On Sun, 2003-01-05 at 12:52, Rich Hutchins wrote:
 I have a search page on which I place six fields into which users may
enter
 data to perform a search. For ease of explanation, the fields are:
 Part Number
 Title
 Subtitle
 Print Date
 Status
 Type

 All of these fields reside in the same table, named docmeta, in a MySQL
 database.

 I'm running into a logic problem when a user enters data into only one or
 two of the six fields. The question/problem is how do I write a MySQL
query
 when not all of the parameters are filled in each time? Is this a problem
 that needs to be handled on the PHP side with a bunch of IF statements
when
 constructing the MySQL string or is there a MySQL command or syntax that
 accommodates variable length parameter sets?

 The problem is when a search parameter is left blank by the user. If I
 include the empty parameter in the query (e.g. SELECT * FROM docmeta WHERE
 partnum LIKE % AND title LIKE % AND subtitle LIKE ;) then an empty
set
 is returned when subtitle is not blank in the database. This is totally
 understandable, since that's what subtitle LIKE  means, but it's not
what
 I want to send.

 Essentially, I want to skip sending the subtitle LIKE  part when
subtitle
 field is not filled in by the user.

 Incidentally, the query works fine if I use OR instead of AND, but
switching
 to an all OR query is not an option; I need to be able to perform both.

 I've checked the archives and the MySQL manual (especially the language
 reference) and I haven't found anything that answers my question.

 I'm fairly certain I'll be able to figure this out if somebody points me
in
 the right direction, but I don't think I even know what (or where) to look
 for the answer. Any help would be appreciated.

 Thanks,
 Rich


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


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




[PHP-DB] mail() question

2003-01-05 Thread tony
I am trying to get the mail() function to work.
Here is my test code:

ini_set(SMTP, mail.mydomain.com);
ini_set(sendmail_from, [EMAIL PROTECTED]);
echo ini_get(SMTP);
echo brbr, ini_get(sendmail_from);
echo brbr, ini_get(sendmail_path);

echo $success = mail([EMAIL PROTECTED], A subject, Some contents);

I print the settings out to make sure they are right.
And they look like right.
But even if the mail() function retuns 1, the mail still doesn't go through.
Don't even see a log on the mail server.
Can somebody tell me what I am missing?
Thanks a lot for your help.


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




[PHP-DB] Flat File Upload..HELP!

2003-01-05 Thread J . Keith Tew


I know this is not technically a DB question but thought someone may be
able to help with this. I have tried everything I could think of to make
this script work but I keep getting the error message below. I've even
changed the permissions on the files and the folders affected to  allow
full read,write execute priviledges to all users ...but still no luck.
I'm not sure if it is a server (apache on linux)  permission issue or if
it is a typo in the script or a file path issue. ANY HELP would be
greatly appreciated.  I've also included the script below in the event
the mistake is in the script


Thanks in Advance

ERROR MESSAGE

Uploading file...

Warning: Unable to create
'/home/design/public_html/uploads/fbcnews.txt': Permission denied in
/home/design/public_html/uploads/upload1.php on line 35
Problem: Could not move file into directory


UPLOAD SCRIPT

htm
head
   titleUploading.../title
/head
body
h1Uploading file.../h1
?
   // $userfile is where file went on webserver
   // $userfile_name is original file name
   // $userfile_size is size in bytes
   // $userfile_type is mime type e.g. image/gif

/*  echo Variables are:br;
   echo $userfile. .$userfile_name. .$userfile_size.
.$userfile_type.br;
*/

   if ($userfile==none)
   {
 echo Problem: no file uploaded;
 exit;
   }

   if ($userfile_size==0)
   {
 echo Problem: uploaded file is zero length;
 exit;
   }

   if ($userfile_type != text/plain)
   {
 echo Problem: file is not plain text;
 exit;
   }

   $upfile = /home/design/public_html/uploads/.$userfile_name;

   if ( !copy($userfile, $upfile))
   {
 echo Problem: Could not move file into directory;
 exit;
   }


   echo File uploaded successfullybrbr;
   $fp = fopen($upfile, r);
   $contents = fread ($fp, filesize ($upfile));
   fclose ($fp);

   $contents = strip_tags($contents);
   $fp = fopen($upfile, w);
   fwrite($fp, $contents);
   fclose($fp);

   echo Preview of uploaded file contents:brhr;
   echo $contents;
   echo brhr;

?
/body
/html





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