[PHP] writing source code to file
I was wondering if there was a block of code I could place at the bottom of the file that would write the page's source code to an html file. I need this because I'm posting pages to a server sans a PHP compiler. Basically, I'd like for every time I run a page its source code to be saved in the filename of my choice, instead of me having to run the page, copy the source, and paste it into the file of my choice. I know how to use fopen, but I'm not sure what to tell it to write to file, since the source I want to write is being generated simultaneously. Any help would be greatly appreciated... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Inserting string - need to trim comma
Hi - I'm trying to create a very basic function that add the results of a form to my database. I have this code so far, with $table being the table name and the $data is an exact copy of the $_POST array. function insert($table, $data) { $sql = INSERT INTO .$table. SET ; foreach ($data as $k=$v) { $sql.= $k. = '.$v.', ; } $sql.=;; $result = mysql_query($sql); } The only problem with the statement is the appended comma to each iteration - the statement generates a mysql error with the extra comma at the end of the statement. This seems like an easy fix -any ideas? Any help would be greatly appreciated... http://www.phreshdesign.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Inserting string - need to trim comma
implode() worked perfectly. thanks - doug - Original Message - From: Chris Shiflett [EMAIL PROTECTED] To: Doug Parker [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Thursday, April 01, 2004 2:19 PM Subject: Re: [PHP] Inserting string - need to trim comma --- Doug Parker [EMAIL PROTECTED] wrote: function insert($table, $data) { $sql = INSERT INTO .$table. SET ; foreach ($data as $k=$v) { $sql.= $k. = '.$v.', ; } $sql.=;; $result = mysql_query($sql); } The only problem with the statement is the appended comma to each iteration - the statement generates a mysql error with the extra comma at the end of the statement. You can usually avoid this type of problem in the first place with implode(). Something like this (untested): sql = insert into $table set ; $pairs = array(); foreach ($data as $key = $value) { $pairs[] = $key = '$value'; } $sql .= implode(',' $pairs); --- Matt Matijevich [EMAIL PROTECTED] wrote: http://www.php.net/rtrim rtrim() trims whitespace, not commas. Hope that helps. Chris = Chris Shiflett - http://shiflett.org/ PHP Security - O'Reilly Coming Fall 2004 HTTP Developer's Handbook - Sams http://httphandbook.org/ PHP Community Site http://phpcommunity.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Error redirect function
I have a message board script that requires certain parameters like message_id, thread_id, etc. The whole thing works fine, I'd like to have a generic error page to default to in the case that someone fools with the parameters above - for example, setting the thread id to 400 when there are only 300 threads. Right now, it just generates the mysql error message, which doesn't look nice. I know you can use the die() function after the mysql_query function to display some text in the case of an error, but I want to go a little further by redirecting to an error page. How would I go about doing this? Any help would be greatly appreciated. - Doug http://www.phreshdesign.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Selecting between using letters
How would I create a select statement in MySQL that would return a range of records from the LastName field where the value starts with a designated letter - for example, returning the range where the first letter of LastName is between A and E... Any help would be greatly appreciated. http://www.phreshdesign.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Creating a line break between letter groupings
I'm reading a list of stores from a database and ordering them alphabetically. How would I place a line break in between each letter grouping? For example, Applebee's Aaron's Place Aardvark Store Bumblebee's Bears R' Us Big Bad Johnny's Caterpillar central Coffee time!! etc.- with the line break occuring in between each letter grouping. Any help would be greatly appreciated. -- http://www.phreshdesign.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re[2]: [PHP] Creating a line break between letter groupings
Worked great. Thanks!! Tom Rogers [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi, Thursday, November 20, 2003, 11:12:55 AM, you wrote: TR Hi, TR Keep track of the first letter and if it changes echo a br TR $key = '' TR //loop through results TR while($result = mysql..){ TR $char = strtoupper(substr($row['name'],0,1)); TR if(empty($key){ TR $key = $char;//first result set key TR else{ TR if($key != $chat){ TR echo 'br'; TR $key = $char; TR } TR } TR //rest of loop TR } TR -- TR regards, TR Tom Stupid keyboard :) $key = '' //loop through results while($result = mysql..){ $char = strtoupper(substr($row['name'],0,1)); if(empty($key){ $key = $char;//first result set key else{ if($key != $char){ echo 'br'; $key = $char; } } //rest of loop } -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] storing quotes into a variable
isn't there a function that allows me to store a string with a bunch of quotes in it (like an html tag) into a variable? for example, i need something like: $perf_mod = a href=# onclick=popWindow('popup.php') thanks... -- http://www.phreshdesign.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] upload problems
I'm trying to do some uploading on my server, and I'm not getting any value for my tmp upload setting - meaning this code: $source = $_FILES['cat1_thumb']['tmp_name']; echo $source; returns nothing. The form is fine - meaning that the text input name is correct and I am indeed selecting a file. I realized that our upload_tmp_dir setting was not set, so I had the admin set it, but it still returns nothing. Is there another setting I should check? Thanks -- http://www.phreshdesign.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] File upload restrictive permissions
Recently I had a problem with file uploading on a server I use, and the problem was that the tmp/ directory was not set. Now that it has been set, the images do upload, but the file permissions end up being very restrictive - something like (-rw---) - so the images obviously do not show up on the web. I know I could login and chmod tihs, but since we have clients upload their own images, it goes without saying that this would be a major inconvenience. Our sysadmin, who is relatively clueless, suggested that I add a php chmod function to my scripts. I suppose this would work, but I don't understand why my scripts once worked without this function - the files uploaded and were web-viewable. I checked both the target directory and tmp/ directory, and both are fit for web viewing. Any ideas as to how I could fix this? Thanks... http://www.phreshdesign.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] need a reliable PHP host
Hi everyone - I need suggestions for a reliable PHP/mySQL host that has cURL support WITH https capability. The site is e-commerce, but is mainly a statistics site that relies on frequent mysql requests, rather than numerous transactions. The only transaction is the site subscription fee. I could also use suggestions for a reliable Credit Card processor. If anyone has experience with this and can point me in the right direction, I would REALLY appreciate it. I'm having alot of trouble with shoddy hosting and a terrible cc processor right now, I really need to know which direction to take. Thanks - Doug -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] looking for advice on PHP server
My server has cURL built into its php module, but it doesn't support SSL, and thus doesn't support requests to secure servers, i.e. https. It was an effort in itself to get them incorporate cURL, and I was just wondering if I should move immediately to a new host - if this were just ridiculous. I needed cURL badly in order to process credit card transactions, now I don't even have the option. I supposed I could use the PHP wrapper with the API, but it looks difficult and the processing company (Linkpoint) really doesn't seem to have their stuff together as far as support goes, or anything for that matter. What should I do? If I should move, could anyone suggest a decent host that could handle the aforementioned? any help would be greatly appreciated... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] quick question
I'm sending credit card info to a 3rd party credit card processing site. I would like to keep the inputted values and, after the approval, have them appear in the value part of the form so that they don't have to re-input the same values they had just put in for the credit card. how can i do this? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] form submission and storing variables
I'm sending information to be processed by a third party site. I need to store the inputted information in my site, via session or whatever, at some point. However, the 3rd part site only accepts the information via a POST form submission, so I can't record the variables, then redirect them to the 3rd party site via a header function. What should I do? any help would be greatly appreciated. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] quick question
Right - but the problem is, the form is submitting to another site, so i don't have a way to store the variables. I could put them in session variables, but I would have to create another script and then forward the form submission to the outside side. This isn't working because the outside site requires the variables to be submitted via a form, or POST i guess. I don't even know if I'm going about this the right way - I just need to somehow store variables on my site that are submitted for processing to another site, so that when the user is sent back from that other site, i can put the values in the form fields of a new page. Cpt John W. Holmes wrote: I'm sending credit card info to a 3rd party credit card processing site. I would like to keep the inputted values and, after the approval, have them appear in the value part of the form so that they don't have to re-input the same values they had just put in for the credit card. how can i do this? So put the value in the value attribute of your text box. input type=text name=cc_number value=?=$_POST['cc_number']? substitute $_POST['cc_number'] with whatever you send to the processing site. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] refreshing scripts a problem
I'm having trouble with my php scripts running on my local machine. I'm running winXP, apache, and for the most part, everything runs ok. But sometimes the scripts will refresh rapidly for a few seconds, and then give up - This page cannot be displayed. It seems to happen more often when I'm sorting a query that i had run in phpMyAdmin, and sometimes in normal scripts as well. Everything works fine on a remote server. Is there a setting I can change here? this is getting really annoying. any help would be greatly appreciated. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] need apostrophe solution
OK - thanks. I saw that the magic_quotes_gpc is turned off by default, so I did a ini_set(magic_quotes_gpc, 1) to turn it on temporarily. I ran a get_magic_quotes_gpc() and saw that the ini_set did work, but for some reason the query still won't accept the quotes. What am i doing wrong? thanks again, doug Chris Shiflett wrote: --- drparker [EMAIL PROTECTED] wrote: i need to escape all my apostrophes in values submitted to a mySQL database. http://www.php.net/manual/en/function.addslashes.php is there a way i can loop thru all the post variables and replace the apostrophes? Read about the magic_quotes setting in your php.ini. Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] need apostrophe solution
So you're saying that I have to turn on magic_quotes_gpc in php.ini in order for it to work? the ini_set won't work? Leif K-Brooks wrote: Magic_quotes has already done (or not done) its job by the time your script runs. Doug Parker wrote: OK - thanks. I saw that the magic_quotes_gpc is turned off by default, so I did a ini_set(magic_quotes_gpc, 1) to turn it on temporarily. I ran a get_magic_quotes_gpc() and saw that the ini_set did work, but for some reason the query still won't accept the quotes. What am i doing wrong? thanks again, doug Chris Shiflett wrote: --- drparker [EMAIL PROTECTED] wrote: i need to escape all my apostrophes in values submitted to a mySQL database. http://www.php.net/manual/en/function.addslashes.php is there a way i can loop thru all the post variables and replace the apostrophes? Read about the magic_quotes setting in your php.ini. Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] approaching a relational database
I'm about to embark on a project where I have to enter many, many fields into a MySQL database, and I don't know how to approach the database structure. The data is statistics for a golf course. There are 18 holes, and each hole has a Red Tee Par, White Tee Par, and Blue Tee Par, which is 54 inputs already (18 x 3). Then, there are about 5 more statistics I have to keep for each hole, making the total amount of inputs 144 (18 x 8). There's about 7 more fields pertaining to the Course name, location, etc. How the heck do I approach this? I've successfully done relational databases before, but not to this scale. Does anyone have any suggestions as to how I should approach this? I attached a .jpg of the form I'm using to input, just to clarify things. Any suggestions would be greatly appreciated... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Beginner question : Removing spaces in forms
I've solved similar things, i.e. removing commas from a number of text fields, by looping through the input boxes and doing a search/replace - all using Javascript via the onSubmit event. This chunk of code removes commas from input boxes: script for (var i = 0; i form.elements.length; i++) { var pattern = /,/ig; var newString = form.elements[i].value.replace(pattern,); form.elements[i].value = newString; } /script In your case, you'd just replace the , with a . I don't know of an easier way, though if one exists I'd would like to know about it. Andrew Wilson wrote: Hay guys i was wondering if there was a form parameter of something equivalent for input text boxes that when a user enters a number or series of numbers that it removes the spaces. If there is no alternative how would you go about solving this issue. Your help is appreciated. Thanks. Netway Networks Pty Ltd (T) 8920 8877 (F) 8920 8866 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Select drop-down box overflow?
I've got sort of an odd one here. I'm populating a select drop down box with a substantial number of options - actually every county in the U.S.- which is about 3000 results from a query. The problem is that when I load the page, there are all kinds of weird problems, characters, you name it. I'm wondering if theres's a limit to how many options I can have in a select drop down box? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Integer to decimal value.
I know this seems easy, but I can't get it to work for the freaking life of me. I have number that is an integer, lets say 15, and I need it to be 15.00, for a monetary value. I've casted every which way to no avail. Any help would be greatly appreciated. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Integer to decimal value.
excellent. thanks. John W. Holmes wrote: I know this seems easy, but I can't get it to work for the freaking life of me. I have number that is an integer, lets say 15, and I need it to be 15.00, for a monetary value. I've casted every which way to no avail. www.php.net/number_format ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] passing form variables with the same name
I'm passing form variables from a script that is meant to display information to be updated in a mysql database, and it sends these to a script that updates the changed values. The problem is, I have a number of the same field being passed. For example, I have two fields in an html form - Resource and Task, that need to be updated in a specific table, let's call it Projects. However, I need to update every Resource and Task in table Projects. So if there were 5 rows in Projects, the script would display the values for Task and Resource for all 5 rows, so that would total 10 input boxes. Obviously, I loop the display of these variables in input boxes as to get all 5 rows. So in order to send the variables to the script that will update them, they need to be unique - right? I can't have the input name=Resource for each one, so in the loop on the form I resolved this by appending a number to each one - e.g. input name=Resource1, input name=Task1, input name=Resource2, ... etc. So now I have the unique variables I need, the problem is that I have no idea how to loop through them in the update script and update each one accordingly. Can someone give me an idea how to do this? I'd love to use an array, but I don't think you can pass an array value from a form and have it work on the update script - e.g. input name=Resource[0]... any help would be greatly appreciated. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] quick mysql question
where can i find info on setting up a mysql database on a remote server? i know how to set them up on a local machine, but i can't figure out how to get to the command line setting on a remote server... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] quick mysql question
jon - thanks for the reply. i tried this: prompt ssh server.net i got an open failed: no such file or directoy does that mean that ssh is not enabled on the server? i pinged the server and it said it was alive... Jon Haworth wrote: Hi Doug, where can i find info on setting up a mysql database on a remote server? i know how to set them up on a local machine, but i can't figure out how to get to the command line setting on a remote server... me@mybox:~$ ssh my.remote.server Or am I missing something? Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] MySQL vs. basic text file
often i use text files at my data sources, delimted by the | symbol. i simply delimit the fields of each line, then when i need to open them, i open the text file, populate an array with each line, then explode the fields for each to get the corresponding values. i use this method for catalogs - and even backend interfaces, for which the client can add/edit/delete products. everything seems to be working fine, and there doesn't seem to be a need for MySQL or anything. i was wondering if there is anything i'm not thinking of that perhaps would push me to favor using php and mysql instead of the plain old text file. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php