Jump to content

gizmola

Administrators
  • Posts

    5,945
  • Joined

  • Last visited

  • Days Won

    145

Everything posted by gizmola

  1. Unless the mobo requires paired sticks, it doesn't matter. My caveats being: if this is a 32 bit machine/ os, there's no point in having more than 4 gigs since they can't be addressed.
  2. While that may be true, it wouldn't effect the insert because it is properly delimitted as a string constant using the single quotes.
  3. We would need to see the code that is displaying the cart.
  4. You might also want to take a look at using the zend framework for this. One reason is that a single block of code will allow you to generate both rss and atom format feeds. Here's code from a working feed that shows you everything you would need to know. I've pulled out various specific queries and things, but the skeleton could be easily used to implement your feeds. /* * * Feeds.php * Parameters: name= name_of_feed (feeda | feedb | etc) * format=atom | rss */ require_once('Zend/Feed/Writer/Feed.php'); function addEntry($writer, $entryData, $entryDescription) { $entry = $writer->createEntry(); $entry->setTitle($entryData['title']); $entry->setLink(SERVER_URL . 'link to the full item id=' . $entryData['some_id'] . '&action=view'); // must supply a non-empty value for description $content = !empty($entryData['content']) ? $entryData['content'] : "N/A"; $entry->setDescription($content); $entry->setDateCreated(time()); $entry->setDateModified(time()); $entry->addAuthor($entryData['author'], $entryData['email']); $writer->addEntry($entry); // manual addition post-creation } function loadFeed($writer, $query, $entryDescription) { // your query here then loop through results calling addEntry and passing data if ($result) { foreach($result as $row) { addEntry($writer, $row, $entryDescription); } } } $format = isset($_REQUEST['format']) ? $_REQUEST['format'] : 'rss'; if (!($format == 'atom' || $format == 'rss')) { $format = 'rss'; } $name = 'something'; // get from request or $_GET // get the name of the specific feed, in case you have multiple different feeds you want to generate. This is a junction box where you can use this one feed script // to generate the feeds for different sources of data in your site. // Connect to db Your db connection stuff needs to be done here in someway, or files read or whatever the data source is for the feed switch ($name) { case 'feeda' : $name = 'feeda'; $title = 'this is feeda including the latest feeda entries!'; $description = 'Feeda description here... blah blah'; $entryDescription = 'this is a feedA item'; $query = "SELECT a, b, c etc. FROM sometable etc."; break; case 'feedb' : default : $name = 'feedb'; // etc. "; } $url = 'http:.. yoursite/'; $link = $url . "feed.php?name=$name&format=$format"; $writer = new Zend_Feed_Writer_Feed; $writer->setTitle($title); $writer->setLink(SERVER_URL); $writer->setFeedLink(SERVER_URL . $link, $format); $writer->setDescription($description); $writer->setDateModified(time()); //Atom needs this loadFeed($writer, $query, $entryDescription); echo $writer->export($format);
  5. When you use an aggregate function it takes all the rows in the group and applies the aggregate to them. In the case of SUM() and your example data: Air Stairs | 15 Air Stairs | 09 One would expect that the sum(slides) will be 24. You can't nest aggregate functions as that doesn't make sense. MAX() simply returns the largest value in the max'd column. Adding the Rollup is simply going to give you one more row where all the rows will be added together. As fenways stated... what are you trying to do?
  6. The values of the variables clearly are not what you think they are when the calculation occurs. Everything else is fine. $mem_tot_gold = 1895462; echo "mem_tot_gold: $mem_tot_gold\n"; $tot_gold = 157657698; echo "tot_gold: $tot_gold\n"; $stake = number_format(($mem_tot_gold/$tot_gold)*100,2); echo "$stake\n"; PHP 5.3.1 (cli) (built: Nov 20 2009 18:18:28) Copyright (c) 1997-2009 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2009 Zend Technologies [david@benji ~]$ php -f pmath.php mem_tot_gold: 1895462 tot_gold: 157657698 1.20
  7. We don't have enough information to go on here. Were there any errors in any of the logs?
  8. Where is your code? Also, instead of "thinking" use var_dump() and then you'll know what is in $output, as i previously suggested.
  9. Do you know about the var_dump() function? You might find it helpful to understand what you've got in your variables at various places. I don't really understand your most recent question. Curl acts like a client/browser and gets exactly what a browser would get --- the html code for the page requested. I assumed from your original question you know what the data is that you want.
  10. That code in no way answers the question about how to do what you asked for.
  11. The most common solution in the open source world is to integrate the free version of the jwplayer. http://www.longtailvideo.com/ You install it on your server, and have it emit the necessary embed code and you'll have your flash movies playing in no time. There is support for how to accomplish this on their forums.
  12. These days, people would do something like this with javascript, by hiding/unhiding divs. This supposes I guess that all your content is static. If that's the case I have a hard time understanding why you would want to load up a giant page just to prevent a small amount of traffic back and forth. My recommendation would be to look at jquery() as writing the code to do this, even if you have only a beginners understanding of javascript. jquery also supports ajax and makes it trivial to implement, which is another alternative to doing requests, but for what are in essence full pages, I still don't see the point.
  13. If you're not storing the information about orders in any way, how do you expect to figure out what the next order number should be?
  14. include() does a pretty good job, and you can simply use a naming convention and some simple functions that support finding the right files by naming convention, and supporting the idea of loading of partials inside a template. A couple of simple wrappers around include, that use PATH variables to make sure that the inclusions are safe, and you'll have a lot of what you need. There's also tried and true template libraries like those available in zf (Zend_view), in PEAR and that oldie but goodie smarty. They each have a point of view and a reason for being, so it very much depends on what your goals are.
  15. One typical way of handling this is to have your insert_events.php form action point to itself. The best way is probably to do a basename(__FILE__) call. You should have some code that checks state at the top, to insure that the method is POST and that any required columns are filled in correctly. If all the criteria is met, then you do whatever is required to actually insert the data. If all goes well, then do a simple header('location:...') call to your view_events.php script. The important thing is that you can not call header if you've output anything, so as long as your script does not echo anything, you'll be able to call header and redirect at any point. It is very important that immediately after the header() call you exit the script! Many people have neglected to code for this, and people trying to exploit your site will use tools that for example, will not honor the redirect (since it's a client side activity) and it's possible that your code can progress past the redirect into an area that you did not intend to execute. Otherwise, there is not much else to this -- very simple. In a nutshell: if (//check that the method was POST, and check for any required columns, format of data etc.) { // Do your insert code here. If all is well... header('location: view_events.php'); exit; } else { // Output form target }
  16. There's actually 2 issues. The first is that the expand doesn't work because initially the display property is null. You can see this if you stick an alert at the top of the function. You can fix that by adding an: || document.getElementById(element).style.display ==''' And your expansion would work fine. However, you will never get collapsing to work, because on collapse your function would: -set display to = 'none' - then immediately set it back to 'block' (2nd if in function). The if then else is the logical approach to making this work.
  17. I have written a couple of blog posts that cover mysql date and datetime types and calculations in detail. They might be helpful to you. http://www.gizmola.com/blog/archives/51-Exploring-Mysql-CURDATE-and-NOW.-The-same-but-different..html http://www.gizmola.com/blog/archives/99-Finding-Next-Monday-using-MySQL-Dates.html One other thing I can add is that you can use BETWEEN with mysql as an alternative to the > and
  18. I find it helps if you understand the way browsers work in regards to the HTTP protocol. You might want to read up on that a bit. In a nutshell, PHP is "serverside". PHP is for all intents and purposes, the same thing as the web server. The browser makes requests, the webserver returns HTML. The HTML may specify other parts of the HTML page like images and javascript and css files. All the server does is send those things when requested. It is the job of the browser to parse the html, take all the components and assemble them into the page that gets displayed. This is all done "clientside". To be totally clear, once the server has sent what was requested, it immediately closes the connection with the client and goes on to process the next request, if there is one. So when you consider this flow, it should be clear that the client initiates these conversations by making requests and the server only answers. The last few years, it has become common for applications to utilize javascript, thanks in a large part to the emergence of cross-browser compatible libraries like jquery. Any interactivity on the client that doesn't involve a plugin (flash or java) are created through javascript. This code runs clientside, meaning it is delivered by the server as source code, and it's up to the browser to interpret and run that code. Via javascript you can implement a rich UI where you add or modify elements on the fly, and handle client events like keypresses and mouseclicks. If the application requires communication with the server, you can utilize ajax, which is a feature of javascript that allows a persistent connection to be made from the javascript code running in the browser, to a server. It sounds like your feature might require the use of ajax. The implementation details for ajax connections differ between browsers, so again using a javascript framework like jquery is highly advisable. The ajax will let you respond to an event, make an ajax connection to the server, and allow the retrieval of data in a variety of formats (typically either xml or json). The javascript code can then dynamically modify the rendered html page. This still requires a serverside (PHP) script which, given pertinent input, will return the appropriate data. So the answer to your question is: there is both javascript (DHTML and Ajax code) AND serverside PHP code required. Since you're clearly new to this, I would suggest you google some jquery tutorials and start there.
  19. Sure, most applications, especially ones that store data in a database, require a config file that sets variables like the name of the database, username and password. Just creating a config file is probably not enough. Some applications will setup things for you through a user interface they provide, however, permissions need to be set so that the file in question is writeable by the web process. This is non-trivial if you don't understand permissions. It is possible that your current gallery package has that, but in any case there should be some documentation for the format of the config file somewhere.
  20. safe() was the function that you had included in your original code snippet. That function stripped out a lot of email headers that you would not want someone injecting. My code assumed that you would use that function, since you already had it in your code, even though you were not calling it. If you place that function back into your code as it was previously, things should work fine. Just to be clear, the function I wrote is not tested. I just typed it in off the top of my head, so you should do some simple testing on it.
  21. eregi is simply doing regex pattern matching. You don't need a regex here, because all your code was doing was looking for the newline. Here's a simple (but untested) function that might help you figure this out. function checkEmailField($emailField) { $emailField = trim($emailField); // Add anything to this array that you consider to be bogus $check = array("\r\n", "\r", "\n", "\t", ","); foreach($check as $ch) { if (strpos($emailField, $ch) !== false) { // Bad character found return false; } } return true; } You would use this at the top of your script, and have code like this: if (checkEmailField($emailer) && checkEmailField($name) && checkEmailField($company)) { // Passed basic checks $emailer = safe($emailer); $name = safe($name); $company = safe($company); // Do rest of your email code here } else { die('Invalid Input'); }
  22. So originally, the code attempted to look for tampering back matching on the inclusion of a "\r\n". If those characters were included the assumption is that there was tampering, and you had a die(). Then you made it so that there had to be a "\r\n" in all of 3 variables. That is definately not what you want. You don't want to use && (AND) but rather use || (or). So here's my points: 1. There's no reason to use eregi for this, when you can use the much faster strpos() to try and find the characters. 2. You don't stop someone from including a list of hundreds of emails, seperated by commas.
  23. When you use foreach, you specify the variables that will receive the name of the array key, and the value of the array element. foreach (array as $arraykey => $element value) You are echoing out the key, rather than the value. If you change your echo to: echo "POSTED: $checkRows = $hip \n"; I think it will be clearer to you.
  24. There's lots out there, you just need to google. This is an oldie but goodie --- lots of functionality, used by many people. http://coppermine-gallery.net/
×
×
  • 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.