Re: [PHP] $_POST['xxx'] = blabla ?
Use unset () to reset the variable values and $_POST to set the values. As long as there's no other, unacceptable access to your server, you'll be in a good position, other security considerations aside. If any other latent $_POST values exist, what could they do? And if they were to do anything, could they not be reset easily? [Original Message] From: Angelo Zanetti [EMAIL PROTECTED] To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Date: 11/23/2004 12:17:37 AM Subject: Re: [PHP] $_POST['xxx'] = blabla ? I speak under correction but the reason could be that if someone tries to hack your site, for example I post to your HTML page, you want to check it your $_POST contains a certain variable (which may be hidden) Not really sure besides that Perry Jönsson [EMAIL PROTECTED] 11/22/2004 10:57:23 PM Jay Blanchard wrote: [snip] What is the difference between these two examples? Both works fine for me. 1. if ($_POST['submit'] == 'Login') { ... ... } 2. if (isset($_POST['submit']) { ... ... } [/snip] One is checking if $_POST contains a specific value, the other just checks to see if it contains a value. If $_POST['submit'] contains 'foo' is ISSET. Make sense? Maybe a daft question but why would you like to check for a specific value? Can you give an example when this is a good thing to do? /PJ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Disclaimer This e-mail transmission contains confidential information, which is the property of the sender. The information in this e-mail or attachments thereto is intended for the attention and use only of the addressee. Should you have received this e-mail in error, please delete and destroy it and any attachments thereto immediately. Under no circumstances will the Cape Technikon or the sender of this e-mail be liable to any party for any direct, indirect, special or other consequential damages for any use of this e-mail. For the detailed e-mail disclaimer please refer to http://www.ctech.ac.za/polic or call +27 (0)21 460 3911 -- 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] getting the highest number in 3 db fields?
http://www.php.net/manual/en/function.max.php [Original Message] From: Louie Miranda [EMAIL PROTECTED] To: [EMAIL PROTECTED] Date: 11/19/2004 2:10:32 AM Subject: Re: [PHP] getting the highest number in 3 db fields? thanks, im not aware that php also has max(), ty. On Thu, 18 Nov 2004 23:46:01 -0700, Dennis Seavers [EMAIL PROTECTED] wrote: Try using the SQL aggregate function MAX() or the PHP function max() [Original Message] From: Louie Miranda [EMAIL PROTECTED] To: [EMAIL PROTECTED] Date: 11/18/2004 11:34:57 PM Subject: [PHP] getting the highest number in 3 db fields? I have a db field of 3. - prolog - transmodal - asian I wish to get the highest number of those three, in different fields. Im thingking of.. if (row0 = row1) ... how about row2? confused.. -- Louie Miranda http://www.axishift.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Louie Miranda http://www.axishift.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] getting the highest number in 3 db fields?
Try using the SQL aggregate function MAX() or the PHP function max() [Original Message] From: Louie Miranda [EMAIL PROTECTED] To: [EMAIL PROTECTED] Date: 11/18/2004 11:34:57 PM Subject: [PHP] getting the highest number in 3 db fields? I have a db field of 3. - prolog - transmodal - asian I wish to get the highest number of those three, in different fields. Im thingking of.. if (row0 = row1) ... how about row2? confused.. -- Louie Miranda http://www.axishift.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] parsing /'s in urls
The link offers a CGI error, which is admittedly an uninteresting result. I think you'll need to indicate what your previous results were and, if different, what your desired results are. Dennis [Original Message] From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Date: 11/11/2004 11:58:10 PM Subject: [PHP] parsing /'s in urls My host recently upgraded PHP. I had a script, download.php, that would work like this http://www.myhost.com/download.php/30/file.torrent the download.php script would take the 30, look up the real filename in the database, and readfile() it back. this was a great setup because the browser just thought it was accessing a direct link to a file. But now download.php/30/file.torrent results in a 404. Is this something I can change back? Dan -- 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] php - no results - display other message
mysql_num_rows () will tell you how many rows return in the query [Original Message] From: Dustin Krysak [EMAIL PROTECTED] To: PHP [EMAIL PROTECTED] Date: 09/14/2004 9:37:24 PM Subject: [PHP] php - no results - display other message Hi there... I have a simple search page (mysql database), and I can get it to display the results no issues, but i was wondering how I could display a message stating there were no results, instead of just having the field blank. I am familiar with IF and ELSE statements, but I am not sure how to test the no result option from the results of a SQL query thanks! d -- 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] Creation of MySQL Database Using PHP
mysql_query ('CREATE DATABASE name_of_database'); [Original Message] From: Harlequin [EMAIL PROTECTED] To: [EMAIL PROTECTED] Date: 07/24/2004 3:08:47 PM Subject: [PHP] Creation of MySQL Database Using PHP Hello. I have a friend who knows less than me about PHP and MySQL (which I know is hard to believe) but she needs a login facility for her site. I've passed over some script I use but she doesn't know how to create the database. I can write some commands that create the tables OK - but can I do the same for the database or does that have to be done through the UI...? -- - Michael Mason Arras People www.arraspeople.co.uk - -- 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] Opinion: PHP Sessions or Cookies
Just as folks can turn off JavaScript, they can reject cookies. Sessions have some advantages over cookies. [Original Message] From: Ed Lazor [EMAIL PROTECTED] To: [EMAIL PROTECTED] Date: 07/13/2004 2:47:31 PM Subject: [PHP] Opinion: PHP Sessions or Cookies I'm using PHP sessions for user tracking. My host provider's server is dropping session data. He swears it's my scripts and says I should be using cookies for better security. That goes completely opposite to my understanding, so I'd like to run it by you guys. Which is more secure: PHP sessions or cookies? In case you're curious, more details on the specifics of the problem I'm experiencing: I have a prepend file that executes start_session. The script assumes the user is a guest if $_SESSION[UserID] is not set. All guests route to the login screen. Successful authentication sets $_SESSION[UserID] and sends you to the original requested page. It seems fairly straight forward to me. People are able to login and start using the site, but the login screen displays randomly after they've already authenticated successfully. It sounds like PHP session data is being lost on the server. I've also seen error messages on web pages that report PHP / MySQL as having trouble reading from the temp directory. Here's the extact message: ERRORError writing file '/tmp/MYiYcf7q' (Errcode: 28). Anyway, those are the details. I look forward to hearing what you think. -Ed -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] encryption needed?
If you've set things up so that the id is available client-side, then there's no point in encrypting the id (by any encryption methods). If the id is stored in the client browser, then you'd better make sure it's linked to public data. [Original Message] From: klaus [EMAIL PROTECTED] To: [EMAIL PROTECTED] Date: 07/13/2004 3:17:54 PM Subject: [PHP] encryption needed? Hi all, I am to set up a service where users can view news of companies. To identify the company selected an easy way is to use the company-id. The id is not displayed but stored in the client browser as JS-variable. Question: Is it ok to use the company-id or do I have to encrypt the id using mcrypt (takes some time)? Thanks in advance Klaus -- 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] mail problem
Jason, et al: Is it not true that $HTTP_POST_VARS is more secure than $_POST, even though the latter is a superglobal? Doesn't the former acount for un-updated server versions? If it isn't, what disadvantage is there to using $HTTP_POST_VARS? Why should one use $_POST instead? (P.S.: Aidan Lister, this may be a dumb question, but please don't bother responding.) [Original Message] From: Justin Patrin [EMAIL PROTECTED] To: Jason Wong [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Date: 07/11/2004 12:29:24 AM Subject: Re: [PHP] mail problem You should also be using $_POST instead of $HTTP_POST_VARS. $_POST is a superglobal, so you can use it anywehere, it's shorter ;-), and it's the official way to access post vars. On Sun, 11 Jul 2004 08:52:54 +0800, Jason Wong [EMAIL PROTECTED] wrote: On Sunday 11 July 2004 08:33, Joao Gomes wrote: I am a beginner in php and I am trying to send emails from my machinne, I dont have any mail server installed in my computer (e.g. sendmail), btw i am running Windows XP, i wrote this script: [snip] and changed the php.ini to: [mail function] ; For Win32 only. SMTP = [EMAIL PROTECTED] SMTP (ie SMTP server) should be of the form: xxx.domain.tld, ie you should not have smtp@ in there. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* Death is God's way of telling you not to be such a wise guy. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php !DSPAM:40f08d67207261637984098! -- DB_DataObject_FormBuilder - The database at your fingertips http://pear.php.net/package/DB_DataObject_FormBuilder paperCrane --Justin Patrin-- -- 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] onchange drop down list and text field
I'm not sure, but I think he meant he wanted both (1) a select list based on elements in a database and (2) a textarea element where the client would enter something that does not appear in the select list. If so, you could use a script that uses the records in your database and has a final option for Other. For instance, on a MySQL database: ?php if (isset ($submit)) { if (isset ($other_color)) { $q_ins1 = INSERT INTO colors VALUES ('$other_color'); $q_ins2 = @mysql_query ($q_ins1); } else { $q_ins3 = INSERT INTO colors VALUES ('$color_choice'); $q_ins4 = @mysql_query ($q_ins3); } } ? html head/head body form action=?=$PHP_SELF ? method=post select name=color_choice ?php $q1 = SELECT color FROM colortable; $q2 = @mysql_query ($q1); /* Prints out the drop-down menu of colors (blue, green, red, yellow) */ while ($q3 = @mysql_fetch_array ($q2)) { echo option value=\$q3[color]\$q3[color]/option; } ? option value=otherOther/option /select textarea name=other_color cols=50 rows=2/textarea input type=submit name=submit value=Submit / /form /body /html You'd want to change the form according to your needs, and you may think of a better way of doing it. But, that might give you an idea of how to go about your project, assuming that I understood what you meant. [Original Message] From: Jason Wong [EMAIL PROTECTED] To: [EMAIL PROTECTED] Date: 07/08/2004 8:00:38 PM Subject: Re: [PHP] onchange drop down list and text field On Friday 09 July 2004 10:41, Curlys wrote: I would like to ask another help from u all , I have an data submitable form . There is some fields. It is connected with mysql database. so I want to put to these fields as drop down list as well as text input area. say , if when i adding data , if it is in the database there should be possibility to select from the drop down list . and if it is not there data should allow to enter . can u all help me on this matter ? What exactly is the problem you're having? Assuming you know how to pull the data out of the DB then it's simply a matter of wrapping select and option tags around them. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* Try the Moo Shu Pork. It is especially good today. */ -- 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] Is PEAR worth the effort?
It's hard to say whether it's worth the effort for you; it depends on what your going to do, both for your current project and future ones. However, in general, I believe the effort you put into learning PEAR is negligible compared to the yield. I don't think PEAR is a flash in the pan. [Original Message] From: Will Merrell [EMAIL PROTECTED] To: [EMAIL PROTECTED] Date: 06/30/2004 12:22:23 PM Subject: [PHP] Is PEAR worth the effort? I don't mean to start a flame war here, but I have been working in PHP for a while now and am about to start a more extensive aplication. Some of the PEAR modules look good and I just wanted to hear what the collected wisdom out here thinks about it. When I try to read the installation instructions my eyes glaze over and roll up into my head. Before I fight my way through this learning curve I want to know if its worth it? Is this the wave of the future or just a flash in the pan? Thanks, Will Merrell -- 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] Help with an objective
Also check the archives of this e-mail list. I believe this topic has been discussed before. [Original Message] From: Ryan Schefke [EMAIL PROTECTED] To: Php-General-Help [EMAIL PROTECTED] Date: 06/14/2004 5:48:16 AM Subject: [PHP] Help with an objective All, I would like to use php to email a picture (as an attachment) that is on my server (linux), without manually attaching/uploading one. Is this possible? If so, how can it be done? Thanks, Ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] converting a char variable to an int?
You could cast the type when you create the variable: $variable = (integer) $variable; Or you could set the type: settype ($variable, integer); However, the problem may be with the database, depending on what you mean by it's not working in my database this way. [Original Message] From: Adam Williams [EMAIL PROTECTED] To: [EMAIL PROTECTED] Date: 06/14/2004 8:32:18 AM Subject: [PHP] converting a char variable to an int? Hi, I have a variable that is created using the date command: $date = date(Ymd); but its not working in my database this way (when I explicity enter 20040614 in my database, it works though). so I think PHP is making $date a character variable, so how can I force or change the caste of $date to force it to be an integer variable? thanks -- 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] PHP en XML een vraag waard
42. [Original Message] From: De Saedeleer Yves [EMAIL PROTECTED] To: [EMAIL PROTECTED] Date: 06/14/2004 1:28:28 PM Subject: [PHP] PHP en XML een vraag waard Gegroet, Hoi Ik ben reeds een tijdje bezig met PHP en hier en daar lukt er al eens iets :=)) Maar nu stuit ik toch op een probleempje. Ik moet voor een siteje XML data gaan parsen die bekomen wordt uit een URL. Als ik deze URL in een browser invoer dan krijg ik XML code terug. Mijn vraag is nu: Welke code moet ik gaan in voeren (instuderen) om de aldus bekomen gevens om te zetten in bruikbare data voor het gebruyik in PHP. ik voer in de browser het volgende in: http://www.websiote.com/xml/xmlonl.asp?custid=CustIDprodid=ProdID en dan krijg ik iets in de zin van de data hieronder terug: ?xml version=1.0 ? - RealData MSG ID=0ok/MSG - ITEM ID876607/ID DESCAntec Aluminium Midi Tower 4x5,25 2x3,5 USB amp; IEEE1394 amp; audio 2x120mm fan NO PSU/DESC PRICE CURRENCY=EUR103,3/PRICE QTY32/QTY DELDATE15062004/DELDATE /ITEM /RealData wat ik hieruit nodig heb zijn de volgende gegevens: het veld QTY, PRICE CURRENCY en het veld DELDATE ik heb totaal geen ervaring met de combinatie PHP en XML. Alle hulp is meer dan welkom. Yves, -- 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] SQL Query Statement for MySQL... (DataType -- TEXT vs BLOB)
Probably a good question for a MySQL e-mail list. [Original Message] From: Scott Fletcher [EMAIL PROTECTED] To: [EMAIL PROTECTED] Date: 06/10/2004 12:49:07 PM Subject: [PHP] SQL Query Statement for MySQL... (DataType -- TEXT vs BLOB) I'm wrestling over deciding on which data type to go with, TEXT or BLOB. I have one table with one column of 400 characters, I was thinking that TEXT may be the way to go for that one. I also have another table that use 4 columns of 800 characters along with 5 columns that use 250 characters. I'm thinking of using TEXT for 9 of those columns. The reason is because I read the MySQL Manual there that say TEXT and BLOB are pretty much the same in many ways, the only thing different is that BLOB use VARCHAR Binary while TEXT use VARCHAR. But reading the article somewhere (not part of MySQL's Manual) say this... --snip-- If it doesn't have to be searchable then a BLOB might be more efficient and you shouldn't have to worry about size (Like size is important? ). The reason being that BLOB information is stored seperate from the table data and is related by a reference number in the table. This keeps the table smaller and faster as I understand. --snip-- So, I don't feel too sure what to decide on... Care for some advice or recommendation?? Thanks, Scott Fletcher -- 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: if/elseif/else v. switch
Good. Initially, before I sent this message, I was concerned that it was a really, really, really stupid question. But I apparently hit the mark perfectly with two reallys. Since you seem to enjoy answering them, I shall try to come up with a slew of what I hope will be really, really stupid questions, just for you. Should I send them to your e-mail directly, or share them with the whole list? After all, maybe not everyone enjoys really, really stupid questions as much as you. Just a quick note to clarify: I did ask about the difference between the two conditionals, and a difference in speed is a good example of a difference. In seriousness, if you think it's an unworthy question, why take the time to respond? Deleting the message will take far less energy. Also, I can't see the harm in asking a stupid question (or question that involves one or more reallys), so long as I get an answer. After all, it isn't as though I ask people to write scripts for me or ask questions just to avoid the hassle of looking in the manual. [Original Message] From: Aidan Lister [EMAIL PROTECTED] To: [EMAIL PROTECTED] Date: 06/05/2004 2:04:03 AM Subject: [PHP] Re: if/elseif/else v. switch This appears to be a really, really stupid question. If they are indentical in operation, then ofcourse there will be no noticeable difference to the user. One may note that a switch statement is faster, because the condition is only evaluated once. However you did not ask about the speed difference. Dennis Seavers [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Is there any noticeable difference (on the part of the client) between identical conditionals, one written as a switch, the other written as an if, elseif ... else conditional? I realize that one programmer coming in behind another might prefer the gentler layout of a switch; but would there be any perceivable difference, client-side, between the options? -- 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: if/elseif/else v. switch
[Original Message] From: Aidan Lister [EMAIL PROTECTED] To: [EMAIL PROTECTED] Date: 06/05/2004 6:19:24 AM Subject: Re: [PHP] Re: if/elseif/else v. switch Hi Rachel, You'll note I did not criticise the poster, merely his seemingly stupid question. P.S. Isn't it possible that you offended the question by criticizing it? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] select from db
When you run this script, or one like it, does it work? You seem to be missing a number of brackets. For example, you have: while ($row = MYSQL_FETCH_ROW($result)) instead of while ($row = MYSQL_FETCH_ROW($result)) { or while ($row = MYSQL_FETCH_ROW($result)) { [Original Message] From: Robert Sossomon [EMAIL PROTECTED] To: BigMark [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Date: 06/03/2004 11:44:58 PM Subject: Re: [PHP] select from db !SNIP table name 'Selections' (rows) RoundGameName Winner Points data eg 1 1mark Hawthorn 4 (if team is a winner then 4 points added) 1 2mark Geelong 0 ! End Snip Assuming you have them submit a form to get here: ?php //somefilename //Access your Database include db.php; //Name from previous form, or you can use from authentication, //whichever, just mod the code to reflect where getting it from $name = $_POST[name]; //query and results $query = select * from Selections where Name='$name'; $result = mysql_query($query); /* Determine the number of records returned */ while ($row = MYSQL_FETCH_ROW($result)) $number = mysql_numrows($result); /* Start printing to make it look good */ print table cellspacing=\0\ cellpadding=\5\ border=\1\; print trthRound/ththGame/ththName/ththWinner/ththPoints/th /tr; $total_points=0; /* Iterate through to make it clean */ while ($i $number) { $item_1 = mysql_result($result, $i,Round); $item_2 = mysql_result($result, $i,Game); $item_3 = mysql_result($result, $i,Name); $item_4 = mysql_result($result, $i,Winner); $item_5 = mysql_result($result, $i,Points); /* This makes it print out in 2 separate color, depending on rows. */ if ($i%2 == 0) { print tr bgcolor=\#ee\td$item_1/tdtd$item_2/tdtd$item_3/tdtd$ite m_4/tdtd$item_5/td/tr\n; } else { print tr bgcolor=\#ff\td$item_1/tdtd$item_2/tdtd$item_3/tdtd$ite m_4/tdtd$item_5/td/tr\n; } /* Increase record count and total_points to date */ $i++; $total_points += $item_5; } /* close everything up */ print trth colspan=5Total Points Earned: $total_points/th/tr; print /table; } ? -- 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] select from db
I think I misread your script. I took the line print table cellspacing=\0\ cellpadding=\5\ border=\1\; to be part of the while loop, meaning there would be two statements. I'm not accustomed to seeing scripts that use functions without brackets, even when their not required. Sorry for the confusion. [Original Message] From: Dennis Seavers [EMAIL PROTECTED] To: Robert Sossomon [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Date: 06/04/2004 12:00:39 AM Subject: Re: [PHP] select from db When you run this script, or one like it, does it work? You seem to be missing a number of brackets. For example, you have: while ($row = MYSQL_FETCH_ROW($result)) instead of while ($row = MYSQL_FETCH_ROW($result)) { or while ($row = MYSQL_FETCH_ROW($result)) { [Original Message] From: Robert Sossomon [EMAIL PROTECTED] To: BigMark [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Date: 06/03/2004 11:44:58 PM Subject: Re: [PHP] select from db !SNIP table name 'Selections' (rows) RoundGameName Winner Points data eg 1 1mark Hawthorn 4 (if team is a winner then 4 points added) 1 2mark Geelong 0 ! End Snip Assuming you have them submit a form to get here: ?php //somefilename //Access your Database include db.php; //Name from previous form, or you can use from authentication, //whichever, just mod the code to reflect where getting it from $name = $_POST[name]; //query and results $query = select * from Selections where Name='$name'; $result = mysql_query($query); /* Determine the number of records returned */ while ($row = MYSQL_FETCH_ROW($result)) $number = mysql_numrows($result); /* Start printing to make it look good */ print table cellspacing=\0\ cellpadding=\5\ border=\1\; print trthRound/ththGame/ththName/ththWinner/ththPoints/th /tr; $total_points=0; /* Iterate through to make it clean */ while ($i $number) { $item_1 = mysql_result($result, $i,Round); $item_2 = mysql_result($result, $i,Game); $item_3 = mysql_result($result, $i,Name); $item_4 = mysql_result($result, $i,Winner); $item_5 = mysql_result($result, $i,Points); /* This makes it print out in 2 separate color, depending on rows. */ if ($i%2 == 0) { print tr bgcolor=\#ee\td$item_1/tdtd$item_2/tdtd$item_3/tdtd$ite m_4/tdtd$item_5/td/tr\n; } else { print tr bgcolor=\#ff\td$item_1/tdtd$item_2/tdtd$item_3/tdtd$ite m_4/tdtd$item_5/td/tr\n; } /* Increase record count and total_points to date */ $i++; $total_points += $item_5; } /* close everything up */ print trth colspan=5Total Points Earned: $total_points/th/tr; print /table; } ? -- 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] Bulk table updates
Maybe I don't understand what you're trying to accomplish -- and I'm not sure what you meant by parsed through then just one line -- but the application you have at the link would work if you set the default values of the form elements to the data currently in your table. Even if you have a separate page for entering data, you can have the same script handle both the data viewing and updating. Hope that helps (but I'm guessing it won't) [Original Message] From: Robert Sossomon [EMAIL PROTECTED] To: [EMAIL PROTECTED] Date: 06/03/2004 11:23:31 PM Subject: Re: [PHP] Bulk table updates I use a separate page to do the addition of information to my DB currently, the whole set of information is being re-written as I type this, but where I am stuck is getting the whole thing to be parsed through then just one line. The code I currently use is as follows: SNIP CODE !-- modifycart.php -- $get_Quote = select st.id, st.sel_item_id, st.sel_item_desc, st.sel_item_price, st.sel_item_qty, st.sel_item_comment from store_shoppertrack as st left join items as si on si.id = st.sel_item_id where session_id = '$PHPSESSID' order by $vsort; $get_Quote_res = mysql_query($get_Quote) or die(mysql_error()); while ($row = MYSQL_FETCH_ROW($get_Quote_res)) $number = mysql_numrows($get_Quote_res); if (mysql_num_rows($get_Quote_res) 1) { //print message $display_block = PYou have no items in your Quote. Please a href=\seestore.php\continue to shop/a!/P; } else { //get info and build Quote display while ($i $number) { $id = mysql_result($get_Quote_res,$i,'id'); $item_title = mysql_result($get_Quote_res,$i,'sel_item_id'); $item_desc = mysql_result($get_Quote_res,$i,'sel_item_desc'); $item_price = mysql_result($get_Quote_res,$i,'sel_item_price'); $item_qty = mysql_result($get_Quote_res,$i,'sel_item_qty'); $item_comment = mysql_result($get_Quote_res,$i,'sel_item_comment'); if ($item_title == ) { $display_block .= trtdComment:/tdtd colspan=2 align=centerform method=post action=\replacecart.php\input type=\hidden\ name=\sel_item_id\ value=\$item_title\input type=\text\ size=75 name=\sel_item_desc\ value=\$item_desc\input type=\hidden\ name=\sel_item_qty\ value=\1\input type=\hidden\ name=\SESSID\ value=\$PHPSESSID\\ninput type=\hidden\ name=\id\ value=\$id\\ninput type=\hidden\ name=\url\ value=\$_SERVER[PHP_SELF]?view_code=$view_code\input type=\hidden\ name=\sel_item_price\ value=\0\/tdtdselect name=\color\option value=\aqua\aqua/optionoption value=\black\black/optionoption value=\blue\blue/optionoption value=\fuchsia\fuchsia/optionoption value=\gray\gray/optionoption value=\green\green/optionoption value=\lime\lime/optionoption value=\maroon\maroon/optionoption value=\navy\navy/optionoption value=\olive\olive/optionoption value=\purple\purple/optionoption value=\red\red/optionoption value=\silver\silver/optionoption value=\teal\teal/optionoption value=\white\white/optionoption value=\yellow\yellow/option/select\n/tdtdCurrently: $item_comment/tdtdinput type=\submit\ name=\submit\ value=\Modify\/form/td/tr\n; } else { $display_block .= \ntrtdform method=post action=\replacecart.php\\n; $display_block .= $item_title/tdtdinput type=text size=4 name=\sel_item_qty\ value=\$item_qty\\n; $display_block .= /tdtdinput type=\text\ size=75 name=\sel_item_desc\ value=\$item_desc\; $display_block .= input type=\hidden\ name=\SESSID\ value=\$PHPSESSID\\ninput type=\hidden\ name=\id\ value=\$id\\ninput type=\hidden\ name=\sel_item_id\ value=\$item_title\\n; $display_block .= input type=\hidden\ name=\url\ value=\$_SERVER[PHP_SELF]?view_code=$view_code\\n/tdtd; $display_block .= input type=\text\ name=\sel_item_price\ size=\5\ value=\$item_price\\n/tdtd\ninput type=\text\ name=\comment\ value=\$item_comment\/tdtd\n; $display_block .= input type=\submit\ name=\submit\ value=\Modify\/form/td\n; } $i++; } !-- End Modify Cart -- !-- Replacecart.php -- $addtocart = replace into store_shoppertrack values('$_POST[id]','$_POST[SESSID]','$_POST[sel_item_id]','$_POST[sel_item_ qty]','$_POST[sel_item_price]','$_POST[sel_item_desc]','$comment', now(),'','','',''); mysql_query($addtocart); !-- End Replace Cart -- End Snip CODE I have a test set of data and stuff set up on my server: http://lonewolf.homelinux.net/quoter There are some errors in not getting to other tables, but they are irrelevant for seeing what is there. The data in the table is of course bogus data, but you should see what I am getting at. Thanks, Robert Use a SELECT query to get the values (SELECT * FROM table) and a table that has form input fields in the cells. The values for the form fields would be based on the array you get from the SELECT query. The form could be something like form action=?=$PHP_SELF ? method=post. In the script, before the body, you would have an if statement to check whether the
RE: [PHP] table formatting
Change the design of the HTML table. [Original Message] From: BigMark [EMAIL PROTECTED] To: [EMAIL PROTECTED] Date: 06/04/2004 8:07:51 PM Subject: [PHP] table formatting This script by Rob Sossomon works great --Thanks! however could anyone tell me if its possible to make it run horizontally. at the moment the output is like this--- -- Round Game Winning team Wins 1 1 Collingwood 1 2 Melbourne 4 1 3 Fremantle 4 1 4 Brisbane 4 1 5 St Kilda 1 6 Port Adelaide 4 1 7 Kangaroos 4 1 8 West Coast 4 2 1 Richmond 2 2 Collingwood 4 2 3 Brisbane 4 2 4 West Coast 2 5 Essendon 2 6 Fremantle 2 7 Carlton 4 2 8 Hawthorn --I would like it like this Round game1wingame2 win game3 etc 1 Collingwood 4 Melbourne 4 Fremantle 4 ?php session_start(); include(connect.php); $Name = $_SESSION['first_name'] . . $_SESSION['last_name']; $sql = SELECT * FROM Selections WHERE Name = '$Name'; $result = mysql_query($sql); /* Determine the number of records returned */ while ($row = MYSQL_FETCH_array($result)) $number = mysql_numrows($result); /* Start printing to make it look good */ print table width=\30%\ cellspacing=\0\ cellpadding=\0\ border=\0\; print trthRound/ththGame/ththWinning Team/ththWins/th/tr; $total_points=0; /* Iterate through to make it clean */ while ($i $number) { $item_1 = mysql_result($result, $i,Round); $item_2 = mysql_result($result, $i,Game); $item_4 = mysql_result($result, $i,Winner); $item_5 = mysql_result($result, $i,Points); /* This makes it print out in 2 separate color, depending on rows. */ if ($i%8 == 0) { print tr bgcolor=\#99\tdcenter$item_1/center/tdtdcenter$item_2/ce nter/tdtdcenter$item_4/center/tdtdcenter$item_5/center/td /tr\n; } else { print tr bgcolor=\#66\tdcenter$item_1/center/tdtdcenter$item_2/ce nter/tdtdcenter$item_4/center/tdtdcenter$item_5/center/td /tr\n; } /* Increase record count and total_points to date */ $i++; $total_points += $item_5; } /* close everything up */ print trth colspan=5Total Points Earned: $total_points/th/tr; print /table; ? -- 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] if/elseif/else v. switch
Is there any noticeable difference (on the part of the client) between identical conditionals, one written as a switch, the other written as an if, elseif ... else conditional? I realize that one programmer coming in behind another might prefer the gentler layout of a switch; but would there be any perceivable difference, client-side, between the options?
Re: [PHP] Re: Call JS Function with PHP Header()?
You should be able to use the comment tags, just put them inside the script tags: echo script language=\javascript\ type=\text/javascript\ !-- this.print() //-- /script; I don't believe you need a semi-colon after this.print within the javascript script. [Original Message] From: Nick Wilson [EMAIL PROTECTED] To: [EMAIL PROTECTED] Date: 06/03/2004 11:02:57 AM Subject: Re: [PHP] Re: Call JS Function with PHP Header()? * and then Nick Wilson declared !-- script type=text/javascript this.print(); /script //-- Right in the middle of the body. It doesnt work LoL! - Seems to me that it should do...? Ah... XHTML Strict - Gotta remove the comment tags ;-) Thanks mate.. -- Nick W -- 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] Security/Web tree/db connect and select
I have a question about comparing the security risks for two methods of connecting to a database with PHP. The DBMS is MySQL. Option 1: Include the mysql_connect and mysql_select_db commands within the script that manipulates the data from the database. Option 2: Include the mysql_connect and mysql_select_db commands (along with usernames and passwords) outside the Web tree, but have the script run from within the Web tree. The script would use a command like file() or file_get_contents() to get the information from a text file outside the Web tree. My belief is that Option 2 affords a higher level of security than Option 1, but I wanted to make sure. TIA. Dennis
RE: [PHP] Newbie Question: Variables on the fly
Maybe others will catch on to your intention, but I think you need to provide a bit more information. For example, what variables do you want to create (drawn from a file source, or create on the fly)? Where will they come from (a database, perhaps)? You could create a script that creates variables from scratch, following a (hopefully) finite mathematical formula. Or you could manipulate data that already exists, turning this data into some kind of variables. Ultimately, you'll have to give a better of sense of the end result you'd like. Dennis Seavers [Original Message] From: [EMAIL PROTECTED] To: PHP List [EMAIL PROTECTED] Date: 05/27/2004 9:17:11 PM Subject: [PHP] Newbie Question: Variables on the fly Hello, I'm sure this is a newbie question but I don't know the syntax. I want to create a series of variables within a php script at runtime with a for loop. eg myVar1 myVar2 myVar3 etc What is the proper syntax to do this? Thanks, Tim -- 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] Newbie Question: Variables on the fly
Yikes!! List members, I apologize for sending a reply-requested e-mail over this list. Feel free to punish me by responding. What's worse: I took another list member to task for the same thing! Ego deflation commences in 5 ... 4 ... 3 ... Dennis JackArse (the JackArse is silent) [Original Message] From: Dennis Seavers [EMAIL PROTECTED] To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Date: 05/27/2004 9:30:19 PM Subject: RE: [PHP] Newbie Question: Variables on the fly Maybe others will catch on to your intention, but I think you need to provide a bit more information. For example, what variables do you want to create (drawn from a file source, or create on the fly)? Where will they come from (a database, perhaps)? You could create a script that creates variables from scratch, following a (hopefully) finite mathematical formula. Or you could manipulate data that already exists, turning this data into some kind of variables. Ultimately, you'll have to give a better of sense of the end result you'd like. Dennis Seavers [Original Message] From: [EMAIL PROTECTED] To: PHP List [EMAIL PROTECTED] Date: 05/27/2004 9:17:11 PM Subject: [PHP] Newbie Question: Variables on the fly Hello, I'm sure this is a newbie question but I don't know the syntax. I want to create a series of variables within a php script at runtime with a for loop. eg myVar1 myVar2 myVar3 etc What is the proper syntax to do this? Thanks, Tim -- 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] Simplistic PHP tutorial
I disagree with the suggestion that you need to or should have programming experience to learn PHP, although it is helpful. There are a few books out there (and books probably are the best starting point) that assume the reader has no programming background, although you need to be familiar with HTML (and not just creating HTML pages with a WYSIWYG like GoLive or FrontPage). Larry Ullman's book is a good example (PHP FOR THE WORLD WIDE WEB, Peach Pit Press). [Original Message] From: Gabino Travassos [EMAIL PROTECTED] To: [EMAIL PROTECTED] Date: 05/25/2004 9:17:10 AM Subject: Re: [PHP] Simplistic PHP tutorial I've looked at the php.net tutorial, and though I'm learning some things from it, it's still a bit over my head. It seems to presuppose a comfort level with programming which I do not have. Can anyone recommend a simple, hand-holding, introductory tutorial suitable for someone with no programming experience to speak of? Personally, if I was teaching someone programming concepts from scratch I would start them with Javascript. It's mostly platform-independent, you don't need to install any software, and you don't need to upload your files to a server that has PHP installed. Most of the basics (functions, variables, math) are the same in php, perl, flash, and Javascript, and Javascript is the simplest one in terms of getting started and testing your code quickest. There are some differences, of course, but you'll always be double-checking your syntax anyway. I like the PHP book from Wiley. And MySQL/PHP Database Applications from MT Books. For Javascript, buy the cheapest, oldest used book you can find. Or Inside Javascript from New Riders. Luck. -- 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