[PHP] Advice
Hello all, I need some advice on which version of PHP server to go with, as I am completely new to PHP. The website I am doing research for would need to be able to access a database in order to make the site interactive. Similar to the Microsoft Knowledge base at MSDN but for something totally different. Also the site would need to be able to process orders possibly with in built secure facilities that can process credit card numbers. I may outsource that side of the project but if I do it needs to seamlessly integrate with the website I am developing. Later I may need Java servelets as well so the server is going to have to be able to allow me to install support for them or have that already built in. Is PHP 4 established enough to develop this kind of project or should I look at PHP 3 instead? Any advice on a good server that would enable the points I suggested? Thanks. Steve Jackson Phone +358503435159 Email [EMAIL PROTECTED] Web http://www.webpage.co.uk/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] phpMyAdmin is this possible
I am new to MySQL and PHP. Having looked at PHPMyAdmin the GUI I was wondering if it's possible to create a new database within the system? If so what are the commands? I ask because I only have one database on my server and don't want to populate it with different tables, I'd rather have seperate ones for seperate functions.. Ideas or advice? is the way I am suggesting better or worse than the way my hosting company expects me to work? Thanks in advance. Steve. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] phpMyAdmin
Is it possible to use phpMyAdmin to add new databases (not tables whole databases) to my website? I ask because currently my host has provided me with one database and I don't want to mix database tables when adding new features (such as shopping carts and bulletin boards)? I am new to MySQL and PHP so would like some advice, is the way I describe (databases for each website function) a good way to design or should I have all my functions in one large database? Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Different output on two different servers
Hi all, I have set-up a production server and a live server. The problem is with the production server. I am using PHP version 4.2.3 and MySQL 3.23.39 on both servers. We have just configured the production server to mimick the live server (which incidentally works fine) and the code from both servers is identical. I dumped all the data into the production MySQL database then copied the code from the live server to our production one and there didn't seem to be any problems. However today my boss asked for a new category to go into our webshop with a new product. I went into MySQL and updated the database fine then when I went to check the section of the site to see if the extra category and product are there I get my own PHP encoded error 'No categories currently available'. It fails on the first function: function display_categories($cat_array) { //display all categories in the array passed in if (!is_array($cat_array)) { echo brNo categories currently available.br; } else { //create table echo table width = \760\ border='0' background='images/shopbg.gif'; etc. Now it works superbly on my live server and did work fine until I tried adding another field to the database on the production server. Where should I start looking to de-bug this? Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Theoretical - Device server using PHP - Is this possible?
Hi all, I work for a company that manufactures device servers. They currently have a very low internal memory (about 8MB) which is more than enough for TCP/IP connections (which BTW we just released the code open source to anyone interested www.opentcp.org) to devices but I was wondering if there was any way we could give these device servers more functionality by somehow using PHP. Obviously the device server itself has nowhere near enough memory to have PHP installed upon it but it would be interesting to see if anyone has any ideas or theories about if this is possible. Thanks in advance. Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] server problems.
I have a production server and a 'live' web server. The set-ups are the same and yet I can view code fine on the 'live' web site but not on the production server. At least I can view one shopping cart section online but not offline. All the other database driven stuff appears fine. I've even tried dumping the 'live' database onto my production server and deleting and re-installing the code. No effect. Any ideas? The shop section even worked offline until I added a new category now it simply doesn't show anything. Flummoxed because on the live server everything works hunky dory. Also the shop admin functions are password protected - now when I try to login to that it refuses to let me in, even though the same password and login functions are ok on the live server. I tried adding a new user - no effect. It's like it just refuses to read this part of my database, but everything else will work OK. Any ideas? Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] How do I populate a select?
How do I populate a select list with a list of category names from a DB? I can select the names using a query but how do I loop through them to display them in a select? My query below will return the cat names. (when I do something with it like echoing the result) $mysql = mysql_query(SELECT catname FROM categories ORDER BY catid); But I want to give each catname in the DB a unique name in a form select and don't know how to go about it. Tutorials or tips anyone? Regards, Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Rename an upload
I'm trying to rename an uploaded file with the value of a select I have in the uploaded form. Can someone point me in the right direction. The PHP.net rename manual isn't helping a lot? My code: //Form for upload form enctype=multipart/form-data action=eshop_upload.php method=post input type=hidden name=MAX_FILE_SIZE value=25000 input type=file name=userfile size=18 class=kapea brbr span class=adminisoleipaSelect the category to add the picture to:brbr select name='category' option value=Please select.../option ? while ($array = mysql_fetch_array($mysql)) { echo option value='{$array[catid]}'{$array[catname]}/option; } ? /select /td /tr trtdbr input type=submit name=Submit value=Submit class=nappi /form //eshop_upload.php ?php // Upload the picture to the selected directory and rename the file as the category number. if (is_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'])) { copy($HTTP_POST_FILES['userfile']['tmp_name'],http://www.violasystems.c om/images/); rename(($HTTP_POST_FILES['userfile']['tmp_name']), $category); } else { echo Possible file upload attack. Filename: .$HTTP_POST_FILES['userfile']['tmp_name'] } ? TIA. Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Rename an upload
On Wednesday 11 December 2002 17:30, Steve Jackson wrote: I'm trying to rename an uploaded file with the value of a select I have in the uploaded form. Can someone point me in the right direction. The PHP.net rename manual isn't helping a lot? My code: What is the problem? I can't figure out how to upload the file with the name I need. The rename function in the manual says Its: rename(string1,string2) Ie. ?php rename(/tmp/tmp_file.txt, /home/user/login/docs/my_file.txt); ? I want to rename the file copied to the server to the name of the select value I sent in my previous post (held in the variable $category) so basically How do I do that? Where do I do it in the upload script also? You mention I should be able to do it in a single step, that would be ideal but again how do I do it? Do I need to put the uploaded file in a variable so I can rename the copied image? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Populating form value fields.
I am having problems populating form fields. Here is my code: //$ItemCode is passed to the page with this code $mysql = mysql_query(SELECT * FROM products WHERE ItemCode='$ItemCode'); $result = mysql_query($mysql); Then the form: form action=eshop_editprodprocess.php method=post input type=text name=ItemName value=?=$ItemName;? size=18 class=kapea input type=text name=ItemCode value=?=$ItemCode;? size=18 class=kapea input type=text name=ItemDesc value=?=$ItemDesc;? size=18 class=kapea /form I have tried numerous ways to use $result to get these values to appear but am stuck. How therefore do I select everything from the database sorted by ItemCode and then displayed in a form as shown above. Regards, Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Populating form value fields.
Cheers Jason. Sorted. Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -Original Message- From: Jason Wong [mailto:[EMAIL PROTECTED]] Sent: 11. joulukuuta 2002 17:17 To: [EMAIL PROTECTED] Subject: Re: [PHP] Populating form value fields. On Wednesday 11 December 2002 23:18, Steve Jackson wrote: I am having problems populating form fields. Here is my code: //$ItemCode is passed to the page with this code $mysql = mysql_query(SELECT * FROM products WHERE ItemCode='$ItemCode'); $result = mysql_query($mysql); Then the form: form action=eshop_editprodprocess.php method=post input type=text name=ItemName value=?=$ItemName;? size=18 class=kapea input type=text name=ItemCode value=?=$ItemCode;? size=18 class=kapea input type=text name=ItemDesc value=?=$ItemDesc;? size=18 class=kapea /form I have tried numerous ways to use $result to get these values to appear but am stuck. How therefore do I select everything from the database sorted by ItemCode and then displayed in a form as shown above. You need to use one of the mysql_fetch_*() functions. See examples in manual. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* Prediction is very difficult, especially of the future. - Niels Bohr */ -- 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] Update query
How do you update MySQL in the following way? I have designed a form which has all the fields in the database available to edit based on a user query. The query is a field called $ItemCode. If the user wants to change that $ItemCode field how do I update it? In other words how do I use PHP to update the database row called $ItemCode with a new $ItemCode where $ItemCode is $ItemCode? Here is what I've tried and failed at! $oldItemCode = $ItemCode; $query = update products set ItemCode='$newItemCode', ItemName ='$ItemName', catid = '$catid', price = '$price', description = '$description' shortdesc = '$shortdesc' where ItemCode='$oldItemCode'; Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Update query
It doesn't work in that it doesn't update the database. I have a form which when loaded takes a variable ItemCode from the previous page (which gets the Itemcode from the DB) and puts it into a hidden field which I call oldItemCode, then when I try to update the $ItemCode row in the database with the edited changes using the oldItemCode as an identifier it won't update - It goes to my error message shown below. So what I'm asking is there anything I'm doing wrong. I noted your points about the comma and have changed the code. ? $query = update products set ItemCode='$ItemCode', ItemName ='$ItemName', catid ='$catid', price = '$price', description = '$description', shortdesc = '$shortdesc', where ItemCode='$oldItemCode'; $result = mysql_query($query); if (!$result) { echo table width='100%' border='0' cellspacing='0' cellpadding='0' align='center' bgcolor='#629D39'; echo trtdimg src='images/admin_orders_administrate.gif'/td/tr; echo trtdnbsp;/td/tr; echo trtdspan class='adminisoleipa'Could not change details: please a href='mailto:[EMAIL PROTECTED]'click here/a to email the administratorbrbr/span; echo /td; echo /tr; echo /table; } else { echo table width='100%' border='0' cellspacing='0' cellpadding='0' align='center' bgcolor='#629D39'; echo trtdimg src='images/admin_orders_administrate.gif'/td/tr; echo trtdnbsp;/td/tr; echo trtdspan class='adminisoleipa'Your product has been successfully editedbrbr/span; echo /td; echo /tr; echo tr; echo td; echo a href='eshop_uploadproductpicture.php'img src='images/admin_orders_upload.gif' border='0'/a; echo /td/tr; echo /table; } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Email problems.
I have generated a page on our server using PHP (from within a CMS system) which I renamed the output .html to use in an html email. My problem is when I cut and paste the HTML into the email (Outlook) it either: displays the code, displays the html email and then when it's sent, sends it as an attachment or sends it as a bunch of html links and badly formatted text. I assumed (badly) that Outlook would simply send HTML emails if you formatted the program to send html emails but this seems almost impossible. Anyone have any suggestions? This is the page I want to send: http://www.violasystems.com/e-news/template.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Preperation for News CMS?
Hi all, I am about to write a CMS for a news section which I'll also adjust so that I can use for pages across the entire site. People should be allowed to edit/add/delete/archive/preview and upload pictures to a maximum of say five. My 1st question is does anyone know of some Open Source software which might save me some time? Also what would you suggest the best way is to add pictures to an article? I can upload 1 picture giving it the same ID as the news article but what if there are 2/3/4 etc? how would you go about this? Then there is the problem of where to put it in the article, I was thinking about uploading the picture and then putting the html in the form text box with the rest of the article for the user to move around as needed but does anyone have any better ideas? (it might scare some users so does anyone have something simpler?) Also what's the best way to set-up a preview function? I was thinking that I should add checkbox which makes the article live so that the user could preview the page first from a link but is there any better way to do it? Thanks for your help. Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Cheap Hosting
Dotserv are high response and fairly cheap depending on what you need. Or there's phpwebhosting.com http://www.dotserv.com http://www.phpwebhosting.com -Original Message- From: Edward Peloke [mailto:[EMAIL PROTECTED]] Sent: 27 December 2002 18:29 To: PHP List Subject: RE: [PHP] Cheap Hosting I use www.ht-tech.net Very reliable and I currently pay $12.95 a month. Eddie -Original Message- From: 1LT John W. Holmes [mailto:[EMAIL PROTECTED]] Sent: Friday, December 27, 2002 10:43 AM To: Stephen; Rick Emery Cc: PHP List Subject: Re: [PHP] Cheap Hosting That's only 8 days of work for a whole year of hosting... come on! :) John - Original Message - From: Stephen [EMAIL PROTECTED] To: Rick Emery [EMAIL PROTECTED] Cc: PHP List [EMAIL PROTECTED] Sent: Friday, December 27, 2002 10:29 AM Subject: Re: [PHP] Cheap Hosting That is way to expensive for me. I'm only 13 with a $25 a day paying job... - Original Message - From: Rick Emery [EMAIL PROTECTED] To: Stephen [EMAIL PROTECTED]; PHP List [EMAIL PROTECTED] Sent: Thursday, December 26, 2002 8:38 PM Subject: Re: [PHP] Cheap Hosting : www.nomonthlyfees.com : $200 first year, $70 per year thereafter. : : I put all my clients with this service. : : rick : People will forget what you said. People will forget what you did. : But people will never forget how you made them feel. : - Original Message - : From: Stephen : To: PHP List : Sent: Thursday, December 26, 2002 6:55 PM : Subject: [PHP] Cheap Hosting : : : Hello, : : I need a nice, reliable host for my new website. It needs to be fast, reliable, needs a : good uptime, and some features. PHP and MySQL are the two I really need. Does anyone : recomend one that's really cheap? So far I've found on, $5 a month, but it's slower then : what'd I like. If nothing else pops up, I'll go with it. I'd also like domain parking : and/or domain registration (don't really need the registration though). Thanks in advance! : : Thanks, : Stephen Craton : http://www.melchior.us : : What is a dreamer that cannot persevere? -- http://www.melchior.us : : : : -- : 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 -- 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] Problem with simple update
I am trying to set the order of a set of categories. Previously the catid field sorted the order of the categories. However I changed this to Order By catorder and then set about writing a simple update query to allow people to set the order. I can't see anything wrong with this: Basically I pull the details from the categories DB into an array and then display in a table. This works fine ? while ($array = mysql_fetch_array($mysql)) { echo trtd width='150'span class='adminisoleipa'; echo input type='hidden' name='categoryid' value='{$array[catid]}'; echo {$array[catname]}; echo /tdtdinput type='text' size='2' name='catorder' value='{$array[catorder]}'; echo /span/td/tr; } ? Then using this to update it seems to work till you check the update. It sets the first two fields to one for some reason. $query = update categories set catorder = '$catorder' where catid='$categoryid'; Any suggestions? Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] How do you update multiple rows at the same time?
I am having trouble with this. I need to update 1column in a variable number of rows depending on how many categories are in my database at a given time. Can anyone provide any pointers or example code Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com/ http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159
[PHP] Update row problems
Hi all, I've been playing with this for a few hours now (over the course of a couple of days) and it's getting frustrating! All I want to do is to be able to make one row in the database set the order that my categories appear on my website. Now I can do this fine simply by using ORDER_BY but I want to have my users be able to update the order through an admin page like so: - Catid | catname | catdesc | catorder | 1 name desc 1 2 name desc 2 3name desc 3 4name desc 4 __ Basically I have a form which takes data from the table above and displays catname (just echoed) and catorder in a text form field. When I submit the form I want to update catorder with whatever number the user puts in the field. Currently my code updates only one of the category order numbers. So my form code: form action=eshop_processcatorder.php method=post /td/tr ? while ($array = mysql_fetch_array($mysql)) { echo trtd width='150'span class='adminisoleipa'; echo {$array[catname]}; echo /tdtdinput type='text' size='2' name='catorder[{$array[catid]}]' value='{$array[catorder]}'; echo /span/td/tr; } ? trtdbr input type=submit name=Submit value=Submit class=nappi /form That does everything I need it to do. However what am I doing wrong when I try to process it using this code? foreach($_POST[catorder] as $catid = $catorder) { $query = update categories set catorder=$catorder where catid=$catid; } $result = mysql_query($query) or die(Query failure: .mysql_error()); if (!$result) { echo table width='100%' border='0' cellspacing='0' cellpadding='0' align='center' bgcolor='#629D39'; echo trtdimg src='images/admin_orders_administrate.gif'/td/tr; echo trtdnbsp;/td/tr; echo trtdspan class='adminisoleipa'Could not change details: please a href='mailto:[EMAIL PROTECTED]'click here/a to email the administratorbrbr/span; echo /td; echo /tr; echo /table; } else { echo table width='100%' border='0' cellspacing='0' cellpadding='0' align='center' bgcolor='#629D39'; echo trtdimg src='images/admin_orders_administrate.gif'/td/tr; echo trtdnbsp;/td/tr; echo trtdspan class='adminisoleipa'The category page has had the order in which categories appear changed.brbr/span; echo /td; echo /tr; echo /table; } Any help appraciated. Kind regards, Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Update row problems
I'm processing on a different page so what would I use instead of $_POST? print_r($_POST) Didn't display anything or diagnose anything. Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -Original Message- From: Tim Ward [mailto:[EMAIL PROTECTED]] Sent: 27. tammikuuta 2003 14:57 To: Steve Jackson Subject: Re: [PHP] Update row problems sounds like $_POST[catorder] isn't an array - if you're posting to the same page you need to wrap the processing in something to test if the form has been posted (e.g. is_array($_POST[catorder])), or maybe you're using an older versionof PHP where $_POST isn't available -try using print_r($_POST) for diagnostics. Tim Ward http://www.chessish.com mailto:[EMAIL PROTECTED] - Original Message - From: Steve Jackson [EMAIL PROTECTED] To: 'Tim Ward' [EMAIL PROTECTED] Sent: Monday, January 27, 2003 12:52 PM Subject: RE: [PHP] Update row problems Ok, I put the query in the loop and now I get this error? foreach($_POST[catorder] as $catid = $catorder) { $query = update categories set catorder=$catorder where catid=$catid; $result = mysql_query($query) or die(Query failure: .mysql_error()); } Warning: Invalid argument supplied for foreach() in /home/stephenj/public_html/viola/eadmin/eshop_processcatorder.php on line 27 Is it a $_POST problem? Using PHP 4.06 Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -Original Message- From: Tim Ward [mailto:[EMAIL PROTECTED]] Sent: 27. tammikuuta 2003 14:11 To: PHP General; Steve Jackson Subject: Re: [PHP] Update row problems your query needs to be inside the foreach loop so that it runs for every item, at the moment it just runs after you've scanned through all the items so just does the last one. Tim Ward http://www.chessish.com mailto:[EMAIL PROTECTED] - Original Message - From: Steve Jackson [EMAIL PROTECTED] To: PHP General [EMAIL PROTECTED] Sent: Monday, January 27, 2003 11:46 AM Subject: [PHP] Update row problems Hi all, I've been playing with this for a few hours now (over the course of a couple of days) and it's getting frustrating! All I want to do is to be able to make one row in the database set the order that my categories appear on my website. Now I can do this fine simply by using ORDER_BY but I want to have my users be able to update the order through an admin page like so: - Catid | catname | catdesc | catorder | 1name desc 1 2name desc 2 3name desc 3 4name desc 4 __ Basically I have a form which takes data from the table above and displays catname (just echoed) and catorder in a text form field. When I submit the form I want to update catorder with whatever number the user puts in the field. Currently my code updates only one of the category order numbers. So my form code: form action=eshop_processcatorder.php method=post /td/tr ? while ($array = mysql_fetch_array($mysql)) { echo trtd width='150'span class='adminisoleipa'; echo {$array[catname]}; echo /tdtdinput type='text' size='2' name='catorder[{$array[catid]}]' value='{$array[catorder]}'; echo /span/td/tr; } ? trtdbr input type=submit name=Submit value=Submit class=nappi /form That does everything I need it to do. However what am I doing wrong when I try to process it using this code? foreach($_POST[catorder] as $catid = $catorder) { $query = update categories set catorder=$catorder where catid=$catid; } $result = mysql_query($query) or die(Query failure: .mysql_error()); if (!$result) { echo table width='100%' border='0' cellspacing='0' cellpadding='0' align='center' bgcolor='#629D39'; echo trtdimg src='images/admin_orders_administrate.gif'/td/tr; echo trtdnbsp;/td/tr; echo trtdspan class='adminisoleipa'Could not change details: please a href='mailto:[EMAIL PROTECTED]'click here/a to email the administratorbrbr/span; echo /td; echo /tr; echo /table; } else { echo table width='100%' border='0' cellspacing='0' cellpadding='0' align='center' bgcolor='#629D39'; echo trtdimg src='images/admin_orders_administrate.gif'/td/tr; echo trtdnbsp;/td/tr; echo trtdspan class='adminisoleipa'The category page has had the order in which categories appear changed.brbr/span; echo /td; echo /tr; echo /table; } Any help appraciated
RE: [PHP] Update row problems
Thanks. That was the problem. Im using 4.0.6 so it's a bit out of date. Cheers, Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -Original Message- From: Tim Ward [mailto:[EMAIL PROTECTED]] Sent: 27. tammikuuta 2003 15:32 To: PHP General; Steve Jackson Subject: Re: [PHP] Update row problems what version of PHP? try $HTTP_POST_VARS instead. Tim Ward http://www.chessish.com mailto:[EMAIL PROTECTED] - Original Message - From: Steve Jackson [EMAIL PROTECTED] To: PHP General [EMAIL PROTECTED] Sent: Monday, January 27, 2003 1:14 PM Subject: RE: [PHP] Update row problems I'm processing on a different page so what would I use instead of $_POST? print_r($_POST) Didn't display anything or diagnose anything. Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -Original Message- From: Tim Ward [mailto:[EMAIL PROTECTED]] Sent: 27. tammikuuta 2003 14:57 To: Steve Jackson Subject: Re: [PHP] Update row problems sounds like $_POST[catorder] isn't an array - if you're posting to the same page you need to wrap the processing in something to test if the form has been posted (e.g. is_array($_POST[catorder])), or maybe you're using an older versionof PHP where $_POST isn't available -try using print_r($_POST) for diagnostics. Tim Ward http://www.chessish.com mailto:[EMAIL PROTECTED] - Original Message - From: Steve Jackson [EMAIL PROTECTED] To: 'Tim Ward' [EMAIL PROTECTED] Sent: Monday, January 27, 2003 12:52 PM Subject: RE: [PHP] Update row problems Ok, I put the query in the loop and now I get this error? foreach($_POST[catorder] as $catid = $catorder) { $query = update categories set catorder=$catorder where catid=$catid; $result = mysql_query($query) or die(Query failure: .mysql_error()); } Warning: Invalid argument supplied for foreach() in /home/stephenj/public_html/viola/eadmin/eshop_processcatorder.php on line 27 Is it a $_POST problem? Using PHP 4.06 Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -Original Message- From: Tim Ward [mailto:[EMAIL PROTECTED]] Sent: 27. tammikuuta 2003 14:11 To: PHP General; Steve Jackson Subject: Re: [PHP] Update row problems your query needs to be inside the foreach loop so that it runs for every item, at the moment it just runs after you've scanned through all the items so just does the last one. Tim Ward http://www.chessish.com mailto:[EMAIL PROTECTED] - Original Message - From: Steve Jackson [EMAIL PROTECTED] To: PHP General [EMAIL PROTECTED] Sent: Monday, January 27, 2003 11:46 AM Subject: [PHP] Update row problems Hi all, I've been playing with this for a few hours now (over the course of a couple of days) and it's getting frustrating! All I want to do is to be able to make one row in the database set the order that my categories appear on my website. Now I can do this fine simply by using ORDER_BY but I want to have my users be able to update the order through an admin page like so: - Catid | catname | catdesc | catorder | 1name desc 1 2name desc 2 3name desc 3 4name desc 4 __ Basically I have a form which takes data from the table above and displays catname (just echoed) and catorder in a text form field. When I submit the form I want to update catorder with whatever number the user puts in the field. Currently my code updates only one of the category order numbers. So my form code: form action=eshop_processcatorder.php method=post /td/tr ? while ($array = mysql_fetch_array($mysql)) { echo trtd width='150'span class='adminisoleipa'; echo {$array[catname]}; echo /tdtdinput type='text' size='2' name='catorder[{$array[catid]}]' value='{$array[catorder]}'; echo /span/td/tr; } ? trtdbr input type=submit name=Submit value=Submit class=nappi /form That does everything I need it to do. However what am I doing wrong when I try to process it using this code? foreach($_POST[catorder] as $catid = $catorder) { $query = update categories set catorder=$catorder where
[PHP] Protecting a file via PHP.
I just read this: http://zend.com/zend/trick/tricks-august-2001.php To protect a file via PHP. What does this part mean in the serving the files part: define('FILEDIR', '/mnt/dos/'); Do I define the directory where the file is served from? Or do I define a directory to which the file is served to (a temp) or what? No matter what I've tried I get no error message and the browser (IE6) just hangs so it appears that PHP is trying to serve the file but failing for some reason. What is that directory I am supposed to define? What am I doing wrong? Steve Jackson Web Development and Marketing Manager Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
FW: [PHP] Protecting a file via PHP.
Steve Jackson Web Development and Marketing Manager Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -Original Message- From: Steve Jackson [mailto:[EMAIL PROTECTED] Sent: 16. syyskuuta 2003 12:15 To: '[EMAIL PROTECTED]' Subject: RE: [PHP] Protecting a file via PHP. What does this part mean in the serving the files part: define('FILEDIR', '/mnt/dos/'); Do I define the directory where the file is served from? Or do I define a directory to which the file is served to (a temp) or what? It should be from and not to. OK. The thing is I wonder why in the zend article the directory here is different. There are two scripts on the page: ? define('FILEDIR', '/downloads/'); //display available files $d = dir(FILEDIR); while($f = $d-read()) { //skip 'hidden' files if($f{0} != '.') { print(a href=\get.php?file=$f\$f/abr\n); } } $d-close(); ? This first one looks in the downloads directory (outside the root) and grabs the filenames displaying them as a link. This works fine on my server. This second one starts with: define('FILEDIR', '/mnt/dos/'); And I can't see an explanation why. Surely if it was meant to be the same the writer would have had the same route defined? Could be a different problem... Could be. But I'm trying to eliminate this one first. I've tried the from directory and get the same error as I menioned previously. If I can't get this to work are there any other ways I can protect a file from being displayed. I need to be able to: 1) Display links to authenticated users (php session) 2) Let authenticated users download the files. I don't want to use an htaccess file unless there is a way to authenticate the user in htaccess by reading the session variable. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Getting part of a string...Was protecting a file via php
OK, After much headbanging I figured out the first part of my problem. I want to retrieve a file from behind the webroot and to do this I need to send headers. This should be a simple case of finding out what the file is called (its extension) and sending the headers via a switch depending on what the extension is. My previous problem was that I had a URL string attached to the front of the filename which I got rid of in the variable $pfile My question is how do I find out what the extension of my file is. I have tried explode but it doesn't have the desired effect. I feel stupid asking as I'm sure this is easy but I can't for the life of me figure it out: $pfile = str_replace('get.php?file=','','$file'); $p = explode('.', $pfile); // How do I say look at the extension and put it into the switch? $extension = $p; // end of the bit I'm stuck on. switch ($extension) { // define headers depending on $extension variable. case doc : header(Content-type: application/msword\n); break; case htm : header(Content-type: text/html\n); break; case html : header(Content-type: text/html\n); break; case jpg : header(Content-type: image/jpeg\n); break; case pdf : header(Content-type: application/pdf\n); break; case txt : header(Content-type: text/plain\n); break; case xls : header(Content-type: application/vnd.ms-excel\n); break; default : // force download dialog if no extension defined. header(Content-type: application/octet-stream\n); header(Content-disposition: attachment; filename=\$file\\n); break; } Steve Jackson Web Development and Marketing Manager Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Getting part of a string...Was protecting a file via php
Thanks to all so far. However I am still having problems I have directory outside the root with PDF's in it. The links to the PDF files are called successfully by this function in a page I call getlinks.php function do_non_root_links() { define('FILEDIR', '/home/.sites/144/site281/downloads/'); //display available files $d = dir(FILEDIR); while($f = $d-read()) { //skip 'hidden' files if($f{0} != '.') { echo trtd; echo a href=\get.php?file=$f\ class=\greenlinks\ target=\_blank\$f/a; echo /td/tr; } } $d-close(); } The URL displayed is then to be processed by get.php. My problem *I think* is losing get.php?file= from the URL which I managed to do by doing $pfile = str_replace('get.php?file=','','$file'); This however then becomes confusing because $pfile I assumed would then be simply the filename without the URL. I figured that if I exploded the name and pulled the extension from the file passed that into a switch to send the appropriate header my problem would be solved. However it isn't. This is the code and de-bugging I've done. ? define('FILEDIR', '/home/.sites/144/site281/downloads/'); $path = FILEDIR . $file; //check that this file exists and that it doesn't include //any special characters if(!is_file($path) OR !eregi('^[A-Z_0-9][A-Z_0-9.]*$', $file)) { header(Location: error.php); exit(); } /* ** //check that the user has permission to download file ** if(user does not have permission) ** { ** //redirect to error page ** header(Location: error.php); ** exit(); ** } */ $pfile = str_replace('get.php?file=','','$file'); $p = explode('.', $file); $extension = $p[sizeof($p)-1]; // debug - remove the headers and test output vars. echo Test and $extension; echo brTest and $file; echo brTest and $p; echo brTest and $pfile; /*switch ($extension) { // define headers depending on $extension variable. case doc : header(Content-type: application/msword\n); break; case pdf : header(Content-type: application/pdf\n); break; default : // force download dialog if no extension defined. header(Content-type: application/octet-stream\n); header(Content-disposition: attachment; filename=\$file\\n); break; } header(Content-transfer-encoding: binary\n); header(Content-length: . filesize($path) . \n); //send file contents $fp=fopen($path, r); fpassthru($fp); */ ? Echoing the vars produces this. The exploded file ($extension) is what I need to pass to the switch but if I send the headers as is again I get a blank and corrupted explorer window. Test and pdf Test and EventNotification_01.pdf Test and Array Test and $file Any ideas how to proceed? Cheers, Steve. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Getting part of a string...Was protecting a file via php
I can now download the file as application/octet-stream but it won't allow me to open the file inline as a PDF. The only way I managed to be able to download the file at all was by stripping the URL from the front of the filename (I think). What am I doing wrong?? $pfile = str_replace('get.php?file=','','$file'); $p = explode('.', $pfile); $extension = $p[sizeof($p)-1]; $pfile when echoed is $file $file when echoed is the correct name of the file which is even more confusing. I figured that $file would include the URL which might be why it hanged explorer. Steve Jackson Web Development and Marketing Manager Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -Original Message- From: Steve Jackson [mailto:[EMAIL PROTECTED] Sent: 17. syyskuuta 2003 13:53 To: 'PHP General'; 'Jon Haworth' Subject: RE: [PHP] Getting part of a string...Was protecting a file via php Thanks to all so far. However I am still having problems I have directory outside the root with PDF's in it. The links to the PDF files are called successfully by this function in a page I call getlinks.php function do_non_root_links() { define('FILEDIR', '/home/.sites/144/site281/downloads/'); //display available files $d = dir(FILEDIR); while($f = $d-read()) { //skip 'hidden' files if($f{0} != '.') { echo trtd; echo a href=\get.php?file=$f\ class=\greenlinks\ target=\_blank\$f/a; echo /td/tr; } } $d-close(); } The URL displayed is then to be processed by get.php. My problem *I think* is losing get.php?file= from the URL which I managed to do by doing $pfile = str_replace('get.php?file=','','$file'); This however then becomes confusing because $pfile I assumed would then be simply the filename without the URL. I figured that if I exploded the name and pulled the extension from the file passed that into a switch to send the appropriate header my problem would be solved. However it isn't. This is the code and de-bugging I've done. ? define('FILEDIR', '/home/.sites/144/site281/downloads/'); $path = FILEDIR . $file; //check that this file exists and that it doesn't include //any special characters if(!is_file($path) OR !eregi('^[A-Z_0-9][A-Z_0-9.]*$', $file)) { header(Location: error.php); exit(); } /* ** //check that the user has permission to download file ** if(user does not have permission) ** { ** //redirect to error page ** header(Location: error.php); ** exit(); ** } */ $pfile = str_replace('get.php?file=','','$file'); $p = explode('.', $file); $extension = $p[sizeof($p)-1]; // debug - remove the headers and test output vars. echo Test and $extension; echo brTest and $file; echo brTest and $p; echo brTest and $pfile; /*switch ($extension) { // define headers depending on $extension variable. case doc : header(Content-type: application/msword\n); break; case pdf : header(Content-type: application/pdf\n); break; default : // force download dialog if no extension defined. header(Content-type: application/octet-stream\n); header(Content-disposition: attachment; filename=\$file\\n); break; } header(Content-transfer-encoding: binary\n); header(Content-length: . filesize($path) . \n); //send file contents $fp=fopen($path, r); fpassthru($fp); */ ? Echoing the vars produces this. The exploded file ($extension) is what I need to pass to the switch but if I send the headers as is again I get a blank and corrupted explorer window. Test and pdf Test and EventNotification_01.pdf Test and Array Test and $file Any ideas how to proceed? Cheers, Steve. -- 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] This is my fourth day of hitting this brick wall! Anyone...Purleeeeese help!
I know a few have already done this on the list but I have read articles on Zend tried other functions done everything I can, de-bugged till I'm blue in the face and still haven't been able to solve this. I need to protect files by leaving them outside the web root. I call them up ok. (the link is get.php?file=EventNotifcation_01.pdf) I can download the file fine by right clicking the link in the browser and saving it to disk. My problem is I can't view it inline. IE in the browser. It's a PDF file so I should be able to. This is the code that processes: ? // path to file outside of root. define('FILEDIR', '/home/.sites/144/site281/downloads/'); $path = FILEDIR . $file; //check that this file exists and that it doesn't include //any special characters if(!is_file($path) OR !eregi('^[A-Z_0-9][A-Z_0-9.]*$', $file)) { header(Location: error.php); exit(); } /* ** //check that the user has permission to download file ** if(user does not have permission) ** { ** //redirect to error page ** header(Location: error.php); ** exit(); ** } */ // get the extension of the file $p = explode('.', $file); $extension = $p[sizeof($p)-1]; switch ($extension) { // define headers depending on $extension variable. case pdf : header(Content-type: application/pdf); header(Content-disposition: inline; filename=\.basename($file)); break; case txt : header(Content-type: text/plain); header(Content-disposition: inline; filename=\.basename($file)); break; default : // force download dialog if no extension defined. header(Content-type: application/octet-stream); header(Content-disposition: attachment; filename=\$file\); break; } header(Content-transfer-encoding: binary); header(Content-length: . filesize($path)); header(Cache-control: must-revalidate); //send file contents $fp=fopen($path, r); fpassthru($fp); // debug - remove the headers and test output vars. /*echo Extension is $extension; echo brFile is $file; echo brp is $p; echo brpath is $path; echo brFP is $fp;*/ ? Echoing the vars results in: Extension is pdf File is EventNotification_01.pdf P is Array Path is /home/.sites/144/site281/downloads/EventNotification_01.pdf FP is Resource is #1 Has anyone got any clue what the problem is? Steve Jackson Web Development and Marketing Manager Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] This is my fourth day of hitting this brick wall! Anyone...Purleeeeese help!
Have you tried the obvious, such as using browsers other than IE? Or a different version of IE? So far I've tried IE 6.0.2, IE 5.0, Netscape 7 and they don't work. Fact is that there are versions of IE that have broken mime handling. This I didn't know, so I just tried it on Konqueror running on Linux and it works. However where do I go from here? One thing that Konqueror brought up is that get.php is the filename that it gives the file when trying to save it. Could that be the problem? Get.php is the name of the script that passes the file but not the name of the file itself. Finally a step in the right direction but how do I go about solving this? Kind regards Steve. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] This is my fourth day of hitting this brick wall! Anyone...Purleeeeese help!
The simple things are the stupidest. One thing I didn't do well enough. Testing on different machines. I ran numerous tests from my own PC and numerous tests from a development server using different software. Only when Jason mentioned Mimetypes did I think about doing more tests on adifferent machine. My problem wasn't with the PHP, the server or anything else but with my fecking version of Adobe Acrobat. After trying to open a different PDF file I realised my problem. So after a re-boot of my PC everything works fine. Thanks for the patience and hope this lesson in my stupidity can help someone else! Steve Jackson Web Development and Marketing Manager Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -Original Message- From: Steve Jackson [mailto:[EMAIL PROTECTED] Sent: 18. syyskuuta 2003 12:19 To: [EMAIL PROTECTED] Subject: RE: [PHP] This is my fourth day of hitting this brick wall! Anyone...Purlese help! Have you tried the obvious, such as using browsers other than IE? Or a different version of IE? So far I've tried IE 6.0.2, IE 5.0, Netscape 7 and they don't work. Fact is that there are versions of IE that have broken mime handling. This I didn't know, so I just tried it on Konqueror running on Linux and it works. However where do I go from here? One thing that Konqueror brought up is that get.php is the filename that it gives the file when trying to save it. Could that be the problem? Get.php is the name of the script that passes the file but not the name of the file itself. Finally a step in the right direction but how do I go about solving this? Kind regards Steve. -- 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] shopping cart and login system
Actually you can do it the way you suggest. I'm in the process of doing it also. I have yet to test the system but it should work provided that you follow the PayPal system, I already have my cart working so I think I just need another form like this one with the PHP variables as carried from my previous cart session. Should be easy by the looks of it. (watch for wrap): http://www.paypal.com/cgi-bin/webscr?cmd=_help-exteloc=762unique_id=02 413source_page=_homeflow= Steve Jackson Web Development and Marketing Manager Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -Original Message- From: electroteque [mailto:[EMAIL PROTECTED] Sent: 15. kesäkuuta 2003 6:33 To: olinux; Jeff Harris Cc: Php-General Subject: RE: [PHP] shopping cart and login system yes i know about that but then the whole basket/cart system is out of your hands i prefer to send the total with the products and quantities or can you not do that ? if not i guess adding the individual items to their basket is the only way the IPN system is confusing aswell :| -Original Message- From: Jeff Harris [mailto:[EMAIL PROTECTED] Sent: Sunday, June 15, 2003 1:31 PM To: olinux Cc: electroteque; Php-General Subject: Re: [PHP] shopping cart and login system On Jun 14, 2003, olinux claimed that: |hi | |--- electroteque [EMAIL PROTECTED] wrote: | hi there , i am about to build a shopping cart which | will interact with a | paypal payment system , the cart will use sessions | to store the items and | basket information before checking out and posting | to the paypal form , what | i'd like to know is would the cart require a login | system to track users and | to prevent ppl from making dodgy orders , | |if pure simplicity is a goal, i dont think you need a |login for customers. who cares if they add items and |then dont purchase. obviously they would not be able |to log in again to see the previous orders or current |order status but you could always implement later. Actually, to be more simple, for paypal paying customers, I would use paypal's buy it now buttons. Let them deal with the shopping carts and sessions. http://www.paypal.com/cgi-bin/webscr?cmd=p/xcl/rec/singleitem- intro-outside -- Registered Linux user #304026. lynx -source http://jharris.rallycentral.us/jharris.asc | gpg --import Key fingerprint = 52FC 20BD 025A 8C13 5FC6 68C6 9CF9 46C2 B089 0FED Responses to this message should conform to RFC 1855. -- 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
[PHP] How to insert a variable into a PHP template.
Hi, I want to write a PHP template with a variable number of the last recordset in a MySQL DB being the number referenced in the file. This is so my file can be saved as a PHP page looking at the right content in a database for a content management system. I am stuck on the way to do it. The code below is the part I want to change: So I need to do two things: 1) Select the last record in a database table. 2) get PHP to write all the code below on the fly. db_connect(); // This is the query number which needs to be changed and written every time as the last record in the DB $query = select * from crm_content where PageID='1'; $result = mysql_query($query) or die(Error: Query failure withBR$queryBR.mysql_error()); while ($array = mysql_fetch_array($result)) { $PageTitle = {$array[Title]}; $BodyText = {$array[BodyText]}; $Picture1 = {$array[PictureOne]}; $Picture2 = {$array[PictureTwo]}; $CatID = {$array[CatID]}; } // then write the function to call the page here // Any ideas thoughts or help much appreciated. Steve Jackson Web Development and Marketing Manager Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] How to insert a variable into a PHP template.
mysql_insert_id(); How would I call that in my query? Because I tried that and I get resource ID=2 Also putting it into a string and writing it to a file, sounds good to me, that's what I was thinking but how do you do it? Can it just be written as: $string =all my code including ;''=}{[] etc; And then calling the string with fwrite? Or am I going to run into serious problems? Steve Jackson Web Development and Marketing Manager Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -Original Message- From: Andrew McCombe [mailto:[EMAIL PROTECTED] Sent: 7. heinäkuuta 2003 16:05 To: [EMAIL PROTECTED]; Steve Jackson Subject: Re: [PHP] How to insert a variable into a PHP template. - Original Message - From: Steve Jackson [EMAIL PROTECTED] To: PHP General [EMAIL PROTECTED] Sent: Monday, July 07, 2003 1:34 PM Subject: [PHP] How to insert a variable into a PHP template. Hi, I want to write a PHP template with a variable number of the last recordset in a MySQL DB being the number referenced in the file. This is so my file can be saved as a PHP page looking at the right content in a database for a content management system. I am stuck on the way to do it. The code below is the part I want to change: So I need to do two things: 1) Select the last record in a database table. mysql_insert_id(); 2) get PHP to write all the code below on the fly. db_connect(); // This is the query number which needs to be changed and written every time as the last record in the DB $query = select * from crm_content where PageID='1'; $result = mysql_query($query) or die(Error: Query failure withBR$queryBR.mysql_error()); while ($array = mysql_fetch_array($result)) { $PageTitle = {$array[Title]}; $BodyText = {$array[BodyText]}; $Picture1 = {$array[PictureOne]}; $Picture2 = {$array[PictureTwo]}; $CatID = {$array[CatID]}; } // then write the function to call the page here // Any ideas thoughts or help much appreciated. Can't help with this bit. Apart from putting it into a string and then writing it to a file. Regards Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Fputs problem
I don't know if this is possible but... I want to generate a PHP file on the fly. I am trying to use fputs but I have a problem in that it doesn't print a variable name in the string. Here is my code: Formid is being passed into the string great which is what I want but how do I get the string to write the variable names in this code? Are there any rules I need to follow to get the whole file to print out? If so what? And what should I be looking for in the manual? Fputs isn't helping much. function generate_page($formid, $pagename) { // Give the function the string to be generated including formid passed from // previous form $string = ?php $SECTION_NAME = \goldfish_cms.php\;\n //\n // Written by Steve Jackson. Copyright and all rights reserved Webpage 2003.//\n /functions here all included in output_fns.php\n //\n // include the files from output fns to get functions which design the page\n include ('output_fns.php');\n db_connect();\n $query = \select * from content where PageID='$formid'\;\n $result = mysql_query($query) or die(\Error: Query failure withBR$queryBR\.mysql_error());\n while ($array = mysql_fetch_array($result))\n {\n $HeadTitle = \{$array[HeadTitle]}\; \n $PageTitle = \{$array[Title]}\; \n $BodyText = \{$array[BodyText]}\;\n $Picture1 = \{$array[PictureOne]}\;\n $Picture2 = \{$array[PictureTwo]}\;\n $CatID = \{$array[CatID]}\;\n }\n // carry the variable head title in the page and do the page header\n do_html_header($HeadTitle);\n // carry variables into do_html_index() function in output_fns.\n // Page title = The headline of the page\n // Body text = The text body, can include html commands.\n // Picture 1 = picture or graphic that appears above the title if required.\n // Picture 2 = Picture that appears right hand side on the basic output_fns\n // CatID = Category which is used for determining which links appear on each page\n // Section name = Allows you to specify extra functions to output_fns.php to be unique to the page (requires hard coding)\n do_html_index($PageTitle, $BodyText, $Picture1, $Picture2, $CatID, $SECTION_NAME);\n // put the page footer in position\n do_html_footer();\n ?\n; $filename = 'test.txt'; $fp = fopen($filename, a); $write = fputs($fp, $string); fclose($fp); } generate_page($formid, $pagename); Steve Jackson Web Development and Marketing Manager Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Permissions on server
If I set permissions of my server root to chmod 777 that's a security risk right? How do I set my server to allow me to write a file to my web root from another directory using PHP? Or is it a Unix problem? I have a generator file writes a string to a text file and then renames the text file as a PHP file however it occurred to me while I was doing this that chmod 777 the root might not be a good idea. Anyone have a simple fix or idea for this? Kind regards, Steve Jackson Web Development and Marketing Manager Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Please assist - been on this for hours - Permissions on server
On Tue, 2003-07-08 at 07:21, Steve Jackson wrote: If I set permissions of my server root to chmod 777 that's a security risk right? How do I set my server to allow me to write a file to my web root from another directory using PHP? Or is it a Unix problem? I have a generator file writes a string to a text file and then renames the text file as a PHP file however it occurred to me while I was doing this that chmod 777 the root might not be a good idea. Anyone have a simple fix or idea for this? Change the ownership on the directory to whichever user apache is running as (this is the User directive in your httpd.conf file). Then you can restrict the permissions on that directory. You could probably make it 600 if you want. Can this be done automatically with PHP? I want a file to be written to the root directory by PHP and not have to get the web server admin to change ownership privaleges on the root. Basically does anyone know how to get PHP to see what the server name and group is and then assign the writing rights to the script? This will allow me to generate a file on the fly. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Headers and server
Sorry if anyone has seen anything like this before but: All I want to do is get a script to write a file to the root directory. I get permission problems. Is there any way around this or am I going to go crazy trying. Obviously I can't have users setting the root directory to CHMOD 777, I can't expect users to get system admins to change ownerships on files, so is there a way in PHP script to write to the root after I have executed this script? The problem comes in the re-name of the script: function generate_page($formid, $pagename) { // Give the function the string to be generated including formid passed from // previous form // Begin string $string = ?php // include the files from output fns to get functions which design the page include ('output_fns.php'); db_connect(); \$query = \select * from goldfish_content where PageID='$formid'\; \$result = mysql_query(\$query) or die(\Error: Query failure withBR\$queryBR\.mysql_error()); while (\$array = mysql_fetch_array(\$result)) { \$HeadTitle = \\{\$array[\HeadTitle\]}\; \$PageTitle = \\{\$array[\Title\]}\; \$BodyText = \\{\$array[\BodyText\]}\; \$Picture1 = \\{\$array[\PictureOne\]}\; \$Picture2 = \\{\$array[\PictureTwo\]}\; \$CatID = \\{\$array[\CatID\]}\; } // carry the variable head title in the page and do the page header do_html_header(\$HeadTitle); // carry variables into do_html_index() function in output_fns. // Page title = The headline of the page // Body text = The text body, can include html commands. // Picture 1 = picture or graphic that appears above the title if required. // Picture 2 = Picture that appears right hand side on the basic output_fns // CatID = Category which is used for determining which links appear on each page // Section name = Allows you to specify extra functions to output_fns.php to be unique to the page (requires hard coding) do_html_index(\$PageTitle, \$BodyText, \$Picture1, \$Picture2, \$CatID, \$SECTION_NAME); // put the page footer in position do_html_footer(); ?; // end of string // Define the filename to write to. $filename = 'test.txt'; // Open the file for overwriting. $fp = fopen($filename, w); // Write the string to the file $write = fputs($fp, $string); // Close the file fclose($fp); // rename the page as a php file // everything works fine until I try to rename this file as the form $pagename var in the root. I get permission denied. rename ($filename, ../$pagename.php); // end of function. } // call the function. generate_page($formid, $pagename); ? The page generates great and everything is hunky dory if the root is chmoded 777 but I have a feeling I'm wasting my time with this route unless someone has a better idea. Steve Jackson Web Development and Marketing Manager Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP forum
I should also add that another 685 posts would say RTFM about lightbulbs. Steve Jackson Web Development and Marketing Manager Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -Original Message- From: Richard Baskett [mailto:[EMAIL PROTECTED] Sent: 9. heinäkuuta 2003 6:42 To: PHP General Subject: [PHP] PHP forum Ok some of you might not like this, others of you will know exactly what I mean, but it just reminded me so much of this forum that I am sure some of you will catch the humor in it: http://www.mac-forums.com/forums/showpost.php?postid=5736postcount=85 Please keep your flames directed at me instead of the mailing list so we can keep this thread to one post. Cheers! What's in a name? That which we call a rose by any other name would smell as sweet. - Shakespeare -- 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] Please assist - been on this for hours - Permissions on server
But _why_ do you need to write to the root directory? Why not just write to a directory where you *do* have permission to write to? I can already do that. My problem is that I need to move or copy/delete the file from the place I do have permission to write to to the root. I have generated a PHP page but it is no good where it is, I need to automatically move this page and because the owner of the page is HTTPD and NoGROUP it doesn't let me. I get permission errors. I have tried chmod() and chown() the files I've written also to no avail. I'd really appreciate help because I don't know much at all about permissions, changing them or how I can automatically do this. Below is the code I have worked out up to now to generate the page. It's the part after the string which I have now tried about 60 different ways to adjust! function generate_page($formid, $pagename) { // Give the function the string to be generated including formid passed from // previous form $string = ?php \$SECTION_NAME = \goldfish_cms.php\; // include the files from output fns to get functions which design the page include ('output_fns.php'); db_connect(); \$query = \select * from goldfish_content where PageID='$formid'\; \$result = mysql_query(\$query) or die(\Error: Query failure withBR\$queryBR\.mysql_error()); while (\$array = mysql_fetch_array(\$result)) { \$HeadTitle = \\{\$array[\HeadTitle\]}\; \$PageTitle = \\{\$array[\Title\]}\; \$BodyText = \\{\$array[\BodyText\]}\; \$Picture1 = \\{\$array[\PictureOne\]}\; \$Picture2 = \\{\$array[\PictureTwo\]}\; \$CatID = \\{\$array[\CatID\]}\; } // carry the variable head title in the page and do the page header do_html_header(\$HeadTitle); // carry variables into do_html_index() function in output_fns. // Page title = The headline of the page // Body text = The text body, can include html commands. // Picture 1 = picture or graphic that appears above the title if required. // Picture 2 = Picture that appears right hand side on the basic output_fns // CatID = Category which is used for determining which links appear on each page // Section name = Allows you to specify extra functions to output_fns.php to be unique to the page (requires hard coding) do_html_index(\$PageTitle, \$BodyText, \$Picture1, \$Picture2, \$CatID, \$SECTION_NAME); // put the page footer in position do_html_footer(); ?; // Define the filename to write to. $filename = 'test.txt'; // Open the file for overwriting. $fp = fopen($filename, w); // Write the string to the file $write = fputs($fp, $string); // Close the file fclose($fp); // copy the page as a php file $fp2 = fopen($filename, r); $root = /home/root/; copy($filename, $root); // rename the filename in the root directory to the pagename rename($filename, $pagename.php); fclose($fp2); // end of function. } // call the functions. generate_page($formid, $pagename); ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Please assist - been on this for hours - Permissions on server
The root of the problem (pun intended) Oh dear! ;o) is that you're trying to write to the root (/) directory which is usually only possible if you're the root user. Again, the question is _why_ do you need to write to the root directory? Wouldn't your file function if it wasn't in the root directory? I don't particularly need to *write* to the root directory. I do need to move the file to the root directory though as it's part of a CMS system. I can write the file to a directory which is adequately protected, but there has to be a way to move the file after it is written (to the root from said protected directory). The file is designed to be generated by another user. There are easier ways to design a CMS system I realise but this is my goal, to allow a user to simply generate a file which then is placed in the webroot after it has been written. I thought that this would be the easy part. Any more ideas? Thanks for your help Jason I appreciate it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Please assist - been on this for hours - Permissions onserver
Writing and moving require the same permissions. Also, there is a big difference between root and webroot. Which one are you talking about? Web root. Sorry not the root directory of the server but the webroot. 1 directory back in fact is all I need so the structure would be: Web Cms generator.php Web generated.php So I can protect the CMS directory which currently needs to be chmod 777 in order to write the page (at least that was the only way I could get the write function to work) and then just have the written files drop back into the web root so that if someone typed: http://www.mysite.com/generated.php They would get the page. Not (as I can currently do) http://www.mysite.com/cms/generated.php Thanks. Steve Jackson Web Development and Marketing Manager Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Please assist - been on this for hours - Permissions onserver
Interesting. Do I need to open an FTP connection do you think or use wrappers? I tried this: // Define the filename to write to. $filename = 'test.txt'; // Open the file for overwriting. $fp = fopen($filename, w); // Write the string to the file $write = fputs($fp, $string); // Close the file fclose($fp); // rename the filename in the root directory to the pagename rename($filename, $pagename.php); $url = 172.16.2.4/~stephenj/misc/webpage; $final_url = ftp://$url/$pagename.php;; $fp2 = fopen(ftp://$url/cms/$pagename.php;, r); Line 59. $move = fputs($fp2, $final_url); fclose($fp2); // end of function. and get a really odd error: Warning: fopen(ftp://172.16.2.4/~stephenj/misc/webpage/cms/this_wont_work.php,; r) - Inappropriate ioctl for device on line 59 Any ideas people? Steve Jackson Web Development and Marketing Manager Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -Original Message- From: Jason Wong [mailto:[EMAIL PROTECTED] Sent: 11. heinäkuuta 2003 11:47 To: [EMAIL PROTECTED] Subject: Re: [PHP] Please assist - been on this for hours - Permissions onserver On Friday 11 July 2003 15:20, Steve Jackson wrote: Writing and moving require the same permissions. Also, there is a big difference between root and webroot. Which one are you talking about? Web root. Sorry not the root directory of the server but the webroot. 1 directory back in fact is all I need so the structure would be: Web Cms generator.php Web generated.php So I can protect the CMS directory which currently needs to be chmod 777 in order to write the page (at least that was the only way I could get the write function to work) and then just have the written files drop back into the web root so that if someone typed: http://www.mysite.com/generated.php They would get the page. Not (as I can currently do) http://www.mysite.com/cms/generated.php You can use php's ftp functions to write the file into your webroot directory. -- 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 -- /* One enemy soldier is never enough, but two is entirely too many -- Murphy's Military Laws n68 */ -- 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] Please assist - been on this for hours - Permissions onserver
Same error. Warning: fopen(ftp://[EMAIL PROTECTED]/misc/webpage/cms/test.txt,w) - Inappropriate ioctl for device in /home/stephenj/public_html/misc/webpage/cms/generator.php on line 51 Think this is going to get too complicated for a user interface as well so I might have to abandon this idea. I think I'll just try uploading a template file with it's unique ID rather than writing one directly to the server. I don't want to have to have users put their ftp username and password into the CMS for it to work. Unless you think I am not far from success with this method? All I wanted was for a file to be written into a safe directory and then moved automatically to the webroot. Steve Jackson Web Development and Marketing Manager Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -Original Message- From: Marek Kilimajer [mailto:[EMAIL PROTECTED] Sent: 11. heinäkuuta 2003 13:32 To: Steve Jackson Cc: [EMAIL PROTECTED] Subject: Re: [PHP] Please assist - been on this for hours - Permissions onserver Write the file with ftp right away: // Define the filename to write to. $filename = 'ftp://username:[EMAIL PROTECTED]/your_webdir/test.txt'; // Open the file for overwriting. $fp = fopen($filename, w); // Write the string to the file $write = fputs($fp, $string); // Close the file fclose($fp); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Please assist - been on this for hours - Permissions onserver
You *are* using the correct user/pass? It should be the same as what you use to upload files to your webroot. If you can't get this to work then try the ftp functions. Yes I am. Alternatively, you could consider storing them in a DB. Yes that's what I was thinking they only need put the username password in once so it might not be such a bad idea. But more I think about this I'm doing this in a strange way. If I upload the file directly to root rather than write it then I won't have any problems. Doesn't matter who owns the file then. I still don't understand (ie you still haven't explained) why you're creating the file somewhere then move it elsewhere. Why can you not use it where it's created, or create it where it's to be used? I can't create it where it's meant to be used by writing the file because it would mean changing the permissions of the web root directory to chmod 777. That was the only way I could get the generator file to write the php page by 'chmodding' the directory that the files were being created in to 777. If I do that to the web root it's a security risk. My idea and it's turned out to be a bad one was to put the generator file: ie the file writing the page on the fly in a safe directory IE outside the webroot or in a protected directory. Then move the file to the web root from the safe directory. If there is a way to do what you suggest without a security risk I'd buy you a beer and send it to you via ASDL if you'd tell me how ;o). Cheers, Steve. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] So in summary this can't be done due to permission problems?
As part of a CMS I wanted to get the user to: 1) Create a new recordset via a form (with a uniqueid). 2) Press submit whereupon php gets the ID of the record just created in the DB, writes a new page to the server with that unique id and saves it as a filename determined by the user. No way around that due to permission settings on the webroot? So there is no way that PHP can write to the server unless the directory it's writing in is executable? Thanks for continued help. Cheers, Steve Jackson Web Development and Marketing Manager Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] If no record in MySQL how to?
I have a problem whereby I need to show links based on an ID which is in a MySQL DB. So if ID 1 exists I pull an array of links which are defined as belonging to ID1. This works OK. How though can I distinguish between ID's which are not in the DB. I want to display something if there are no links also and don't know what I'm doing wrong. I try to display table 1 listed below but just get nothing returned with this command. What am I doing wrong? print td valign='top' align='right'img src='pictures/document_heading_blue.gif' border='0'; // link to documents $link_sql = select * from documents where id = '$id'; $link_result = mysql_query($link_sql); while ($documents = mysql_fetch_array($link_result)) { if (!$documents[id]) //If no ID in DB display table 1... { print table cellpadding='4'trtd width='10'img src='../images/nuoli_right_pieni.gif' border='0'/tdtd width='166'a href='mailto:[EMAIL PROTECTED]'No supporting documents with this article mail us for more information/a/td/tr/table; } else //Display table with array of linked files. { print table cellpadding='4'trtd width='40'img src='../images/adobepdf.gif' border='0'/tdtd width='136'a href='$documents[url]' class='greenlinks'$documents[name]/a/td/tr/table; } } // end check for documents Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] If no record in MySQL how to?
Thanks Marek, That is the solution I was looking for. Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -Original Message- From: Marek Kilimajer [mailto:[EMAIL PROTECTED]] Sent: 11. helmikuuta 2003 13:39 To: Steve Jackson Cc: PHP General Subject: Re: [PHP] If no record in MySQL how to? if there are no rows, the while condition will return false so the while block will never be executed, try if(mysql_num_rows($link_result) ){ while($documents = mysql_fetch_array($link_result)) { print table cellpadding='4'trtd width='40'img src='../images/adobepdf.gif' border='0'/tdtd width='136'a href='$documents[url]' class='greenlinks'$documents[name]/a/td/tr/table; } } else { print table cellpadding='4'trtd width='10'img src='../images/nuoli_right_pieni.gif' border='0'/tdtd width='166'a href='mailto:[EMAIL PROTECTED]'No supporting documents with this article mail us for more information/a/td/tr/table; } Steve Jackson wrote: I have a problem whereby I need to show links based on an ID which is in a MySQL DB. So if ID 1 exists I pull an array of links which are defined as belonging to ID1. This works OK. How though can I distinguish between ID's which are not in the DB. I want to display something if there are no links also and don't know what I'm doing wrong. I try to display table 1 listed below but just get nothing returned with this command. What am I doing wrong? print td valign='top' align='right'img src='pictures/document_heading_blue.gif' border='0'; // link to documents $link_sql = select * from documents where id = '$id'; $link_result = mysql_query($link_sql); while ($documents = mysql_fetch_array($link_result)) { if (!$documents[id]) //If no ID in DB display table 1... { print table cellpadding='4'trtd width='10'img src='../images/nuoli_right_pieni.gif' border='0'/tdtd width='166'a href='mailto:[EMAIL PROTECTED]'No supporting documents with this article mail us for more information/a/td/tr/table; } else //Display table with array of linked files. { print table cellpadding='4'trtd width='40'img src='../images/adobepdf.gif' border='0'/tdtd width='136'a href='$documents[url]' class='greenlinks'$documents[name]/a/td/tr/table; } } // end check for documents Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Process array after form submission problem
Hi, My problem is that I have a dynamic form with vars which I want to process. The variables are checkbox names with a variable number of checkboxes but all currently have the same variable name. ie. form action='process.php' method='post' input type = text name = user value = name input type = checkbox name = grant value = {$array[code]} input type = checkbox name = grant value = {$array[code]} input type = checkbox name = grant value = {$array[code]} The array code works fine in that the values reflect what is in the DB. I understand that $grant will be an array? (am I right?) so how do I use PHP to look at $grant as an array in my processing script rather than an ordinary variable? I can get the DB to update if there is only one checked box but otherwise it updates the DB with the value of the last checkbox. Any ideas? Steve Jackson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Process array after form submission problem
Cheers, Solved the problem exactly how I wanted it. Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -Original Message- From: Matt Schroebel [mailto:[EMAIL PROTECTED]] Sent: 13. helmikuuta 2003 21:29 To: Php-General; Steve Jackson Subject: RE: [PHP] Process array after form submission problem -Original Message- From: Steve Jackson [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 13, 2003 2:10 PM To: Php-General Subject: [PHP] Process array after form submission problem Hi, My problem is that I have a dynamic form with vars which I want to process. The variables are checkbox names with a variable number of checkboxes but all currently have the same variable name. ie. form action='process.php' method='post' input type = text name = user value = name input type = checkbox name = grant value = {$array[code]} input type = checkbox name = grant value = {$array[code]} input type = checkbox name = grant value = {$array[code]} The array code works fine in that the values reflect what is in the DB. I understand that $grant will be an array? (am I right?) so how do I use PHP to look at $grant as an array in my processing script rather than an ordinary variable? I can get the DB to update if there is only one checked box but otherwise it updates the DB with the value of the last checkbox. Add [] to the end of the item name like: input type = checkbox name = grant[] value = {$array[code]} ?php $grant = $_POST['grant']; if (is_array($grant)) { echo 'Items checked:br'; foreach ($grant as $value) { echo $valuebr; } } -- 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] Renaming an uploaded file
Hi all, I am in the process of building a CMS and need to know how to rename an uploaded template. I can upload the page fine (ie. Template.php) but then I want to be able to save the file as a user specified name after the upload is done. Either that or copy the template from the server and save it as something else. The reason is that I want all the php files to be physical URLs rather than be a page with an ID assigned so that tracking where users have been is easier. Currently we use webalizer to track pages and ?ID=whatever is dropped from the URL string for entry and exit pages. Any suggestions? Kind regards, Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Renaming an uploaded file
OK, Thanks that helped. I've sorted that part of the problem. Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -Original Message- From: Jason Wong [mailto:[EMAIL PROTECTED] Sent: 24. helmikuuta 2003 11:20 To: [EMAIL PROTECTED] Subject: Re: [PHP] Renaming an uploaded file On Monday 24 February 2003 16:39, Steve Jackson wrote: I am in the process of building a CMS and need to know how to rename an uploaded template. I can upload the page fine (ie. Template.php) but then I want to be able to save the file as a user specified name after the upload is done. Either that or copy the template from the server and save it as something else. How are you processing the uploaded file? Usually (as per example in manual), you would use the move_uploaded_file() command. That allows you to specify a destination filename. -- 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 -- /* Sex is like air. It's only a big deal if you can't get any. */ -- 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] Using a PHP mime email attachment
My problem is that I am trying to send a PDF file from my server after someone has registered for it. The email message, correct attachment name and even file type arrive correctly but the file is only 73Bytes and when you try to open it I get a read error. Can anyone see what is wrong? // send an email to the user and then a thanks messaage $fileatt = db/; // Path to the file $fileatt_type = application/pdf; // File Type $fileatt_name = webopman.pdf; // Filename that will be used for the file as the attachment $email_from = [EMAIL PROTECTED]; // Who the email is from $email_subject = Thank you for downloading the file; // The Subject of the email $message_text = Dear $username, br Thank you for taking the time to subscribe for our free file.br Please find the document attached to this email.br; // Message that the email has in it $email_to = $email; // Who the email is too $headers = From: .$email_from; $file = fopen($fileatt,'r'); $data = fread($file,filesize($fileatt)); fclose($file); $semi_rand = md5(time()); $mime_boundary = ==Multipart_Boundary_x{$semi_rand}x; $headers .= \nMIME-Version: 1.0\n . Content-Type: multipart/mixed;\n . boundary=\{$mime_boundary}\; $email_message .= This is a multi-part message in MIME format.\n\n . --{$mime_boundary}\n . Content-Type:text/html; charset=\iso-8859-1\\n . Content-Transfer-Encoding: 7bit\n\n . $message_text . \n\n; // This may be the problem - not sure what chunk_split or base64_encode does $data = chunk_split(base64_encode($data)); $email_message .= --{$mime_boundary}\n . Content-Type: {$fileatt_type};\n . name=\{$fileatt_name}\\n . //Content-Disposition: attachment;\n . // filename=\{$fileatt_name}\\n . Content-Transfer-Encoding: base64\n\n . $data . \n\n . --{$mime_boundary}--\n; $ok = @mail($email_to, $email_subject, $email_message, $headers); } if($ok) { // carry variables into do_html_index() function in output_fns. do_html_index($PageTitle, $BodyText, $Picture1, $Picture2, $CatID, $SECTION_NAME); // put the page footer in position do_html_footer(); } else { $PageTitle = Error!; $BodyText = Sorry there has been an error whilst processing your subscription. Please a href='[EMAIL PROTECTED]' class='link'email us/a and we will send you a copy of the file as soon as possible.; // carry variables into do_html_index() function in output_fns. do_html_index($PageTitle, $BodyText, $Picture1, $Picture2, $CatID, $SECTION_NAME); // put the page footer in position do_html_footer(); exit; } Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP PDF attachment
Can anyone help. I have code which will send email with an attachment via PHP however when it arrives to the destination email the PDF file is empty. I have come across a few emails where people have had the same problem but no answers. Any ideas? Using the normal mail() function with the code below: $to = $email; $from= [EMAIL PROTECTED]; $subject = Thank you for downloading the document; $message = Dear $username,br Thank you for taking the time to subscribe for our free document.br Please find the document attached to this email.; // Obtain file upload vars $fileatt = db/; // Location of file on server $fileatt_type = application/pdf;// Type of file being sent $fileatt_name = webopman.pdf;// Name of file $headers = From: $from; // If the file exists... if (file_exists($fileatt)) { // Read the file to be attached ('rb' = read binary) $file = fopen($fileatt,'rb'); $data = fread($file,filesize($fileatt)); fclose($file); // Generate a boundary string $semi_rand = md5(time()); $mime_boundary = ==Multipart_Boundary_x{$semi_rand}x; // Add the headers for a file attachment $headers .= \nMIME-Version: 1.0\n . Content-Type: multipart/mixed;\n . boundary=\{$mime_boundary}\; // Add a multipart boundary above the plain message $message = This is a multi-part message in MIME format.\n\n . --{$mime_boundary}\n . Content-Type: text/html; charset=\iso-8859-1\\n . Content-Transfer-Encoding: 7bit\n\n . $message . \n\n; // Base64 encode the file data $data = chunk_split(base64_encode($data)); // Add file attachment to the message $message .= --{$mime_boundary}\n . Content-Type: {$fileatt_type};\n . name=\{$fileatt_name}\\n . //Content-Disposition: attachment;\n . // filename=\{$fileatt_name}\\n . Content-Transfer-Encoding: base64\n\n . $data . \n\n . --{$mime_boundary}--\n; } $ok = @mail($to, $subject, $message, $headers); Real stuck here. Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: MIME help needed please...
I just sorted a similar problem I was having. Basically make sure that the file your trying to send is Chmod'ed so that the mail() can actually execute not just read. I was having the same problem where any email I was attaching a file to (in this case a PDF) was attaching the file fine but only the headers so I was receiving a PDF type document but with no information in it. I chmodded the file to and it works fine. I also made use of this script: // uses mime_mail() class from functions.php $msg = This is a PDF e-mail; $attachment = fread(fopen(db/webopman.pdf, r), filesize(db/webopman.pdf)); $mail = new mime_mail(); $mail-from = [EMAIL PROTECTED]; $mail-headers = Errors-To: [EMAIL PROTECTED]; $mail-to = $email; $mail-subject = Thanks for downloading our attachment; $mail-body = $msg; $mail-add_attachment($attachment, webopman.pdf, application/pdf); $mail-send(); Calling this class: /* * Class mime_mail * Original implementation by Sascha Schumann [EMAIL PROTECTED] * Modified by Tobias Ratschiller [EMAIL PROTECTED]: * - General code clean-up * - separate body- and from-property * - killed some mostly un-necessary stuff */ class mime_mail { var $parts; var $to; var $from; var $headers; var $subject; var $body; /* * void mime_mail() * class constructor */ function mime_mail() { $this-parts = array(); $this-to = ; $this-from = ; $this-subject = ; $this-body = ; $this-headers = ; } /* * void add_attachment(string message, [string name], [string ctype]) * Add an attachment to the mail object */ function add_attachment($message, $name = , $ctype = application/octet-stream) { $this-parts[] = array ( ctype = $ctype, message = $message, encode = $encode, name = $name ); } /* * void build_message(array part= * Build message parts of an multipart mail */ function build_message($part) { $message = $part[ message]; $message = chunk_split(base64_encode($message)); $encoding = base64; return Content-Type: .$part[ ctype]. ($part[ name]? ; name = \.$part[ name]. \ : ). \nContent-Transfer-Encoding: $encoding\n\n$message\n; } /* * void build_multipart() * Build a multipart mail */ function build_multipart() { $boundary = b.md5(uniqid(time())); $multipart = Content-Type: multipart/mixed; boundary = $boundary\n\nThis is a MIME encoded message.\n\n--$boundary; for($i = sizeof($this-parts)-1; $i = 0; $i--) { $multipart .= \n.$this-build_message($this-parts[$i]). --$boundary; } return $multipart.= --\n; } /* * void send() * Send the mail (last class-function to be called) */ function send() { $mime = ; if (!empty($this-from)) $mime .= From: .$this-from. \n; if (!empty($this-headers)) $mime .= $this-headers. \n; if (!empty($this-body)) $this-add_attachment($this-body, , text/html); $mime .= MIME-Version: 1.0\n.$this-build_multipart(); mail($this-to, $this-subject, , $mime); } }; // end of class ? Hope this solves the issue. Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -Original Message- From: Manuel Lemos [mailto:[EMAIL PROTECTED] Sent: 26. helmikuuta 2003 3:51 To: [EMAIL PROTECTED] Subject: [PHP] Re: MIME help needed please... Hello, On 02/23/2003 08:01 PM, Shawn McKenzie wrote: I got this from the user contributed notes in the php.net manual. It seems to work fine most of the time, but Eudora and Pegasus users either get mangled attachments or no attachments. Can anyone see a problem (most files are zip, but sometimes tar.gz or sit) I tried using Content-Type: application/zip with the same results. I'm thinking it is some issue with the headers, content-types, boundaries or something. Or maybe Pegasus/Eudora don't understand MIME or base64 (doubtful)??? It could be one of many bugs of the mail() function. You may want to try this class for composing and sending MIME messages as it works around some of those bugs: http://www.phpclasses.org/mimemessage -- Regards, Manuel Lemos -- 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] to Bryan Lipscy Re: [PHP] how___??
$link = mysql_connect(remote host, mysql_user, mysql_password) or die(Could not connect: . mysql_error()); how is that ??? do i have to put the same function ? or is diferent? Basically what they are saying is $link is your connection to your database. Remote_host mysql_user and mysql_password are your login variables (which you should have defined in your db connection function somewhere else - preferably where noone can see it) or die means if it don't work for some reason print out the mysql_error. Mysql_error is a built in function of php and is useful to display problems... Here is a typical function I use to connect to a DB. function db_connect() { $LocalHost = localhost; $User = root; $Password = password; $DBName = database_name; $result = @mysql_connect($LocalHost, $User, $Password)or die(Could not connect to the database); if (!$result) return false; if ([EMAIL PROTECTED]($DBName)) return false; return $result; } Obviously change the variables $localhost (with your servername) $user (your username) password (you guessed it your password) and $DBName with the name of your database. Then when you want to connect to the DB in php you just call db_connect(); The guys are right though for this level of questions you should read the manual all of this is explained in greater detail than we can go into. Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -Original Message- From: Luis A [mailto:[EMAIL PROTECTED] Sent: 26. helmikuuta 2003 1:52 To: [EMAIL PROTECTED] Subject: [PHP] to Bryan Lipscy Re: [PHP] how___?? MEN I DONT HAVE INTERNET ACCESS thanks anyway if some one else can help m e please - Original Message - From: Bryan Lipscy [EMAIL PROTECTED] To: 'Luis A' [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 6:16 PM Subject: RE: [PHP] how___?? Please read the online documentation at http://www.php.net Also read through examples at http://www.zend.com/tips/tips.php?CID=113 And before you ask another question please read: http://www.catb.org/~esr/faqs/smart-questions.html Each of these pages may be translated at http://babel.altavista.com Bryan -Original Message- From: Luis A [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 2:16 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] how___?? i need to do this $link = mysql_connect(remote host, mysql_user, mysql_password) or die(Could not connect: . mysql_error()); how is that ??? do i have to put the same function ? or is diferent? - Original Message - From: Bryan Lipscy [EMAIL PROTECTED] To: 'Luis A' [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 4:57 PM Subject: RE: [PHP] how___?? RTM first please: http://www.php.net/manual/en/function.mysql-connect.php $link = mysql_connect(localhost, mysql_user, mysql_password) or die(Could not connect: . mysql_error()); Replace localhost with the hostname of your mysql server. -Original Message- From: Luis A [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 1:34 PM To: [EMAIL PROTECTED] Subject: [PHP] how___?? hlelooww) i need some one can help me please? i need to make this quine of conection for example i want to connect to a remote mysql server i realy apreciate if some one can help me please? ) -- 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
[PHP] Problem updating
Been on this a couple of hours... anyone see what I'm doing wrong? I get a result of 1 when I echo $result but it doesn't want to update at all. The action of this form index.php?action=update-account is just a switch case Which asks you to use the function update_subscriber_account() below... form method='post' action='index.php?action=update-account' input type='hidden' name='old_id' value='$email' tr th colspan = 2 bgcolor = '#5B69A6' $title /th /tr tr tdReal Name:/td tdinput type = text name='new_realname' maxlength = 100 value ='$realname'/td /tr tr tdPreferred Name:/td tdinput type = text name='new_nickname' maxlength = 100 value ='$nickname'/td /tr tr tdCompany:/td tdinput type = text name='new_company' maxlength = 100 value ='$company'/td /tr tr tdEmail Address:/td tdinput type = text name='new_email' maxlength = 100 value ='$email'/td /tr tr tdRequested Email Format:/td; echo tdselect name='new_mimetype'option; if ($mimetype == 'T') echo selected; echo Text Onlyoption; if ($mimetype == 'H') echo selected; echo HTML/select/td; print /tr tr td colspan=2 align=center; display_form_button('save-changes'); print /td/tr/form/table/centerbr; } } function update_subscriber_account() { db_connect(); $query = update subscribers set email = '$new_email', nickname = '$new_nickname', fullname = '$new_realname', company = '$new_company', mimetype = '$new_mimetype' where email = '$old_id'; $result = mysql_query($query)or die(Error: Could not update queryBR$queryBR.mysql_error()); if (!$result) { echo An error occurred when trying to update the DB; } else { echo $result Successfully updated the details; } } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Problem updating
Actually it didn't need the globals, But I did need to pass the variables into the function! Update_subscriber_account($var1, $var2 etc) I feel a right plonker now! Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -Original Message- From: Tom Rogers [mailto:[EMAIL PROTECTED] Sent: 6. maaliskuuta 2003 16:28 To: Steve Jackson Cc: PHP General Subject: Re: [PHP] Problem updating Hi, Friday, March 7, 2003, 12:27:27 AM, you wrote: SJ Been on this a couple of hours... anyone see what I'm doing wrong? I SJ get a result of 1 when I echo $result but it doesn't want to update SJ at all. The action of this form index.php?action=update-account is SJ just a switch case SJ Which asks you to use the function update_subscriber_account() below... SJ form method='post' action='index.php?action=update-account' SJinput type='hidden' name='old_id' value='$email' SJtr SJ th colspan = 2 bgcolor = '#5B69A6' SJ $title SJ /th SJ/tr SJtr SJ tdReal Name:/td SJ tdinput type = text name='new_realname' maxlength = 100 SJ value ='$realname'/td SJ/tr SJtr SJ tdPreferred Name:/td SJ tdinput type = text name='new_nickname' maxlength = 100 SJ value ='$nickname'/td SJ/tr SJtr SJ tdCompany:/td SJ tdinput type = text name='new_company' maxlength = 100 SJ value ='$company'/td SJ/tr SJtr SJ tdEmail Address:/td SJ tdinput type = text name='new_email' maxlength = 100 SJ value ='$email'/td SJ/tr SJtr SJ tdRequested Email Format:/td; SJ echo tdselect name='new_mimetype'option; SJif ($mimetype == 'T') SJ echo selected; SJecho Text Onlyoption; SJif ($mimetype == 'H') SJ echo selected; SJecho HTML/select/td; SJ print /tr SJ tr SJ td colspan=2 align=center; SJ display_form_button('save-changes'); SJ print /td/tr/form/table/centerbr; SJ } SJ } SJ function update_subscriber_account() SJ { SJ db_connect(); SJ $query = update subscribers SJ set email = '$new_email', SJ nickname = '$new_nickname', SJ fullname = '$new_realname', SJ company = '$new_company', SJ mimetype = '$new_mimetype' SJ where email = '$old_id'; SJ $result = mysql_query($query)or die(Error: Could not update SJ queryBR$queryBR.mysql_error()); SJ if (!$result) SJ { SJ echo An error occurred when trying to update the DB; SJ } SJ else SJ { SJ echo $result Successfully updated the details; SJ } SJ } You will need to use the global vars and also escape quotes like this: function update_subscriber_account() { $new_email = addslashes($_POST['new_email']); . . . $query = update subscribers set email = '$new_email', . . -- regards, Tom -- 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] Passing data between the web to an Intranet
Haven't the faintest idea what you mean by direct from the web and a secure Intranet mysql db and web DB. Sorry. What I mean is that we have an externally hosted website. Currently all the forms etc update tables in the web hosted mysql DB. I am in the process of building a small CRM system and want the data to drop into our non public domain Intranet server. Is this possible? I am thinking down one of three lines. 1) I use PHP to send an email with the data in it and update our internal DB manually (the worst case) Can be done pretty easily. I know but I don't want to have to manually update data from emails to our Intranet server. 2) I use PHP which takes data, sends it as an email, puts it into a form which then automatically updates our internal network (interesting idea but I have no clue if it can be done ;o) Not sure what you mean here. How is it different from the above? I was thinking that I may be able to *automatically* take the data from emails and put them through a form (hosted internally) which would then update our DB here. I just don't know whether it's possible to do or where to start. 3) I use some sort of synchronisation so every time the web DB is updated our internal one is also updated (ideal). See mysql replication. I would welcome any other ideas or solutions. Does mysql have any replication or synchronisation functions? I am told Oracle has but haven't seen this or heard of this with mysql. Did you actually do any research? I'm sure if you google for mysql replication or mysql synchronisation you would get thousands of hits. Yes I did but am not really understanding it which is why I asked here. Sorry if that offends you. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Passing data between the web to an Intranet
Manually? What I meant was that it's pretty easy to send an email to a server and have a script process the email. Thus the script will parse the contents of the mail and update the db accordingly. Search the archives for process mail, I have some old posts which outline how this can be done. Hi, After much searching I found this http://marc.theaimsgroup.com/?l=php-generalm=104210703824057w=2 This http://marc.theaimsgroup.com/?l=php-generalm=104219587732145w=2 And others with process in the body and subject line but not any of the thread you refer to. Don't suppose you could regurgitate it could you? I must have trawled through about 1 messages. I was back to Nov 2001! The above two links don't really help me that much, I just need the process explained so I know I'm on the right track. Cheers, Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Passing data between the web to an Intranet
Thanks to those that have helped thus far. To clarify what we need: Our CRM system (really a prospect gathering system) needs to internally hosted, be realtime and needs to be updated automatically. Our website (hosted externally) is *one of many* tools which we are going to use to gather information from prospects via subscription forms and our shopping cart. Our internal system will hold much more detailed information about our prospects and will be updated every time we deal with the prospect whether that be by phone, mail, email etc. From the web we will simply get information such as email address, name, company name, telephone and country via a form. The idea is that if someone wants to subscribe via the web they are in effect a prospect for our company because they are interested in our products. So our internal DB will have lots of information about each prospect and be updated frequently whereas the web form is a small information gathering tool. Basically what I'll need to set-up is some sort of system which: 1) Validates user input from the web (php) 2) Sends the information to the external website DB for future customer login authentication (php mysqlupdate/insert) 3) Sends the information to our internal website DB (Intranet server) (email or replication?) 4) Flags our people here when a new prospect arrives (phpemail) 5) Full front end system for the prospect details etc (Intranet server). (php/mysql) The MySQL replication documentation is for someone experienced with MySQL and understands the replication concept fully. This is the first time I have even looked at it and I'm a bit unclear. For instance I would assume that my Master DB would be my Internal server but it's just that, an assumption. Also how would I go about configuring an externally hosted web db to be it's slave? Would I need the sysadmin of our web host company to do it? Looking at the documentation it appears that the two databases need to have exactly the same data structure (I think) if they are to be reproduced so if I have 30 fields on my intranet DB for prospects and only five on my externally hosted web DB would replication even be an option? Or is it simply the individual fields which need to be the same? The only part I have a problem with is number 3. Jason Wong has suggested one solution which I can probably get working in a few days when I get more information on how STDIN works but suggestions have been that I should look at replication as more robust and efficient. What (based on what I have told you) would you do? Any help much appreciated. RTFM: http://www.mysql.com/documentation/mysql/bychapter/manual_MySQ L_Database_Administration.html#Replication This really seems to be what you need. Any php-level solution is going to be kludgy and slow by comparison and prone to problems. Go with the tested, production code. It sounds like you may also have a gray area in your requirements that you should clarify. How current does the internal db need to be? Is a once-a-day replication ok for crm applications or does it need to be in real-time? Clarifying this point can really help you out in terms of what your solution needs to be. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] last questions
Here's a function you could use. The input from your form should be email ($email in this script). function valid_email($email) { // check an email address is possibly valid if (ereg([EMAIL PROTECTED], $email)) return true; else return false; } HTH Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -Original Message- From: Jason k Larson [mailto:[EMAIL PROTECTED] Sent: 28. maaliskuuta 2003 5:33 To: Haseeb Iqbal Cc: PHP General list Subject: Re: [PHP] last questions Search the list archives, this question gets asked (and answered) a lot. http://marc.theaimsgroup.com/?l=php-general HTH, Jason k Larson Haseeb Iqbal wrote: thanx to all those who replied to my previous question. 1 more question.i need help with reqular expressions.i want to check valid (email) usernanes for my mail server .i.e. Qmail. any help welcome. thanx in advance Haseeb -- 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] Connecting to a remote server
Your remote server has PHP/MySQL setup? Your DB hostname may be different from Localhost but basically your php connection string should just reflect what host username and password you need to use to connect to your DB. DNS has nothing to do with it. For example this function will connect to *any* mysql database *anywhere* provided the correct variables are inputted simply by calling db_connect(). What I usually do is put this function in a secure place and tell every page which needs a DB connection to include the page ie. include ('secure/db_fns.php'); then just call it. function db_connect() { $LocalHost = your_host_name; $User = username; $Password = password; $DBName = name_of_db; $result = @mysql_connect($LocalHost, $User, $Password)or die(Could not connect to the database); if (!$result) return false; if ([EMAIL PROTECTED]($DBName)) return false; return $result; } What it sounds like your problem is, is that you don't know what your new hostname/username/password etc is. They will likely be different on your new server. If it's remotely hosted ask your administrator what these variables are. If you have admin and root rights you should be able to configure your password and find out the information yourself. Regards, Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -Original Message- From: Jason Wong [mailto:[EMAIL PROTECTED] Sent: 28. maaliskuuta 2003 15:24 To: [EMAIL PROTECTED] Subject: Re: [PHP] Connecting to a remote server On Friday 28 March 2003 21:06, Roberts, Mark \(Tulsa\) wrote: They are not on the same server...that is the problem. They used to be on the same server, but I have had to move the application to a physically different server with a different DNS than the DB Server. So, on the surface, it would seem that I should just replace 'localhost' with the dns name of the DB Server i.e. (http://www.xyz.com). However, this did not work. Is there something else that I should be doing, either in the connect string or in php configuration? Please read my original reply: Are you talking about the database connection? If so, then there is no need for the 'http://'. And if both the webserver and the DB server are on the same machine you can continue to use 'localhost'. -- 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 -- /* This is probably the first and last time I will openly agree for someone to tell me were to go, and do it ;-). - Andre Hedrick on linux-kernel */ -- 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 Email Attachment problem
I also had a similar problem and it was simply because the directory holding the attachment didn't have permission to send the attachment, so check the permissions on the directory. Once I changed it it sends fine. Cheers, Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -Original Message- From: Jason Wong [mailto:[EMAIL PROTECTED] Sent: 3. huhtikuuta 2003 8:23 To: [EMAIL PROTECTED] Subject: Re: [PHP] PHP Email Attachment problem On Wednesday 02 April 2003 04:19, Michael Arena wrote: the only difference in the server setup is on my remote server it's a RAQ and locally i'm using Xitami with PHP. I don't understand why it won't send. I get the email over the RAQ but no attachment... Have you checked that the file actually gets uploaded? are there any other settings that could differ that I would need to set? Like in the php.ini file? Have you enabled file_uploads in php.ini? -- 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 -- /* Our ISP is having {switching,routing,SMDS,frame relay} problems */ -- 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] help me please.
got a problem here people. What I want to do is upload a file and store its name in a database. For some reason I cant. I can upload the file fine but can't pass it's name to the mysql DB. Any ideas: Upload form: ? require( ../Cart.php); Brand(); DBInfo(); echo bYou can now upload a picture.../bbrbr; echo form enctype='multipart/form-data' action='uploadItem.php' method=post; echo INPUT TYPE='hidden' name='MAX_FILE_SIZE' value='25000'; echo INPUT TYPE='hidden' name='ID' value='$II'; echo INPUT name='userfile' type='file'; blueFont( Arial, Send this file: ); echo INPUT TYPE='submit' VALUE='Send File'/form; echo pbThis file MUST be a JPEG (jpg) image./b; //adminFooter($Relative); ? Process the form: ? require(../Cart.php); Root(); DBinfo(); mysql_connect($DBHost,$DBUser,$DBPass); $UploadURL = ../images/; if ($usefile==none) { echo Error: no file uploaded; exit; } //Connect to DB $mysql = mysql_connect($DBHost,$DBUser,$DBPass); if(!$mysql) { echo Cannot connect to database.; exit; } mysql_query(INSERT INTO Items (ImageName) WHERE ItemID = '$II' VALUE('test')); $upfile = $UploadURL.$userfile_name; if ( !copy($userfile, $upfile)) { echo Error: Could not move file into directory; exit; } ? Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Looping?
Anyone help me? this is probably quite simple but I'm pretty new to PHP. All I want to do it loop through some DB records and display them in the format written in this PHP file: Anyone see where I'm going wrong? the error I get says: Warning: Unable to jump to row 0 on MySQL result index 2 ? $dbreturn = mysql_query(SELECT * FROM Items WHERE ItemID = '$ItemID'); //debug echo mysql_error(); $ItemHits = mysql_numrows($dbreturn); $ItemID = mysql_result($dbreturn ,$i,ItemID); $ImageName = mysql_result($dbreturn ,$i,ImageName); $ItemName = mysql_result($dbreturn ,$i,ItemName); $ItemSKU= mysql_result($dbreturn ,$i,ItemSKU); $ItemCost = mysql_result($dbreturn ,$i,ItemCost); $ItemDescription= mysql_result($dbreturn ,$i,ItemDescription); for ($i=0; $i $ItemHits; $i++) //($i $ItemHits) { $row = mysql_fetch_array($dbreturn); echo table width='400' border='0' cellspacing='0' cellpadding='0'; echo tr; echo tdimg src='images/$ImageName' width='175'/td; echo td valign='top'; echo table width='225' border='0' cellspacing='0' cellpadding='0'; echo tr; echo tdspan class='pikkuleipa'Product Name:/span/td; echo tdspan class='pikkuleipa'$ItemName/span/td; echo /tr; echo tr; echo tdspan class='pikkuleipa'Product Code:/span/td; echo tdspan class='pikkuleipa'$ItemSKU/span/td; echo /tr; echo tr; echo tdspan class='pikkuleipa'Unit price:/span/td; echo tdspan class='pikkuleipa'€$ItemCost/span/td; echo /tr; echo tr; echo tdspan class='pikkuleipa'bDescription/b/spanbr/td; echo /tr; echo tr; echo td; echo /td; echo /tr; echo /table; echo table width='225' border='0' cellspacing='0' cellpadding='0'; echo tr; echo tdspan class='pikkuleipa'$ItemDescription/span/td; echo /tr; echo /table; echo /td; echo /tr; echo /table; echo form method='post' action='$Relative/addcart.php'; echo table width='400' border='0' cellspacing='0' cellpadding='0'; echo tr; echo td width='175' align='right'span class='pikkuleipa'Quantity Required:/span/td; echo td width='225'; echo INPUT TYPE='TEXT' Name='ItemQuantity' Value='1' size='2'; echo /td; echo /tr; echo tr; echo td width='175'/td; echo td width='225'input type='image' border='0' name='submit' src='images/add.gif'/td; echo /tr; echo /table; echo /form; //$i++; } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Scrollbars?
This might be off topic but I thought I'd give the list a try... Does anyone know of any PHP or CSS or something which allows you to change the appearance of scrollbars in Explorer and navigator? Kind regards, Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Shopping cart? Ahh!
I have a shopping cart which starts with two categories. The links to each category both have a unique userID so that shopping information can be added to the cart. The problem I have is this: My user can add and remove as many of one category to his cart, but if he links back to the page with both categories listed he loses state (userID) so loses the items in his cart when adding part of the other category. Currently my back button is using this code and I need a quick fix if possible: ? echo A href='index_1.php?CA=$CatIDUID=$UID'img src='../images/nuoli_left.gif' border='0' alt='Back'/abrbr;? Where CatID is the category (currently only one or two) and the UID is the USerID made up of the time date and IP address. You can see what I mean by going here: http://www.violasystems.com/Cart/ and following the links. Click a device server for instance add one of them to the cart and then go back and try adding a starter kit. I want both to appear in the cart if possible. Any ideas? If not I'm off for a cry! Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Function to remember costs.
I am having difficulty passing details to a form. I need to somehow pass a variable cost to a form. The cost is made up of items in a cart (details taken from a Mysql DB) and a shipping cost. I then have a function written to display the credit card form (which needs to be passed to a secure server below the final cost (ie cost plus shipping). I have tried without success most of this morning to pass the final cost plus shipping to the form hidden field (which is on the same html page!) Here is the section of code I am having problems with. I will supply the rest of the functions to anyone who thinks they can help but it's a lot of code. ? } function display_shipping($shipping) { // display table row with shipping cost and total price including shipping global $total_price; ? table border = 0 width = 760 cellspacing = 0 trtd align = leftShipping/td td align = right ?=number_format($shipping, 2); ?/td/tr trth bgcolor=#146190 align = leftTOTAL INCLUDING SHIPPING/th th bgcolor=#146190 align = rightˆ ?=number_format($shipping+$total_price, 2); ?/th /tr /tablebr ? } function display_card_form($name) { //display form asking for credit card details ? table border = 0 width = 760 cellspacing = 0 form action ='https://spos.luottokunta.fi/pm/servlet/Payment' method='post' input type='hidden' name='version' value='1.2' input type='hidden' name='merchant_rn' value='8058950' input type='hidden' name='order_rn' value='10001' input type='hidden' name='amount' value='' input type='hidden' name='amount_exp' value='-2' input type='hidden' name='currency' value='978' input type='hidden' name='order_description' value='Viola test product' input type='hidden' name='success_url' value='http://www.violasystems.com' input type='hidden' name='failure_url' value='http://www.violasystems.com/bazaar' input type='hidden' name='cancel_url' value='http://www.violasystems.com/privacy.php' input type='hidden' name='trans_method' value='0' input type='hidden' name='mac' value='F529BC531D' trth colspan = 2 bgcolor=#ccCredit Card Details/th/tr tr tdType/td tdselect name = card_typeoptionVISAoptionMasterCard/select/td /tr tr tdNumber/td tdinput type = text name = card_number value = maxlength = 16 size = 40/td /tr tr tdAMEX code (if required)/td tdinput type = text name = amex_code value = maxlength = 4 size = 4/td /tr tr tdExpiry Date/td tdMonth select name = card_monthoption01option02option03option04option05option06 option07option08option09option10option11option12/select Year select name = card_yearoption00option01option02option03option04option05o ption06option07option08option09option10/select/td /tr tr tdName on Card/td tdinput type = text name = card_name value = ?=$name; ? maxlength = 40 size = 40/td /tr tr td colspan = 2 align = center bIf you press purchase your credit card details will be transmitted via a secure server, your details processed and then you will be redirected to our site./b ? display_form_button(purchase, Purchase These Items); ? /td /tr /table ? As you can see the PHP code is just a part of one larger page of functions. What I am trying to do is pass the ?=number_format($shipping+$total_price, 2); ? to the amount hidden field in the form. Any ideas? This is not all my code which is why I am having problems. Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com http://www.violasystems.com/ [EMAIL PROTECTED] Mobile +358 50 343 5159
[PHP] Shipping problem...
Hi all, I have a problem which I'm not sure the best way to go about. We will be shipping products based on weight and I have two types of product with differing weights. Basically we want to charge one price for shipping less than 10 KG and one for anything over that. I wonder how to go about it. I have the weights for each product and have my products organised into two categories in MySQL DB. So anything in category 1 means less than 30 items is below 10 Kilos and 15 in category 2. How would you code this? I have tried adding a weight category to my products table and calculating total weight (then a simple if statement would do the trick) but it leads to other problems which I couldn't de-bug. Basically adding to my products table means my DB won't update due to a Mysql error (column count didn't match or something) so I can't do it that way or at least as my shop is currently working I'm scared of messing with the code too much! I also need to have a combination of the two products so the customer might buy 1 of category 2 and 35 of cat 1 etc. Ideas to tackle this please? Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Weight function.
Hi all. Wondering if anyone can shed some light! I have a problem whereby I need to define the weight of a selection of items in a shopping cart in order to calculate a shipping cost. Basically I have 5 products (at the moment) which are of set weights. What I want to do is add up the amount of items in the cart and multiply by weight then determine what the shipping weight is. Once that is determined I can calculate the shipping cost. My problem is arrays. I dunno what I'm doing with them! I can return the weight of one item and multiply that by the amount of items in the cart but need to figure out how do then do it again for any more items and add them to the first calculation. Here is my code: function calculate_weight($items) { global $weight; $conn = db_connect(); $query = select weight from products where catid = $catid; $result = @mysql_query($query); $weight = ($result*$items); return $weight; } Where $items is the number of items in the cart. $catid is the category the products are in but maybe I need to use a different identifier. I have another identifier called $itemCode which defines the actual item which would probably be more reasonable? Thoughts? Regards, Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Weight function.
Thanks. I have just this minute got it working. Basically the same function I used for determining price of the cart items could be used for determining weight. All I needed to do was assign my DB with a field called weight and call that instead of price from the DB so my calculate weight function looks like this. function calculate_weight($cart) { // sum total weight for all items in shopping cart global $weight; $weight = 0.0; if(is_array($cart)) { $conn = db_connect(); foreach($cart as $ItemCode = $qty) { $query = select weight from products where ItemCode='$ItemCode'; $result = mysql_query($query); if ($result) { $item_weight = mysql_result($result, 0, weight); $weight +=$item_weight*$qty; } } } return $weight; } By making $weight a global variable I then call that in my shipping function and set it's parameters: function calculate_shipping_cost($weight) { //shipping costs calc. less than 10KG is 15 more than 10KG currently 20. global $shipping; if ($weight = 1) $shipping = 15; else $shipping = 20; return $shipping; } I still don't fully understand why this works but am happy it does! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Weight function.
I'm using both variables called in another page. Taking globals off causes weight not to be calculated in the shipping cost? Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -Original Message- From: Jason Wong [mailto:[EMAIL PROTECTED]] Sent: 17. lokakuuta 2002 12:39 To: [EMAIL PROTECTED] Subject: Re: [PHP] Weight function. On Thursday 17 October 2002 15:52, Steve Jackson wrote: Thanks. I have just this minute got it working. Basically the same function I used for determining price of the cart items could be used for determining weight. All I needed to do was assign my DB with a field called weight and call that instead of price from the DB so my calculate weight function looks like this. function calculate_weight($cart) { // sum total weight for all items in shopping cart global $weight; $weight = 0.0; if(is_array($cart)) { $conn = db_connect(); foreach($cart as $ItemCode = $qty) { $query = select weight from products where ItemCode='$ItemCode'; $result = mysql_query($query); if ($result) { $item_weight = mysql_result($result, 0, weight); $weight +=$item_weight*$qty; } } } return $weight; See below } By making $weight a global variable I then call that in my shipping function and set it's parameters: By making $weight a global variable there is no need for return $weight; inside your function. And same for return $shipping; below. function calculate_shipping_cost($weight) { //shipping costs calc. less than 10KG is 15 more than 10KG currently 20. global $shipping; if ($weight = 1) $shipping = 15; else $shipping = 20; return $shipping; } I still don't fully understand why this works but am happy it does! -- Jason Wong - Gremlins Associates - www.gremlins.com.hk Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* The solution of problems is the most characteristic and peculiar sort of voluntary thinking. -- William James */ -- 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] Adding to cart function.
My boss wants me to add a number of items to the cart based on a user form input. At the moment my add to cart function checks if anything is in it and then increments one item (using this code). I can supply the full function if required but just this part would get me away I think. if($cart[$new]) $cart[$new]++; Instead of incrementing by one how do I increment by a variable which would be the form input? Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Anyone used Luke Welling Laura Thompsons shopping cart?
I am developing a shopping cart based on the above authors shopping cart fom their book. (Book is a must by the way). I am still pretty new to PHP and MySQL and need some help with the cart. Basically I need to add a form to adjust the quantity in the cart instead of just incrementing by one and then allowing the user to change the amount when she gets there. I have tried unsuccessfully for the last three days to do this. the code that increments the cart is this but if anyone has used the shopping module and knows how to adjust the code to add this fairly simple procedure I'd appreciate it. if($new) { //new item selected if(!session_is_registered(cart)) { $cart = array(); session_register(cart); $items = 0; session_register(items); $total_price = 0.00; session_register(total_price); } if($cart[$new]) $cart[$new]++; else $cart[$new] = 1; $total_price = calculate_price($cart); $items = calculate_items($cart); }
[PHP] Error?
I get the following error and I don't know why this is the code: if($new) { $details = get_product_details($new); if($details[catid]) $target = show_cat.php?catid=.$details[catid]; //line 55 is the bracket below. } $path = $PHP_SELF; $path = str_replace(show_cart.php, , $path); Error: Warning: Can only count STRING and INTEGER values! in /www/u1255/shop_testing/show_cart.php on line 55 Any ideas? all I'm trying to do is pass a qty from a form?
[PHP] Can anyone help please.
I have two test carts online at the moment. This one works fine: http://www.violasystems.com/shop/ this one is the one I want to get working http://www.violasystems.com/shop_testing/ The code for the first shop basically increments the cart by one when the submit button is added using the commented out code. $qty = $formqty; if($cart[$new]) //$cart[$new]++; $cart[$new] = $cart[$new] + $qty; else $cart[$new] = 1; $total_price = calculate_price($cart); $items = calculate_items($cart); I have added the rest (taking a variable from the form $formqty and adding it to the cart) Can anyone see why doesn't this work?
[PHP] Here's a weird one!
I've been trying for ages to add a form field qty to an array to pass it to my shopping cart and have finally managed it but not quite. Please check this cart: http://www.violasystems.com/shop_testing/ When you add an item using the form text box it doesn't add more than 1 on the first submit. However if you go back and then add further items it's will add the multiple products to the cart? I have three functions which control this and can't see where I'm going wrong: Submitting the form: echo table width ='760' background='images/shopbg.gif'form action='show_cart.php' method='post'trtd width='380'nbsp;/td; echo td width='200' align='right'; echo bQuantity required: /binput type='text' name='formqty' value='1' size='3'/td; echo td width='180' align='left'; echo input type='hidden' name='new' value='$ItemCode'; echo input type='image' src='images/add-to-cart.gif' border ='0' alt ='Add to cart'; echo /td/tr/form/table; echo table width='760' background='images/shopbg.gif'trtd width='200'nbsp;/tdtdimg src='images/lower.gif'/td/tr/table; Processing the form: ? include ('products_sc_fns.php'); // The shopping cart needs sessions, so start one session_start(); if($new) { //new item selected if(!session_is_registered(cart)) { $cart = array(); session_register(cart); $items = 0; session_register(items); $total_price = 0.00; session_register(total_price); } $qty = $formqty; if($cart[$new]) //$cart[$new]++; $cart[$new] = $cart[$new] + $qty; else $cart[$new] = 1; $total_price = calculate_price($cart); $items = calculate_items($cart); } if($save) { foreach ($cart as $ItemCode = $qty) { if($$ItemCode==0) unset($cart[$ItemCode]); else $cart[$ItemCode] = $$ItemCode; } $total_price = calculate_price($cart); $items = calculate_items($cart); } do_html_header(Your shopping cart); //array de-bug //print_r($cart); if($cartarray_count_values($cart)) display_cart($cart); else { echo table width='760' cellpadding='0' background='images/shopbg.gif'trtd width='200'nbsp;/tdtdThere are no items in your cart; echo /td/tr/table; } $target = index.php; // if we have just added an item to the cart, continue shopping in that category if($new) { $details = get_product_details($new); if($details[catid]) $target = show_cat.php?catid=.$details[catid]; } $path = $PHP_SELF; $path = str_replace(show_cart.php, , $path); echo table width='760' cellpadding='0' background='images/shopbg.gif'trtd width='200'nbsp;/tdtd align='left'; display_button($target, continue-shopping, Continue Shopping); display_button(http://.$SERVER_NAME.$path.checkout.php;, go-to-checkout, Go To Checkout); echo /td/tr/table; do_html_footer(); ? And displaying the cart: function display_cart($cart, $change = true, $images = 1) { // display items in shopping cart // optionally allow changes (true or false) // optionally include images (1 - yes, 0 - no) global $items; global $total_price; echo table border = 0 width = 760 cellspacing = 0 background='images/shopbg.gif' form action = show_cart.php method = post trth width='200'nbsp;/thth colspan = . (1+$images) . bgcolor=\#146190\font face='Verdana,Arial' size='-1' color='White'Item/font/th th bgcolor=\#146190\font face='Verdana,Arial' size='-1' color='White'Price/font/thth bgcolor=\#146190\font face='Verdana,Arial' size='-1' color='White'Quantity/font/th th bgcolor=\#146190\font face='Verdana,Arial' size='-1' color='White'Total/font/th/tr; //display each item as a table row $qty = $formqty; foreach ($cart as $ItemCode = $qty) { $product = get_product_details($ItemCode); echo trtd width='200'nbsp;/td; if($images ==true) { echo td align = left; if (file_exists(images/$ItemCode.jpg)) { $size = GetImageSize(images/.$ItemCode..jpg); if($size[0]0 $size[1]0) { echo img src=\images/.$ItemCode..jpg\ border=0 ; echo width = . $size[0]/3 . height = .$size[1]/3 . ; } } else echo nbsp;; echo /td; } echo td align = left; echo a href = \show_products.php?ItemCode=.$ItemCode.\.$product[ItemName]./a (Code) .$product[ItemCode]; echo /tdtd align = center€ .number_format($product[price], 2); echo /tdtd align = center; // if we allow changes, quantities are in text boxes if ($change == true) echo input type='text' name='$ItemCode' value='$qty' size='3'; else echo $qty; echo /tdtd align = center€ .number_format($product[price]*$qty,2)./td/tr\n; } // display total row echo trth width='200'nbsp;/th th colspan = . (2+$images) . bgcolor=\#146190\nbsp;/th th align = center bgcolor=\#146190\font face='Verdana,Arial' size='-1' color='White' $items
[PHP] Displaying one of three functions.
I have three functions written which work and I want to only display one of them depending on user input. What is the correct way to code this? I can display all three functions but not one. this is my code: ? include ('products_sc_fns.php'); // The shopping cart needs sessions, so start one session_start(); do_html_header(Checkout); // if filled out if($cart$name$address$city$zip$country) { // able to insert into database if( insert_order($HTTP_POST_VARS)!=false ) { //display cart, not allowing changes and without pictures display_cart($cart, false, 0); calculate_weight($cart); //de-bug //echo test $country $express; display_shipping(calculate_shipping_cost($weight)); display_shipping(calculate_nonfinland_cost($country)); display_shipping(calculate_express_cost($express)); //display_shipping(calculate_temp_shipping_cost($weight)); //get credit card details calculate_final_cost($total_price, $shipping); get_order_id(); display_card_form($name, $final_cost); echo table width='760' cellpadding='0' background='images/shopbg.gif'trtd width='200'nbsp;/td; echo td align='right'; display_button(show_cart.php, continue-shopping, Continue Shopping); echo /td/tr/table; } else { // error info and footer goes here. I want to display shipping if the user is from finland and paying an express cost display_shipping(calculate_express_cost($express)); from finland but paying by weight of shipping display_shipping(calculate_shipping_cost($weight)); or from outside of finland display_shipping(calculate_nonfinland_cost($country)); How do I write the If statement to say if country=finlandexpress=yes display function 1 then if country = finland but express= display function 2 or if country isn't finland do 3? Tried all morning and repeatedly failed! Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com http://www.violasystems.com/ [EMAIL PROTECTED] Mobile +358 50 343 5159
[PHP] New Error?
I get this error from my code. Fatal error: Cannot break/continue 1 levels in /www/u1255/shop/purchase.php on line 22 I think I need to end the functions if a condition is met so is there a way to do it without breaking? Where do I go from here? ? include ('products_sc_fns.php'); // The shopping cart needs sessions, so start one session_start(); do_html_header(Checkout); // if filled out //echo testing; if($cart$name$address$city$zip$country) { // able to insert into database if( insert_order($HTTP_POST_VARS)!=false ) { //display cart, not allowing changes and without pictures display_cart($cart, false, 0); calculate_weight($cart); //determine what shipping we are using if ($country!=Finland){ display_shipping(calculate_nonfinland_cost($country)); break; } elseif ($country==Finland $express==no){ display_shipping(calculate_shipping_cost($weight)); break; } elseif ($country==Finland $express==yes){ display_shipping(calculate_express_cost($express)); break; } //de-bug echo test $country $express; //if($country!=Finland) //display_shipping(calculate_shipping_cost($weight)); //{ //display_shipping(calculate_nonfinland_cost($country)); //} //display_shipping(calculate_express_cost($express)); //display_shipping(calculate_temp_shipping_cost($weight)); //get credit card details calculate_final_cost($total_price, $shipping); get_order_id(); display_card_form($name, $final_cost); echo table width='760' cellpadding='0' background='images/shopbg.gif'trtd width='200'nbsp;/td; echo td align='right'; display_button(show_cart.php, continue-shopping, Continue Shopping); echo /td/tr/table; } else { echo mysql_error(); echo table width='760' cellpadding='0' background='images/shopbg.gif'trtd width='200'nbsp;/tdtdCould not store data, please try again./td; echo trtd width='200'nbsp;/tdtd; display_button(checkout.php, back, Back); echo /td/tr/table; } } else { echo table width='760' cellpadding='0' background='images/shopbg.gif'trtd width='200'nbsp;/tdtdYou did not fill in all the fields, please try again./td; echo trtd width='200'nbsp;/tdtd; display_button(checkout.php, back, Back); echo /td/tr/table; } do_html_footer(); ? Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com http://www.violasystems.com/ [EMAIL PROTECTED] Mobile +358 50 343 5159
[PHP] Php web hosting
Anyone like to recommend a good host with good uptime for a high traffic site? The host would need excellent technical support as well as be feature rich (Multiple MySQL database support/listserver/SSL support etc.) I have been trying out phpwebhosting.com and they seem very good but I am not happy with their technical support which is very slow response time. We are based in Europe and they are in the US which might lead to problems as they haven't answered any of our queries. Saying that they have a good automated process in place which is easy to use. Anyone out there have high volume sites with a feature rich hosting solution? Any examples of Phpwebhosting welcomed as well. regards steve.
[PHP] How do you select?
I want to the select the very last record from my MySQL DB. How do I do it? Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com http://www.violasystems.com/ [EMAIL PROTECTED] Mobile +358 50 343 5159
[PHP] Anything wrong with this function?
Can anyone see why I am having problems with this page. I'm trying to connect to the DB and display results using the function get_order_id_receipt. The DB connection works because I can produce the cart based on the users session so I don't get why this doesn't work ? include ('products_fns.php'); include ('order_fns.php'); include ('db_fns.php'); include ('output_fns.php'); // The shopping cart needs sessions, so start one session_start(); do_html_header(Please print out this page for your records.); function get_order_id_receipt($orderid, $shipping) { //Get order ID from DB to pass to receipt. $conn = db_connect(); $query = select orderid from receipts; $shippingquery = select shipping from receipts; $orderid = mysql_result($query); $shipping = mysql_result($shippingquery); //return $orderid; } //debug test echo mysql_error(); echo test $orderid; echo test $shipping; display_receipt($orderid); echo table width='760' cellpadding='0' background='images/shopbg.gif'trtdnbsp;/td/tr/table; display_cart($cart, false, 0); echo table width='760' cellpadding='0' background='images/shopbg.gif'trtdnbsp;/td/tr/table; echo table width='760' cellpadding='0' background='images/shopbg.gif'trtdnbsp;/td/tr/table; display_success_form(); //empty shopping cart //session_destroy(); do_html_footer(); ? Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com http://www.violasystems.com/ [EMAIL PROTECTED] Mobile +358 50 343 5159
[PHP] At last an error message!
function get_order_id_receipt($orderid, $shipping) { //Get order ID from DB to pass to receipt. $conn = db_connect(); $datequery = select date from receipts where customerid = '10'; $query = select orderid from receipts where customerid = '10'; $shippingquery = select shipping from receipts where customerid = '10'; $date_result = mysql_query($datequery); $date = mysql_result($date_result); $orderid_result = mysql_query($query); $orderid = mysql_result($orderid_result); $shipping_result = mysql_query($shippingquery); $shipping = mysql_result($shipping_result); return $orderid; return $shipping; } I get these errors echoed from mysql_error() Warning: Wrong parameter count for mysql_result() in order_fns.php on line 127 Warning: Wrong parameter count for mysql_result() in order_fns.php on line 129 Warning: Wrong parameter count for mysql_result() in order_fns.php on line 131 What does that mean? Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com http://www.violasystems.com/ [EMAIL PROTECTED] Mobile +358 50 343 5159
[PHP] Simple Problems taking me hours to solve!
This is the query I am running on my database: $query = select orderid from receipts order by receipt_id DESC LIMIT 0,1; $orderid = mysql_query($query); That should return the last record in the DB? Correct? I currently get a number returned which is the number plus 1. IE if 423 is the last DB record then 424 is returned. Any ideas why this happens? Also in the same table I have a shipping price variable. My query for this is: $query = select shipping from receipts order by receipt_id DESC LIMIT 0,1; $shipping_cost = mysql_query($query); Again this should return the last record? It doesn't return anything however. Any ideas? Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com http://www.violasystems.com/ [EMAIL PROTECTED] Mobile +358 50 343 5159
[PHP] Help please.
Hi, I have been trying for most of the day to pull a variable from a db. Finally managed that. Now I need to pass the result of a function to another function. How do you do this? I assume the following if called in another page can be used? function get_shipping($shipping) { $conn = db_connect(); $query = SELECT * FROM receipts ORDER BY receipt_id DESC LIMIT 1; $result = mysql_query($query); //$shippingvar = $myrow[shipping]; if(mysql_numrows($result)0) $shipping = mysql_result($result, 0, shipping); return $shipping; } If I return $shipping how can I display that? I have called it in another page by doing get_shipping($shipping) And then Echo test $shipping; But that doesn't work. Ideas where I'm going wrong this time? Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Get shipping problem continued!
Sorry to keep on at you guys but this is really getting to me now! I want to pull a shipping quantity (the very last record in the Db) into a page and am still having problems. Tried looping through the records and I can't seem to get it to return anything: function get_shipping($shippingvar) { $conn = db_connect(); $query = mysql_query(SELECT MAX(receipt_id) from receipts); $myrow = mysql_fetch_row($query); $shippingvar = $myrow[shipping]; return $shippingvar; } Surely it can't be much more complicated than that? Help please. Smoked 10 fags already! Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Address array?
I want to display an address from my database based on an orderid. Where am I going wrong? I am still unsure how Php interacts with mySQL but am I right in assuming it should be an array? My code... function get_shipping_address($address_array) { $conn = db_connect(); $orderid = get_order_id($orderid); $query = SELECT * FROM orders WHERE orderid = '$orderid'; $row = mysql_fetch_array($query); foreach ($address_array as $row) { $ship_name = $row[ship_name]; $ship_address = $row[ship_address]; $ship_city = $row[ship_city]; $ship_zip = $row[ship_zip]; $ship_country = $row[ship_country]; } } Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Help me learn! with an explanation of these two functions.
Can someone run over these functions I have written to explain if my logic is correct. I'm still new to PHP and am trying to get my head round it! This first function is to collect a list of order numbers from my database where checked = no. Am I correct in assuming that the variable $orderid will be an array of results returned? How can I check this? function get_live_orders() { $conn = db_connect(); $query = select orderid from email where checked='no'; $result = @mysql_query($query); if(mysql_numrows($result)0) $orderid = @mysql_fetch_array($result); return $orderid; } This second function is to take these order numbers and compare them to order numbers in a second table and return the result of that. So if order number 11 is in the first array from the above function and there is a number 11 in the second query result I want to take all the data in that row and return it. function get_order_details() { $orderid = get_live_orders(); $conn = db_connect(); $query = select * from orders where orderid='$orderid'; $result = @mysql_query($query); if (!$result) return false; $result = mysql_result($result, 0, orderid); return $result; } I haven't actually run this yet but I'd like someone to explain to me what these functions will do so I am not just copy pasting code and hoping to get it right eventually! Probably I have written this wrong anyway and would like help before I actually attempt to do what I am after. I'll look back on this tomorrow so any help will be greatly appreciated. Kind regards, Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Help me learn! with an explanation of these two functions.
Joins. Cool. Never heard of them before now but have started experimenting with them. What does this error mean? Error: cannot select orderid select orderid from orders, email where orders.orderid = email.orderid and email.checked='no' Column: 'orderid' in field list is ambiguous My query function syntax is: function get_order_numbers() { $conn = db_connect(); $query = select orderid from orders, email where orders.orderid = email.orderid and email.checked='no'; $result = mysql_query($query) or die(Error: cannot select orderidBR$queryBR.mysql_error()); while( $row = mysql_fetch_array($result)) { extract($row); $orderid = $row; return $orderid; } } What does it mean ambiguous? Cheeky error! Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -Original Message- From: 1LT John W. Holmes [mailto:holmes072000;charter.net] Sent: 5. marraskuuta 2002 16:59 To: [EMAIL PROTECTED]; PHP General Subject: Re: [PHP] Help me learn! with an explanation of these two functions. Your first function is only going to return one row of 'checked=no' records. The second function will only return one column of the result. What you want is a JOIN. You can do all of this with a single query. Without knowing the format of your tables exactly, I can't give you the syntax, though. Check the MySQL manual and read the chapter on JOINs. ---John Holmes... - Original Message - From: Steve Jackson [EMAIL PROTECTED] To: PHP General [EMAIL PROTECTED] Sent: Tuesday, November 05, 2002 9:50 AM Subject: [PHP] Help me learn! with an explanation of these two functions. Can someone run over these functions I have written to explain if my logic is correct. I'm still new to PHP and am trying to get my head round it! This first function is to collect a list of order numbers from my database where checked = no. Am I correct in assuming that the variable $orderid will be an array of results returned? How can I check this? function get_live_orders() { $conn = db_connect(); $query = select orderid from email where checked='no'; $result = @mysql_query($query); if(mysql_numrows($result)0) $orderid = @mysql_fetch_array($result); return $orderid; } This second function is to take these order numbers and compare them to order numbers in a second table and return the result of that. So if order number 11 is in the first array from the above function and there is a number 11 in the second query result I want to take all the data in that row and return it. function get_order_details() { $orderid = get_live_orders(); $conn = db_connect(); $query = select * from orders where orderid='$orderid'; $result = @mysql_query($query); if (!$result) return false; $result = mysql_result($result, 0, orderid); return $result; } I haven't actually run this yet but I'd like someone to explain to me what these functions will do so I am not just copy pasting code and hoping to get it right eventually! Probably I have written this wrong anyway and would like help before I actually attempt to do what I am after. I'll look back on this tomorrow so any help will be greatly appreciated. Kind regards, Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -- 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] Help me learn! with an explanation of these two functions.
Ok this is starting to get complex! (For me anyway) This is my function: function get_order_numbers() { $conn = db_connect(); $query = select orders.orderid from orders, email where orders.orderid = email.orderid and email.checked='no'; $result = mysql_query($query) or die(Error: cannot select orderidBR$queryBR.mysql_error()); while( $row = mysql_fetch_array($result)) { extract($row); $orderid = $row; $query2 = SELECT * FROM orders WHERE orderid=\$orderid\; $result2 = mysql_query($query2) or die(Error: cannot fetch orderBR$query2BR.mysql_error()); extract(mysql_fetch_array($result2)); } } The SQL works Ok. At least I get no errors now. It's my PHP to display the SQL I think I get a result of 8 errors with the following message. Warning: Wrong datatype in call to extract() in /www/u1255/eadmin/eshop_fns.php on line 40. Where line 40 is: extract(mysql_fetch_array($result2)); I am trying to display the message on another page using: ? include ('eshop_fns.php'); get_order_numbers(); $ship_name = $result2[ship_name]; echo tests and $ship_name; ? What does extract do? I am under the assumption it extracts row information so why a datatype error? Any pointers? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Help me learn! with an explanation of these two functions.
On Wednesday 06 November 2002 16:52, Steve Jackson wrote: Ok this is starting to get complex! (For me anyway) This is my function: function get_order_numbers() { $conn = db_connect(); $query = select orders.orderid from orders, email where orders.orderid = email.orderid and email.checked='no'; $result = mysql_query($query) or die(Error: cannot select orderidBR$queryBR.mysql_error()); while( $row = mysql_fetch_array($result)) { extract($row); According to your query it should return a single result (assuming your orderid is unique -- and it should be), and that single result contains a single field called orderid. Use print_r($row) to see exactly what it contains (good for reference and debugging). It doesn't contain a single result. It returns 16 order numbers (which is correct - 8 should be in the table emails with no checked and therefore the query has worked and pulled out 8 from the orders table also). What I want the function to do is say OK where the orderid's match pull out all the address details for each orderid and display what I want displayed accordingly. At the moment I get this array returned by using print_r($row). Array ( [0] = 100040 [orderid] = 100040 ) Array ( [0] = 100041 [orderid] = 100041 ) Array ( [0] = 100043 [orderid] = 100043 ) Array ( [0] = 100044 [orderid] = 100044 ) Array ( [0] = 100046 [orderid] = 100046 ) Array ( [0] = 100050 [orderid] = 100050 ) Array ( [0] = 100051 [orderid] = 100051 ) Array ( [0] = 100052 [orderid] = 100052 ) Where do I go from here? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Help me learn! with an explanation of these two functions.
My second query still doesn't return anything? Even with $orderid = $row removed as Jason suggested. This is my current function. function get_order_numbers() { $conn = db_connect(); $query = select orders.orderid from orders, email where orders.orderid = email.orderid and email.checked='no'; $result = mysql_query($query) or die(Error: cannot select orderidBR$queryBR.mysql_error()); while( $row = mysql_fetch_array($result)) { extract($row); //$orderid = $row; print_r($row); $query2 = SELECT * FROM orders WHERE orderid=\$orderid\; $result2 = mysql_query($query2) or die(Error: cannot fetch orderBR$query2BR.mysql_error()); extract(mysql_fetch_array($result2)); } } What I want the function to do is say OK where the orderid's match pull out all the address details for each orderid and display what I want displayed accordingly. At the moment I get this array returned by using print_r($row). Array ( [0] = 100040 [orderid] = 100040 ) Array ( [0] = 100041 [orderid] = 100041 ) Array ( [0] = 100043 [orderid] = 100043 ) Array ( [0] = 100044 [orderid] = 100044 ) Array ( [0] = 100046 [orderid] = 100046 ) Array ( [0] = 100050 [orderid] = 100050 ) Array ( [0] = 100051 [orderid] = 100051 ) Array ( [0] = 100052 [orderid] = 100052 ) Where do I go from here? Well, like I said in my previous post if you remove the line: $orderid = $row; then your second query *should* work. -- Jason Wong - Gremlins Associates - www.gremlins.com.hk Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Help me learn! with an explanation of these two functions.
Finally I have it! Cheers to all that helped. I was querying twice when I didn't need to and as Jason said not doing anything with the extracted information. This code works and displays data nicely. function get_order_numbers() { $conn = db_connect(); $query = select * from orders, email where orders.orderid = email.orderid and email.checked='no'; $result = mysql_query($query) or die(Error: cannot select orderidBR$queryBR.mysql_error()); while( $row = mysql_fetch_array($result)) { extract($row); if (is_array($row)) //print_r($row); { //echo tests and ; echo $row[orderid]; echo $row[ship_name]; } } } Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -Original Message- From: Jason Wong [mailto:php-general;gremlins.com.hk] Sent: 7. marraskuuta 2002 10:06 To: [EMAIL PROTECTED] Subject: Re: [PHP] Help me learn! with an explanation of these two functions. On Thursday 07 November 2002 15:15, Steve Jackson wrote: My second query still doesn't return anything? Even with $orderid = $row removed as Jason suggested. What exactly do you mean by doesn't return anything? a) Does the second query fail? b) Do you get any errors? If no to both (a) and (b) then your query succeeded. Now, your code below as-is does not do anything with the 2nd query results. You've only used extract() on it, which by itself is not much use, unless you use the variables that has been extracted. Read my previous post about what extract() does (and read the manual for heaven's sake) Also make liberal use of print_r() to see what values your variables contain at different stages of your program. This is my current function. function get_order_numbers() { $conn = db_connect(); $query = select orders.orderid from orders, email where orders.orderid = email.orderid and email.checked='no'; $result = mysql_query($query) or die(Error: cannot select orderidBR$queryBR.mysql_error()); while( $row = mysql_fetch_array($result)) { extract($row); //$orderid = $row; print_r($row); $query2 = SELECT * FROM orders WHERE orderid=\$orderid\; $result2 = mysql_query($query2) or die(Error: cannot fetch orderBR$query2BR.mysql_error()); extract(mysql_fetch_array($result2)); } } -- Jason Wong - Gremlins Associates - www.gremlins.com.hk Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* One Bell System - it works. */ -- 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 me learn! with an explanation of these two functions.
Of course you are correct. I forgot to remove the $row[orderid] etc.. I was just testing the function and thought I'd post the code rather than waste someones time answering me. However thanks for the help. Much appreciated. Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -Original Message- From: Jason Wong [mailto:php-general;gremlins.com.hk] Sent: 7. marraskuuta 2002 11:51 To: [EMAIL PROTECTED] Subject: Re: [PHP] Help me learn! with an explanation of these two functions. On Thursday 07 November 2002 16:28, Steve Jackson wrote: Finally I have it! sigh if this is your final code then you still don't have it ! Cheers to all that helped. I was querying twice when I didn't need to and as Jason said not doing anything with the extracted information. extract($row); You're still not gaining anything by using extract() ... if (is_array($row)) //print_r($row); { //echo tests and ; echo $row[orderid]; echo $row[ship_name]; ... the whole point of using extract() is that instead of using echo $row['orderid']; you could simply use: echo $orderid; -- Jason Wong - Gremlins Associates - www.gremlins.com.hk Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* Don't feed the bats tonight. */ -- 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] Globals set to off - Sessions
I am not sure what I have to do in order to control sessions in PHP 4.33 when globals are set to off. I used to use the following function to check if the user was of admin status; function check_admin_user() // see if somebody is logged in as admin and notify them if not { global $admin_user; if ( (session_is_registered(admin_user)) (isset($admin_user)) ) return true; else return false; } Then in my protected pages I would say; if (check_admin_user()) // if you're an admin user display the following { Session_register(admin_user); // Do admin functions } Else { //Do login form } How do I adapt the check_admin_user() function and the pages to work in 4.33? Thanks, Steve Jackson Web Development and Marketing Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php