[PHP-DB] Using ifelse to go to another page
I have dropdown lists on one page which were working fine. However I need to make a slight alteration and add another 2 ifelse statements to go to another page instead of carrying out the $SQL statement. I have added the last 2 ifelse statements but I still get the SELECT statement working. Can someone help please. ? if ($level==All Levels) { $SQL = SELECT * FROM courses where department='$department'; } elseif ($level!=All Levels) { $SQL = SELECT * FROM courses where department='$department' and level='$level'; } elseif ($department==5-14 Curriculum) { A HREF 'add_5-14_material.php'/A; } elseif ($level==5-14 Curriculum) { A HREF 'add_5-14_material.php'/A; } $retid = mysql_db_query($dbname, $SQL, $link); if (!$retid) { echo( mysql_error()); } else { // the rest creates a table with the information from the SELECT statement. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Using ifelse to redirect to another page
I have dropdown lists on one page which were working fine. However I need to make a slight alteration and add another 2 ifelse statements to go to another page instead of carrying out the $SQL statement. I have added the last 2 ifelse statements but I still get the SELECT statement working. Can someone help please. ? if ($level==All Levels) { $SQL = SELECT * FROM courses where department='$department'; } elseif ($level!=All Levels) { $SQL = SELECT * FROM courses where department='$department' and level='$level'; } elseif ($department==5-14 Curriculum) { A HREF 'add_5-14_material.php'/A; } elseif ($level==5-14 Curriculum) { A HREF 'add_5-14_material.php'/A; } $retid = mysql_db_query($dbname, $SQL, $link); if (!$retid) { echo( mysql_error()); } else { // the rest creates a table with the information from the SELECT statement. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Using ifelse to go to another page
Change the second ifelse-- either get rid of it, or put it at the end. Right now your logic is like this: if (a equals b) { ... } elseif (a does not equal b) { ... } elseif (c equals d) etc One of the first two conditions will always match, so the rest of the statement is skipped. -bill Alex Francis wrote: I have dropdown lists on one page which were working fine. However I need to make a slight alteration and add another 2 ifelse statements to go to another page instead of carrying out the $SQL statement. I have added the last 2 ifelse statements but I still get the SELECT statement working. Can someone help please. ? if ($level==All Levels) { $SQL = SELECT * FROM courses where department='$department'; } elseif ($level!=All Levels) { $SQL = SELECT * FROM courses where department='$department' and level='$level'; } elseif ($department==5-14 Curriculum) { A HREF 'add_5-14_material.php'/A; } elseif ($level==5-14 Curriculum) { A HREF 'add_5-14_material.php'/A; } $retid = mysql_db_query($dbname, $SQL, $link); if (!$retid) { echo( mysql_error()); } else { // the rest creates a table with the information from the SELECT statement. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Renaming a file uploaded by a form.
Thanks for all your help. I got the file OK and I figured out how to rename it and make it an attachment to an email. But one thing is not working for me. When I look for the mime type I get the following error: Fatal error: Call to undefined function: mime_content_type() When I call it to define a variable: $ftype = mime_content_type($file) Any suggestions or ideas on how to do this? Thanks again! Tim on 1/1/03 6:08 PM, [EMAIL PROTECTED] at [EMAIL PROTECTED] wrote: copy($_FILES['userfile']['tmp_name'],/real/path/to/$_FILES['userfile'] ['name']); what you really want is... http://www.php.net/manual/en/features.file-upload.php hth jeff Info@Best-IT infoTo: [EMAIL PROTECTED] cc: 01/01/2003 Subject: [PHP-DB] Renaming a file uploaded by a form. 06:25 PM I have a script that uploads form data to a MySQL server then emails the form data to alert people that an upload occurred. I am having trouble getting the form to upload my file with the actual filename. The filename seems to be created by the PHP machine (wild guess) but it looks like this: /var/tmp//phptkYxkV Any ideas on how to get it to look like: filename.doc would be greatly appreciated. /Tim -- 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] Renaming a file uploaded by a form.
did you compile PHP with --enable-mime-magic? if not, this extension will not work. there are work arounds. one isa class that resides on phpclasses.org that will give you a mime based on the file extension. and i'm sure there are other ways hth jeff Info@Best-IT infoTo: [EMAIL PROTECTED], [EMAIL PROTECTED] cc: 01/04/2003 Subject: Re: [PHP-DB] Renaming a file uploaded by a form. 12:25 PM Thanks for all your help. I got the file OK and I figured out how to rename it and make it an attachment to an email. But one thing is not working for me. When I look for the mime type I get the following error: Fatal error: Call to undefined function: mime_content_type() When I call it to define a variable: $ftype = mime_content_type($file) Any suggestions or ideas on how to do this? Thanks again! Tim on 1/1/03 6:08 PM, [EMAIL PROTECTED] at [EMAIL PROTECTED] wrote: copy($_FILES['userfile']['tmp_name'],/real/path/to/$_FILES['userfile'] ['name']); what you really want is... http://www.php.net/manual/en/features.file-upload.php hth jeff Info@Best-IT infoTo: [EMAIL PROTECTED] cc: 01/01/2003 Subject: [PHP-DB] Renaming a file uploaded by a form. 06:25 PM I have a script that uploads form data to a MySQL server then emails the form data to alert people that an upload occurred. I am having trouble getting the form to upload my file with the actual filename. The filename seems to be created by the PHP machine (wild guess) but it looks like this: /var/tmp//phptkYxkV Any ideas on how to get it to look like: filename.doc would be greatly appreciated. /Tim -- 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] How to seperate the web server and MySQL database server?
Hi, I am sure this is a silly/easy question but I really hope someone can point me some documents. We are currently running PHP and MySQL at the same machine. Can I run PHP in one machine and MySQL server in another machine? If so, how can I make the database connection? Currently, in all my PHP scripts, they connect to the database through @ $db = mysql_pconnect(localhost, UNAME, PASSWD); can I just replace localhost with the host name of MySQL machine? What else should I worry about? Thanks! Qunfeng __ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Progress output
I just wrote a script that goes through a database and does a lot of stuff to the data, it takes about 30 seconds to a minute to run through everything, so I thought it would be nice to show a progress indicator of some sort. What I have at this point, is that after every record is processed, I put in an: echo .; command. I just noticed though, that nothing will get sent to the browser until the script is finished, so it's worthless to output the periods. Is there a way to get the browser to display partial data before it's done downloading the page (or before the script execution is done in this case..)? I'm not doing any output buffering, or sending headers or anything at this point, just SQL commands and echo output. Oh, I'm running php 4.2.2 Thanks! -- Raincross Technologies Development and Consulting Services http://www.raincross-tech.com
Re: [PHP-DB] Progress output
On Sunday 05 January 2003 03:25, Micah Stevens wrote: I just wrote a script that goes through a database and does a lot of stuff to the data, it takes about 30 seconds to a minute to run through everything, so I thought it would be nice to show a progress indicator of some sort. What I have at this point, is that after every record is processed, I put in an: echo .; command. I just noticed though, that nothing will get sent to the browser until the script is finished, so it's worthless to output the periods. Is there a way to get the browser to display partial data before it's done downloading the page (or before the script execution is done in this case..)? I'm not doing any output buffering, or sending headers or anything at this point, just SQL commands and echo output. Oh, I'm running php 4.2.2 Short answer: flush() Longer answer: search the archives (both php-general php-db), it's been covered many times before. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* static buildup */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] How to seperate the web server and MySQL database server?
On Sunday 05 January 2003 02:54, Qunfeng Dong wrote: Hi, I am sure this is a silly/easy question but I really hope someone can point me some documents. We are currently running PHP and MySQL at the same machine. Can I run PHP in one machine and MySQL server in another machine? If so, how can I make the database connection? Currently, in all my PHP scripts, they connect to the database through @ $db = mysql_pconnect(localhost, UNAME, PASSWD); can I just replace localhost with the host name of MySQL machine? What else should I worry about? Basically yes. But you need to tell mysql to allow remote connections (checkout the GRANT command). Also if you have a firewall between the two machines you would naturally have to take that into account. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* Cure the disease and kill the patient. -- Francis Bacon */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Progress output
Heh.. I did.. Thanks! -Micah On Sat, 2003-01-04 at 12:05, Jason Wong wrote: On Sunday 05 January 2003 03:25, Micah Stevens wrote: I just wrote a script that goes through a database and does a lot of stuff to the data, it takes about 30 seconds to a minute to run through everything, so I thought it would be nice to show a progress indicator of some sort. What I have at this point, is that after every record is processed, I put in an: echo .; command. I just noticed though, that nothing will get sent to the browser until the script is finished, so it's worthless to output the periods. Is there a way to get the browser to display partial data before it's done downloading the page (or before the script execution is done in this case..)? I'm not doing any output buffering, or sending headers or anything at this point, just SQL commands and echo output. Oh, I'm running php 4.2.2 Short answer: flush() Longer answer: search the archives (both php-general php-db), it's been covered many times before. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* static buildup */ -- Raincross Technologies Development and Consulting Services http://www.raincross-tech.com
[PHP-DB] PHP/MySQL
Hi, I hope someone can help me with this. I am trying to modify this portion of a script so that I can upload photos (MacOSX 10.2.3) but keep the file names intact. At the moment everything works fine except that when I upload photos, the script changes the name of the file I just uploaded to a new filename (sequentially) based on the database 'id' number to 1.gif, 2.gif, 3.gif and so on. I need to be able to keep the filename as it is (05-01.gif, 23-02.gif etc) when I upload it! // // Insert the photo details into the database // $result = mysql_query(INSERT INTO photo (id,galleryid,title,size_in_MB,person,filename,description) VALUES ('','$galleryid','$title','$size_in_MB','$person','$filename', '$description') ); // // Retrieve the ID of the photo // $result = mysql_query(SELECT * FROM photo WHERE galleryid = '$galleryid' AND title = '$title' AND description = '$description'); $id = mysql_result($result,0,id); // // Generate a filename for the file // $filename = $id.$format; // // Alter the database record to point to the correct // filename. // $result = mysql_query(UPDATE photo SET filename = '$filename' WHERE id = '$id'); // // Move the thumbnail and full-sized photo to the correct filesystem // location. // copy ($photo,$filepath/$galleryid/photos/$id.$format); copy ($thumbnail,$filepath/$galleryid/thumbnails/$id.$format); // // Print out a Success message to the user. // Regards Mike -- -- Mike C Macintosh Support Specialist University of Otago (ITS) Dunedin NEW ZEALAND http://www.otago.ac.nz -- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Textarea, File Upload field setting values
Hi, I can write a code like : input type=text name=txtfield1 value=? $txtfield1 ? Thus I can set the value of $txtfield1 and it is reflected in the above textbox. How can such thing be done with TextArea and File upload ? input maxLength=128 name=Imagefile type=file value=? echo $Imagefile ? textarea name=txtDescription rows=25 cols=80 maxlength=1000 value=? $txtDescription ?/textarea The above stuff is not working. Is it possible to accomplish the above stuff ? I need this since I am calling the same form on submit for validation and hence will need the values of the above also to remain intact in case of error in any other fields. Thanks in advance. Peace -- Rajesh * [EMAIL PROTECTED] * http://www.symonds.net/~rajesh/ Powered By : Debian GNU/Linux 3.0 (Woody) - [Kernel 2.4.18(ext3),Mutt 1.5.1i] It's not the valleys in life I dread so much as the dips. -- Garfield -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] PHP/MySQL
The script is generating a filename based on the id and then copies the file from somewhere to the new location. It's doing just what it's supposed to. IF you don't want it to do it, just use the following instead: // // Insert the photo details into the database // $result = mysql_query(INSERT INTO photo (id,galleryid,title,size_in_MB,person,filename,description) VALUES ('','$galleryid','$title','$size_in_MB','$person','$photo', '$description') ); That should do it. You should be using the $photo variable as the filename and not moving anything. Of course this doesn't address the thumbnail issue, but you get the idea. -Micah On Sat, 2003-01-04 at 13:55, Mike C wrote: Hi, I hope someone can help me with this. I am trying to modify this portion of a script so that I can upload photos (MacOSX 10.2.3) but keep the file names intact. At the moment everything works fine except that when I upload photos, the script changes the name of the file I just uploaded to a new filename (sequentially) based on the database 'id' number to 1.gif, 2.gif, 3.gif and so on. I need to be able to keep the filename as it is (05-01.gif, 23-02.gif etc) when I upload it! // // Insert the photo details into the database // $result = mysql_query(INSERT INTO photo (id,galleryid,title,size_in_MB,person,filename,description) VALUES ('','$galleryid','$title','$size_in_MB','$person','$filename', '$description') ); // // Retrieve the ID of the photo // $result = mysql_query(SELECT * FROM photo WHERE galleryid = '$galleryid' AND title = '$title' AND description = '$description'); $id = mysql_result($result,0,id); // // Generate a filename for the file // $filename = $id.$format; // // Alter the database record to point to the correct // filename. // $result = mysql_query(UPDATE photo SET filename = '$filename' WHERE id = '$id'); // // Move the thumbnail and full-sized photo to the correct filesystem // location. // copy ($photo,$filepath/$galleryid/photos/$id.$format); copy ($thumbnail,$filepath/$galleryid/thumbnails/$id.$format); // // Print out a Success message to the user. // Regards Mike -- -- Mike C Macintosh Support Specialist University of Otago (ITS) Dunedin NEW ZEALAND http://www.otago.ac.nz -- -- Raincross Technologies Development and Consulting Services http://www.raincross-tech.com
[PHP-DB] displaying a MySQL date in a different format
Can anyone help me. I am trying to display a date in a different format from that stored in a MySQL database. MySQL forces you to store it as -mm-dd but I want to display it as dd-mm-, or dd- Any ideas? Many thanks in advance Ali McLeod [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] displaying a MySQL date in a different format
SELECT DATE_FORMAT(NOW(), '%m/%d/%Y'); will out put 01/04/2003. replace NOW() with you're column name. check out hte mysql manual for all of the date variations. hth jeff Ali McLeod alimcleod@btint To: [EMAIL PROTECTED] ernet.com cc: Subject: [PHP-DB] displaying a MySQL date in a different format 01/04/2003 06:27 PM Can anyone help me. I am trying to display a date in a different format from that stored in a MySQL database. MySQL forces you to store it as -mm-dd but I want to display it as dd-mm-, or dd- Any ideas? Many thanks in advance Ali McLeod [EMAIL PROTECTED] -- 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] Textarea, File Upload field setting values
For the textarea, print the value between the tags-- there is no value attribute: textarea?= $txtDescription ?/textarea You cannot do this with file inputs. -bill Rajesh Fowkar wrote: Hi, I can write a code like : input type=text name=txtfield1 value=? $txtfield1 ? Thus I can set the value of $txtfield1 and it is reflected in the above textbox. How can such thing be done with TextArea and File upload ? input maxLength=128 name=Imagefile type=file value=? echo $Imagefile ? textarea name=txtDescription rows=25 cols=80 maxlength=1000 value=? $txtDescription ?/textarea The above stuff is not working. Is it possible to accomplish the above stuff ? I need this since I am calling the same form on submit for validation and hence will need the values of the above also to remain intact in case of error in any other fields. Thanks in advance. Peace -- Rajesh * [EMAIL PROTECTED] * http://www.symonds.net/~rajesh/ Powered By : Debian GNU/Linux 3.0 (Woody) - [Kernel 2.4.18(ext3),Mutt 1.5.1i] It's not the valleys in life I dread so much as the dips. -- Garfield -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] more values in a array
Hi everybody, I'm about to transport data from a function to a page that calls it, but i'm HAD to make the data's in one or more array's. How can i possibly put all these datas in an array ?? And is it possible ?? idvalueyeartype --+---+-+-+ 1 1002002 P 2 2002002 A 3 3002002 P 4 4002002 A I hope you understand my bad english and that you can help me... Thanks a lot just for reading this! Regards, Martin Allan Jensen -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] more values in a array
On Sunday 05 January 2003 11:18, Martin Allan Jensen wrote: Hi everybody, I'm about to transport data from a function to a page that calls it, but i'm HAD to make the data's in one or more array's. How can i possibly put all these datas in an array ?? And is it possible ?? idvalueyeartype --+---+-+-+ 1 1002002 P 2 2002002 A 3 3002002 P 4 4002002 A $myarray[1][value] = 100; $myarray[1][year] = 2002; $myarray[1][type] = 'P'; etc. OR $myarray[1] = array('value' = 100, 'year' = 2002, 'type' = 'P'); etc. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* Life is like a tin of sardines. We're, all of us, looking for the key. -- Beyond the Fringe */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[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