Jump to content

gizmola

Administrators
  • Posts

    5,945
  • Joined

  • Last visited

  • Days Won

    145

Everything posted by gizmola

  1. My advice to you is to use eclipse with the phpeclipse plugin. I tried the netbeans support for php about 6 months ago and unless things have really improved, I wouldn't recommend it.
  2. Just to summarize for you, cron, is a unix specific job scheduling system. It will run programs of any type on a particular schedule. Thus cron is a good solution for scheduling recurring jobs, like a monthly batch job. It is not a part of PHP, although php scripts can be set to run via cron. There are plenty of resources on how to set up cron. The primary way is to use crontab -e to edit the cron schedule. In the example of a script that is in webspace, cron can not call those scripts directly, because they are meant to be accessed by a web client using HTTP protocol. You can use wget or lynx or curl to accesss the scripts, but as they are usually not scripts that require webspace, the best alternative is to write the script in php and call it with the php command line interpreter. Make sure that you have this installed on your server, and that you can run it from a shell. You can test this running php -v. You should get output like this: [david@penny ~]$ php -v PHP 5.1.6 (cli) (built: Jul 16 2008 19:52:52) Copyright (c) 1997-2006 The PHP Group Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies Assuming that this works on your server, then you can use corbin's technique to call your php script from cron. That script can also be outside your web root, as stated by others.
  3. I wasn't aware of that, that's good to know. What would be the downsides or 'problems' with passing a handle to a function without setting it as a pass by reference? Usually it will be garbage/non functional after it's copied, because it's not the original handle anymore. I did mention serialization, but that is a bad example, because serialized handles will always be destroyed. If you think of a handle as a connection to something, it's easier to think about them that way. While you can use a connection to access something, the connection itself has no value. PHP calls this special variable type a "resource". There's more about them here -> http://us3.php.net/manual/en/language.types.resource.php
  4. Your script really needs to act as a client, submitting the form contents via a POST and then accepting the response from the server. This is quite complicated stuff. The best advice I have is to use PHP's curl integration. http://www.php.net/curl Basically what you would need to do: 1. Form posts either to itself or to another script 2. Use Curl to re-post to the target server 3. Curl will let you read the response data 4. Parse that into something you can use with simplexml or whatever other PHP/xml solution suites you.
  5. Off the top of my head, it's because by default PHP will set the character set of the page to be 8859-1. So you might try this at the top and see if that takes care of it: header('Content-type: text/html; charset=UTF-8') ;
  6. You have to understand that globals can actually have a purpose. For example, in your case you have a $conn that contains the handle to your mysql db connection. You can certainly do what gevans suggested, but if you do, then you will have to pass the handle variable explicitly to every function. Handles are special variables in that they can't be serialized or copied without issue, so you need to be careful that if you do pass them into functions, that you declare the variable to use pass by reference. So in Gevans example. you probably want: function Query ($q, &$conn) { $result = mysql_query ($q, $conn); if (!$result) {
  7. I don't think you understand what you've been told. A browser understands http protocol. In reference to html, the browser supports the rendering of html documents. Documents can have embedded elements like images, but the base html for those images is the img tag. The img tag needs to reference a source for the image --- namely a seperate url that indicates where the image can be located in web space. The client is responsible for integrating all the elements referenced in the html page and rendering them. So -- no you can't just read a blob out the database and display that. What you *can* do, is have a script that reads the image blob data from the database and returns that with the appropriate Mime header, as genericnumber1 suggested. You can then use the call to that script in a page. So--- you need to write a script that returns ONE image. The simplest manner would be using the get param as he illustrated. Let's say that the script is called: image.php. It would accept an image id, or something that can be used to find the data in the mysql database. You'd call it with : http://yoursite.com/image.php?id=5 Working properly, this should render the image in your browser. Once this is working, it's easy enough to have a page with as many images as you need: Image one! Image two! etc.
  8. You access object properties using the -> accessor. So something like this: $cart = $_SESSION['cart']; if (count($cart->contents) // empty
  9. Does it work if you have another page on your site? It probably has nothing at all to do with paypal. I hope you realize that the session mechanism requires cookies for this to work. The session mechanism needs to set a valid cookie for your site on the client, that has the session id in it. It sounds like the problem is that a cookie is not being set, so when the client returns from paypal, there was no cookie on the client to read.
  10. I glossed over your set question. Of course isset($_POST) returns true, because that array is created by PHP in a web environment, even if the array has no elements. In general I don't see the value of checking whether it has any elements, as usually you are looking for particular elements. One effective approach in that fashion is to call array_key_exists(). With that said isset() works fine for $_POST['myvar']. The problem is that often with html forms the elements exist (are set) but don't have a value, which is why others have advocated using empty(). Checkboxes are an exception, because in html, a checkbox causes it to exist. When a checkbox is not checked, it will not exist in the $_POST.
  11. Have you checked the permissions on the directories involved? Often this is caused by the web server not having the permissions it needs on one or more of the directories.
  12. You are on the right track, but missing a detail. The element that is selected needs to have that attribute set in the html markup as you indicated. A small mod similar to this will allow you to continue to work with your array and foreach loop. foreach($cast as $role => $actor) { $t = " if ($role === $_POST['dropdown']) $t .= ' selected'; echo $t . ">$actor\n"; }
  13. The pear convention (also used by the Zend Framework) is to have each class in its own file with the same base name as the class. You capitalize the first letter of the directory and class names. It is also important to understand the php include path. Typically you place your classes in a directory structure that is in the include path. Let's assume that the include path contains among other thing: '/var/httpd/mysite/include/' So you decide to create your own library, named for your site: MYSITE. And let's say that you create a utility class called Timer. Then you would have a structure like this: /var/httpd/mysite/include/Mysite/Utility/ Since everything up to the include directory is in the php include path, you can ignore it as far as naming is concerned. All that's important is that PHP can find and load those classes. And in the Utility directory, you would create your new class file name timer.php. Your class should then be named: class Mysite_Utility_Timer { } An autoloader as simple as this will now work for your classes: function __autoload($class) { $filename = strreplace('_', DIRECTORY_SEPERATOR, $class) . '.php'; @require_once $filename; }
  14. Probably has a bug in the code. Did you check the web error log? You could also try adding this code temporarily at the top of your script: error_reporting(E_ALL); ini_set("display_errors", 1);
  15. Whether or not a CMS is a help or hindrance depends entirely on the *features you need*. It's extremely important that you have such a list and focus on it. If the cms provides you the majority of what you require, then it may be worth the effort required to learn the ins and outs of the cms. You could also use a blog like wordpress or my personal preference Serendipity as the basis of your site. Blogs often have a lot of the features of that a cms has without much of the complexity. In your case, however, it does seem that the user and subscription features are something that will save you a lot of time and effort. You might also want to consider Joomla. Having in the past been project lead on a Joomla mod (Ponygallery) developing extensions to Joomla is completely feasible, although like anything requires a high level of development expertise.
  16. Well, 2 of those are CMS, and one is a blog (although the difference between blogs and CMS is often fairly minimal). Between Drupal and Joomla, flip a coin. Either one has the features you require. They both have a learning curve, but also have extensive documentation and community support. I'd suggest you visit each site and take a look and see which appeals to you. You can also visit http://opensourcecms.com In particular, since your assignment involves a custom template, you will want to investigate template development and customization for each. In a nutshell, the general consensus is that Drupal is much better architected, while Joomla is more feature packed, primarily due to the extensive number of mods available for it. For your assignment I don't think this will be relevant to you at all.
  17. One consideration for this is what version of PHP you are using. If you're using php5 then all objects are passed by reference. In PHP4 this was not the case. Hopefully you're using PHP5. If it's appropriate for your application to be dealing with objects then you should be using them. Only you can answer that question. For example, if you have a factory class that creates objects, then it would be a very poor design if it did not in fact pass back the object it had manufactured.
  18. You need to read up on PHP Arrays and learn the basic syntax. I've illustrated a variety of techniques in this thread, but it's not going to help you code if you don't understand what I'm doing. This code should be pretty close to what you asked for, although it might have syntax issues. $query = "SELECT * FROM $dbBiographyTable WHERE approval = 1 ORDER BY title ASC"; $result = mysql_query( $query ) or die ( "Error on db query biographies.php" ); mysql_close( $session ); $num_rows = mysql_num_rows( $result ); if(mysql_num_rows($result) == 0) { echo("Nothing to Display!"); } else { while($row = mysql_fetch_array($result)) { $rows[] = $row; } } foreach($row as $value) { $title = $value['title']; $namesarray[$title[0]] = array('title' => $value['title'], 'id' => $value['id']); } foreach($namesarray as $letter => $title { echo " " . "$letter" . " "; foreach ($title as $value) { echo '' . $value['title'] . ''; } } [\code]
  19. There are a lot of different possibilities here. Usually you need to go into your web logs and look for the attacks. We really don't have enough information or access to your site, so there's no much we can do to help you.
  20. yes, did you look at the php rand() function?
  21. No, hehe. All you need to do is take the code where I make the $names array. Instead of a static definition of the names, you replace that code with your mysql select and fetch loop, only inside each fetch you simply get the name and add it to the names array. Something close to this should work: $namesarray = array(); foreach(range('a', 'z') as $value) { $namesarray[$value] = array(); } $names = array(); $query = "SELECT * FROM $dbBiographyTable WHERE approval = 1 ORDER BY title ASC"; $result = mysql_query( $query ) or die ( "Error on db query biographies.php" ); mysql_close( $session ); $num_rows = mysql_num_rows( $result ); if(mysql_num_rows($result) == 0) { echo("Nothing to Display!"); } else { while($row = mysql_fetch_array($result)) { $names[] = $row['title']; } } foreach($names as $value) { $namesarray[$value[0]][] = $value; } foreach($namesarray as $letter => $names) { echo "$letter \n"; foreach ($names as $name) { echo "$name \n"; } }
  22. Yes. Concentrate on getting your login system going, which is non-trivial. If a user should not be able to access a url unless logged in, then this needs to be handled in your authentication logic, which is typically done with an include at the top of the script, or in a class you create for the purpose.
  23. Yeah it's because the way you have coded, you only print out a title from the db if it happens to have the same first letter as the letter in the range that matches the value of $i, which you increment every time a row is read from the database. The two loops (one to produce the letter headings, one to fetch rows from the result set, have nothing to do with each other, and it's just happenstance that the first two rows have names that start with A and B respectively, so you get a match. There is no way to make that structure work out. You could fix this in a number of different ways, but what I'd suggest is this: $namesarray = array(); foreach(range('a', 'z') as $value) { $namesarray[$value] = array(); } $names = array('alan', 'bill', 'bob', 'dan', 'david', 'fred', 'henry', 'niamh', 'tim', 'tracy', 'zoe'); foreach($names as $value) { $namesarray[$value[0]][] = $value; } foreach($namesarray as $letter => $names) { echo "$letter \n"; foreach ($names as $name) { echo "$name \n"; } } The output of my test script is this: [david@penny ~]$ php rmerge.php a alan b bill bob c d dan david e f fred g h henry i j k l m n niamh o p q r s t tim tracy u v w x y z zoe So hopefully you get the basic idea -- fill in an array during the fetch loop. When you exit it, you're ready to output the list. Add the html you need, as my command line test couldn't use html. So basically $names was just used as a substitute for your result set.
  24. Did you try something like this? $insertSQL = sprintf("INSERT INTO job_details (uid, job_id, job_no, country, eng_name, status, `date`,) VALUES (%s, %s, %s, %s, %s, %s, %s,)", GetSQLValueString($u_uname, "text"), GetSQLValueString($_POST['job_id'], "int"), GetSQLValueString($_POST['job_no'], "text"), GetSQLValueString($_POST['country'], "text"), GetSQLValueString($_POST['eng_name'], "text"), GetSQLValueString($_POST['status'], "text"), GetSQLValueString($_POST['date'], "date")),
  25. Thanks for your advice on HEREDOC, I'll try to implement it. As for the third party script section, I did not know that such forum existed. Sorry about that. Is there a way to "move" this topic to that board? Getting back to the issue, I understand that there is a significant difference between COD and PayPal in terms of data exchange, but the information that I'm missing originates from my side and PayPal server does not alter any. Therefore, I should be able to simply retrieve it and print it out, as in the COD case. That's all I want to do. Thanks again I can move it there, so I will do that if this goes on further. In answer to your question this code starting at line 49 or so is where all the calculation occurs. / load the before_process function from the payment modules $payment_modules->before_process(); require(DIR_WS_CLASSES . 'order_total.php'); $order_total_modules = new order_total; $order_totals = $order_total_modules->process(); So for whatever reason, $order_totals, which is expected to be an array of strings, apparently is empty when it processes. The code for the order_total class is in order_total.php, which you didn't include. As oscommerce appears to be a rats nest with a mindboggling number of global variables it is relying on, again the most logical explanation is that there's something happening inside the factory class that's different when it's paypal. Again glancing at the paypal script, there are calls being made and files being generated and all sorts of stuff that could fail due to simple things like permissions or php.ini settings that prevent the use of fopen().
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.