Lassie
Members-
Posts
390 -
Joined
-
Last visited
Everything posted by Lassie
-
I am trying to debug a script that provides a download link from a shopping cart. The logic is: 1. pass the cart variables and the product id to a function which retrieves the download file reference from the database. 2.make an array of the results which is returned to a function which prints the link(s) and store them in a variable. This will be used to copy the file to a pick up folder. I am printing the links to establish that I have this part working correctly. The code is: //call the functions $dl_link=display_dl_link2($_SESSION['cart'],'product_id');result (links) are returned to $dl_link display_dl_link($dl_link);//print the links. function display_dl_link2($cart,$product_id) { foreach ($cart as $product_id => $qty){ echo "The value of $product_id is $qty<br />";//de-bug code: This gives values } // query database for the relevant file references book if (!$product_id || $product_id==''){ return false; } $connection = db_connect(); $query = "select dl_link from products where product_id='$product_id'"; $result = mysql_query($query); if (!$result){ mysql_error(); return false; if(mysql_num_rows($result)==0){ echo "there were no results"; }else { while ($row = mysql_fetch_assoc($result)){ echo $row['dl_link']; $dl_link = $row['dl_link']; } $result = db_result_to_array($result); return $result; } } } function db_result_to_array($result) { $res_array = array(); for ($count=0; $row = mysql_fetch_assoc($result); $count++) $res_array[$count] = $row; return $res_array; } function display_dl_link($dl_link) { if (!is_array($dl_link)) { echo 'No dl links currently available<br/>'; return; } foreach ($dl_link as $row) { $link = $row['dl_link']; echo "this is the reference $link"; } } What I get is the no array message - No dl links currently available. Can anyone suggest how I can find out what is going wrong?
-
Thanks for that it worked just fine. lassie
-
i'm tying to establish that my function is returning the right values, but my de bug line fails to print. Can anyone help please? code is function display_dl_link($cart,$product_id) { // query database for all details for a particular book if (!$product_id || $product_id=='') return false; $connection = db_connect(); $query = "select dl_link from products where product_id='$product_id'"; $result = mysql_query($query); if (!$result) return false; while ($row = mysql_fetch_assoc($result)){ echo $row['dl_link'];//print to establish record pulled from db } } Thanks, lassie.
-
Many Thanks Patrick, that worked. On to the next...
-
Hi, Thanks for that. If possible could you provide a few words of explanation. Specifically, What does the if statement mean/do? What is the difference between readfile and fpassthru? Would I expect to see a windows alert to save or download the file? Thanks, lassie
-
I am trying to make a folder identified by a hash code. When using the following I get a folder with the variable name and not the variable value. What am I doing wrong? Help please. This is the code <?php /* include ('book_sc_fns.php'); // The shopping cart needs sessions, so start one session_start(); //set the variables $email = $POST['email']; */ //create unique hash (email plus salt) and store in database.Values hard coded for testing. $email= 'blogsx@yahoo.co.uk'; $salt="nigel"; $hash=md5($email.$salt); include("misc.inc"); $connection = mysql_connect($host,$user,$password) or die ("$connection:".mysql_error($connection)); $db = mysql_select_db($database,$connection) or die ("$db:".mysql_error($connection)); $query = "Insert Into Customer (hash) Values ('$hash')"; $result = mysql_query($query); if (!$result) return false; //create temp folder with hash info //check if folder already exits if(file_exists($hash)) { echo "Dir exist"; }else{ mkdir('$hash'); echo "dir made"; } exit(); ?>
-
I am trying to build a download script and currently have a couple of building blocks to see how things work. The following two scripts are concerned with fetching a file and creating a download alert. At present when the link is activated all i get is a blank browser when I am expecting a windows alert to appear giving the chance to download or open the file. Can anyone tell me where I am going wrong? promt.php [code] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Prompt for download</title> </head> <body> <p><a href="test.php?file=test.txt">Download text 1</a></p> <p><a href="test.php?file=10steps.jpg">Download image 2</a> </p> </body> </html> [/code] test.php [code] <?php $nogo = 'Sorry, download unavailable. <a href="prompt.php">Back</a>.'; $getfile = ($GET['file']); $filepath = 'C:/Program Files/EasyPHP1-8/www/phpsolutions/images/'.$getfile; // check that it exists and is readable if (file_exists($filepath) && is_readable($filepath)) { // get the file's size and send the appropriate headers $size = filesize($filepath); header('Content-Type: application/octet-stream'); header('Content-Length: '.$size); header('Content-Disposition: attachment; filename='.$getfile); header('Content-Transfer-Encoding: binary'); // open the file in binary read-only mode // suppress error messages if the file can't be opened $file = fopen($filepath, 'rb'); if ($file) { // stream the file and exit the script when complete fpassthru($file); exit; } else { echo $nogo; } ?> [/code]
-
Ok. Will do Thanks.
-
Thanks for that guys> i will try and get my head around it. Incidently, I noticed that in my original set up register globals were set to on and in the new config they are set to off. I understand this has a security implication, but would it also be a cause of the warnings? If I turn register globals on would that cure it? lassie
-
I have just upgrade from mysql 3.23.53 to 4.1.9 and php 4.2.2 to 4.3.10 I have cart application that worked before but now gives me some warnings here is an example Notice: Use of undefined constant product_id - assumed 'product_id' in c:\program files\easyphp1-8\www\e_cart7\index.php on line 45 the code is //get featured books $connection = db_connect(); $query = "select * From products WHERE Featured='1' Order by cat_id"; $result = mysql_query($query); if (!$result) return false; $num_cats = mysql_num_rows($result); if ($num_cats ==0) return false; echo '<td>';/* set cell for contents within overall table*/ echo'<div id="contents">'; echo'<table id="contents" width="700" border="1" cellpadding="0">'; echo"<caption>Welcome to e-Books4U electronic Book store</caption>"; echo'<thead><tr><td bgcolor="gray" colspan="5" ><h6>This Months Featured e-Books</h6></td></tr> </thead>'; $i=0; $size=3; echo "<tbody>"; echo "<tr>"; while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) #38 { /* display picture */ echo "<td><a href='./images/{$row['pix']}' border='0'> <img src= './images/{$row['pix']}' border='0' width='100' height='80'></a></br>"; /* display row for each featured book */ $url= 'show_book.php?product_id='.($row{product_id}); [color=red]//line 45[/color] $title = $row['title']; do_html_url($url,$title); echo "ONLY</br>"; echo "£{$row['price']}</td>"; $i++; if($i==$size) { echo "</tr><tr>"; $i=0; } I have imported the database and as far as i can see that is ok. Can any one show me where to look please.
-
[SOLVED] Where to find a WAMP installer
Lassie replied to Lassie's topic in PHP Installation and Configuration
Hi, Sorry to be slow coming back - forced to xmas shopping! Your advice was good and it all now works.Many thanks. Not sure what u would like on the home page but this is the link http://www.easyphp.org/ Do you know this set up? Have a good xmas and thanks again lassie -
Thanks guys. I will give it a bash. lassie
-
Thanks I am thinking also that I will need to create a temporary download area to store the basket contents for the download rather than download from a storage area that has all the products. I have not stored the products in the database. This doesnt feel very elegant to me. Do you have any thoughts? lassie
-
I need to set up a download application as the backend of a shopping cart. I would like to email a link to the product and download from there. I would want the link to be secured to the users emailaddress in someway. Can anybody give me a starter for 10 on this one.What would a broad design encompass? lassie
-
[SOLVED] Where to find a WAMP installer
Lassie replied to Lassie's topic in PHP Installation and Configuration
Hi, Thanks for coming back. The config path in the phpinfo() says C:\winnt A search on that points to winntbtbu.dll The php.ini I have edited is in the Easyserv directory - C:\Easyserv\php.ini This is labeled as Configuration Settings. Should I change the path if so where? Thanks again for your help. -
[SOLVED] Where to find a WAMP installer
Lassie replied to Lassie's topic in PHP Installation and Configuration
Hi, Yes I have restarted the server and I still have mixed inormation from the phpinfo() and the php.ini file This is what the phpini() returns: sendmail_from no value no value sendmail_path no value no value short_open_tag On On SMTP localhost localhost sql.safe_mode Off Off track_errors Off Off unserialize_callback_func This is what the php.ini file says it has: [mail function] SMTP=213.210.25.37 sendmail_from=hawkesley_2jags@yahoo.co.uk ; For Unix only. You may supply arguments as well (default: 'sendmail -t -i'). ;sendmail_path = Apart from deinstalling and reinstalling I dont know how to proceed. I have tried dynamically setting the php.ini with this test: <?php ini_set("SMTP","213.210.25.37"); $to = "hawkesley_2jags@yahoo.co.uk"; $subj = "test"; $mess = "This is a test of the mail function"; $headers = "From:Hawkesley House<hawkesleyhouse@btinternet.com>\r\n"; $mailsent = mail($to,$subj,$mess,$headers); if ($mailsent){ echo "Test message sent"; } else { echo "There was an error"; } ini_restore("SMTP"); exit(); ?> I get the same error message. I thoughtr I would configure another pc and see if I can just get mail to work hence the question if you know of a differenr install to easyserv. Thank you for you interest. lassie -
[SOLVED] Where to find a WAMP installer
Lassie replied to Lassie's topic in PHP Installation and Configuration
Hi I have set the php. ini to reflect the SMTP server address(this is on the same remote server) as follows: ;;;;;;;;;;;;;;;;;;; ; Module Settings ; ;;;;;;;;;;;;;;;;;;; [Syslog] define_syslog_variables=Off [mail function] SMTP=213.210.25.37 sendmail_from=hawkesley_2jags@yahoo.co.uk ; For Unix only. You may supply arguments as well (default: 'sendmail -t -i'). ;sendmail_path = I am using a package from www.easyserv.com There is a strange aspect to the php.ini eeasyserv installs aconfiguration file php.ini and the settings above are taken from this. However, if I run phpinfo() the response shows no values for these fields. Therefore I was thinking of changing to a different package or maybe doing a manual install. If you have any views that would be welcome. Do you know of a package that comes with an email server? Thanks, lassie -
Thanks Ken I did spot that and changed it but it has made no difference. Is it right to assume that a straight forward installation of php will have the mail function? Does Pear have to be configured at all? Thanks if you have a view. lassie
-
Can any one point me to a good instal package for Apache 2.0 PHP 4.2 and mysql 4.0 I have an easyserv installation and am having significant mail problems and think I will try a different set up and see if the problem is replicated. Thanks
-
Thanks. I will try that.
-
Thanks to everbody who has previously tried to help me with this but unfortunately I am making no headway. My mail function refuses to work. I have set the php.ini to reflect my server address which is on the same machine and set the send mail from field. The settings are [mail function] SMTP=213.210.25.37 sendmail_from=hawkesley_2jags@yahoo.co.uk I have written a test script to check mail is working as follows <?php $to = "hawkesley_2jags@yahoo.co.uk"; $subj = "test"; $mess = "This is a test of the mail function"; $headers = "From:Hawkesley House<hawkeslehouse@btinternet.com>\r\n"; mail($to,$subj,$mess,$headers); if ($mailsent){ echo "Test message sent"; } else { echo "There was an error"; } exit(); ?> I have checked that the SMTP server on the machine works by getting it to send an email via telenet I get the following error Warning: Unknown error in c:\easyserv\www\e_cart7\test_mail3.php on line 7 There was an error I have looked at the php manual but cant find an obviuos clue. Can anyone help please. Is there a way to reveal the unknown error? Desperate for advice.
-
Does anyone have experience of sending mail to an SMTP server set up on a local windows machine. I have set my php.ini to the server address and put in a sendmail from address. my code is: $to = "me@yahoo.co.uk"; $subj = "test"; $mess = "This is a test of the mail function"; $headers = "bcc:adminxx@btinternet.com"; mail($to,$subj,$mess,$headers); I keep getting an unknown error.
-
Thank you for that. I dont follow the headers comment. None of my books ( I am teaching myself) mention headers. Can you give me an example or a reference I can follow. Thank you.
-
I am trying to send a simpleemail acknowledgement from a shopping cart application. I have set my php.ini smtp to my servers address and set the send from mail to a valid email address. I get and unknown error. The code is as follows: .......When your Cheque is received we will email you a download link or notify you of shipment</p></div></br>";//end of echo to browser. $to = "hawkesley_2jags@yahoo.co.uk"; $subj = "test"; $mess = "This is a test of the mail function"; mail($to,$subj,$mess);//line 30 The error message is: Warning: Unknown error in c:\easyserv\www\e_cart7\cheque.php on line 30 Can anyone help me debug this please.
-
Can anybody advise on the best way to create a drop down list a) to select a country b) to select a currency Should i use an array?