Jump to content

gizmola

Administrators
  • Posts

    5,945
  • Joined

  • Last visited

  • Days Won

    145

Everything posted by gizmola

  1. Ok, I looked at this real quickly, and it appears you are going to continue to run into resource problems on your host. I noticed you have this small piece of code --- if($margin_num==0) { } else {mysql_query("UPDATE BOOKS set `price` = $margin_num WHERE `isbn` =$item", $db);} Is the purpose of this to check for margin_num and update that where needed? If so, why are you not simply querying that directly. You also could probably construct and update entirely in SQL.
  2. php Version difference? If you look at the manual page for this, there's a warning: The behavior of array_merge() was modified in PHP 5. Unlike PHP 4, array_merge() now only accepts parameters of type array. However, you can use typecasting to merge other types. See the example below for details. So you may need to cast both params to array() to insure that it actually works.
  3. Thorpe +1. I agree entirely -- if all you want is the count, then just do the count in the db. Only do the loop if you actually need the individual post row data for something else on the page.
  4. Well one other potential issue: your query might not be working. You should test that independently --- print_r() is your friend when debugging.
  5. Yes I do. It is because you are not doing the assignment you think you are. What you want to do is $array[] = $row['posts'];
  6. No problem, I think you will find it's easy to use, and I would recommend going with all aspects of it initially, including their templating. Where I worked, we had a highly modified version of it, with Smarty built in, and a lot of the suppossed features of the thing were unusable due to all the hacking that went into it.
  7. I will go you one further on the error: If you actually *read it* you will see that it is trying to connect as a user with NO PASSWORD!
  8. This is a pretty simple set of requirements. You need a routine that queries the database and determines whether they have met the criteria or not. Since you brought it up --- what database structure have you arrived at for storing the "marks" By marks, I assume you mean grades? So the idea is: Student Table --- Where 1 student can have many Grades? Usually, there would also be a course table in there, so you could have the same student take many courses, but maybe you don't need that.
  9. Frameworks (smarty isn't one by the way) are not just a trend. For larger projects, if your not using one of the existing frameworks your going to end up pretty well writting your own anyway. May as well start with a good solid base. Ok, one last question. Do you suggest any one over the other? The only 2 frameworks I'm aware of are Zend and CakePHP.... I'm still trying to understand the difference between a framework and a templating engine like Smarty... A couple of general comments: 1. When dealing with performance you *MUST* have a tool that helps you profile. As you already indicated, somehow you are doing more *queries* which has nothing to do with OOP. But in general, you need to have some tool that lets you isolate things and do timings to know what is taking up time. 2. Is PHP OOP slower than not procedural code? Yes, although the overhead especially in PHP5 is marginal. Would the use of Oop vs. non-oop be noticeable on a human perception level? No. For most developers the reason to use OOP is that it lets you write better more reliable and functional code. Often it would be near impossible to write and maintain a large non-oop system without global variables and spaghetti. Not that oop is a panacea, but it does offer things specifically designed to make code modular. I will make a comment on your use of autoload. Autoload does not come without a price. The price may be minimal, but if you don't absolutely need autoload, you are better off implicitly doing require() statements at the top of your scripts. In regards to PHP/Mysql frameworks: The big 3 right now in my opinion are: -CakePHP -Symfony -Zend Framework Each takes a different philosophy. Symfony was designed to provide and compete with the benefits offered by Ruby on Rails. What it does it does really well. It offers the most holistic package of features in a framework. With that said, you really have to use it the way it was designed, and there's a lot of black magic in there. People either love or hate the yaml configuration stuff for example. We found there were some things that didn't work the way we wanted, and figuring out what to do when we hit the wall, involved just reading the code, and some of it wasn't very modular. You have to invest time in looking at all the seperate projects they used to cobble it together and understand those individually. CakePHP is the oldest of the three, and has a great community. It does offer a lot of the same benefits as Zend Framework and symfony but it was originally developed in PHP4 whereas Symfony and Zend are PHP5 only. It is the only framework that I don't have direct experience with, so I don't want to discount it out right without having tried it personally. Zend framework is the newest and is just starting to hit its stride. It is the only one that had the design goal of offering a library of components as much as a framework. Probably it's the one I would use right now, but it still is evolving. Expect a learning curve that includes reading code. The documentation is ok, but often will have an example that scratches the surface and really doesn't show you what you want to actually do with it. Despite the "Comes from Zend" (not really true, it comes from various people in the PHP community but was partially financed by Zend) it does represent the best practices of PHP and PEAR.
  10. If you do a forum search I recently answered a question that involved cron that has some information in it. Just to be clear, your cron job would be a daily job, so you'd set it up to run once a day. It would run a script that would need to query your phpBB database and use the joined date, and send the email. It might also require some other query criteria. You would write a CLI php script that would connnect to your mysql database and query the ppBB user table using the date criteria you need. There's also an article on my blog about doing date arithmetic that will probably help with the aging. http://www.gizmola.com/blog/archives/51-Exploring-Mysql-CURDATE-and-NOW.-The-same-but-different..html Off the top of my head the table is named phpbb_users (the phpbb_ prefix is something you set when you install but most people don't change the default). From there you should be able to get a result set, and cycle through the list using the php mail() command. One thing I will warn you about -- make sure that you have your email server stuff in order and it is probably best if you have the mail sent from that server. What i mean is that, these days unless your mail server is "legitimate" which means at very least that it has a valid reverse dns lookup, an mx record, and an SPF entry, you will find that your attempts to mail from your server directly will result in a lot of bounces if not outright refusals. Also for efficiency sake it's best if you send the mail in an MTA and have that handle the sending, since they all handle resending and retrying mail that can't initially be delivered. Otherwise, what you want to do is a relatively simple job. The only thing I didn't address was the question of how individual rows would be "marked" as you indicated.
  11. I don't see anything off the top of my head, but I also don't know what's in your database initially. Are you sure that the value of votes in the screenshot table is 0 when you start and not 1?
  12. If that's true then I would think there is a logic error in your scripts where the query is being run 2x rather than once.
  13. That can't really be done because sessions use cookies, and the cookies are relevant to the domain. You could set up a hack where you pass the session ID as a url param, and then write some custom code, but this will open up a whole can of worms, and also leaks the session ID into the urls, which will then be pasted by the users into the links leading to people attemting to session hijack other users. Bottom line: you need to explain to the clients that their desire is incompatible with the technology platform being used. There are solutions to these problems if the user wants them bad enough -- for example, consider something like an ID server that all the sites in the network utilize to provide identification. This could be used, and as long as all the web servers in the network use the same session storage (this could be memcache, or an NFS mounted volume) you could construct a work around, but it is by no means a small job. If they want it badly enough, will accept the recoding and probably substantial reworking of security code, you can get this to work.
  14. Oh yeah, I guess I should say that your code is basically correct, but you are making a table every loop which is of course the main problem. Only make the table once. Otherwise, your code does what I described.
  15. You have this line of code: $r(10,30); That doesn't mean anything out of context. If you had this: $r = rand(10, 30); Then it might make sense. Anyways, I've given you the solution to your problems and identified what is going wrong for you. Do you understand the answer I provided?
  16. That code is javascript. Hence it runs on the client. If it's satisfactory for your solution, you could code using javascript and use the DOM to hide the form and display a box indicating that cookies are required. If you want to do a serverside solution, then it's more complicated. To understand why you need to understand how cookies work. When the browser makes a request the server sends a response to that request. Client Request -> to Server Server Response -> to Client Since this is the HTTP protocol, in each case the sender includes an HTTP Header, which is some control data. Cookies (either the cookie data itself, or the request from the server to set a cookie, go in the Header. So as you can see, the first chance the Server has to tell the Client to set a cookie, is when it responds to the client's request. So for the server to actually determine whether or not the client actually set the cookie, the server needs the client to make another request. How can it do that? It can tell the client to redirect to another page (which also goes in the header usually via the "Location:" header. THere are various approaches to this. One of the best in PHP is to use PHP's built in session capability, with sessions configured to use cookies. What you can then do is have some generic session code on your site that sets/checks session variables. You can use this to set a session variable that indicates that cookies are working for that user. This takes some planning because you don't want to send the client off in an infinite loop, so you typically use a url param like ?cookiecheck=1 Pseudocode of this: 1. start session 2. check cookie value. If value not set AND $_GET['cookiecheck'] == 1 display an error -- sorry client you need cookies or this doesn't work 2a. else start session, set session cookie value (perhaps $_SESSION['cookiesok'] = true; and redirect to SELF appending ?cookiecheck=1. HTH.
  17. This is not a thread conducive to anything productive at the moment. To the OP, I would say this: Rather than venting, which is fine once and a while, but will not help you address issues with your website, why not instead post a link to it and request people to review it and make suggestions? That might help you begin to understand what your underlying problems are.
  18. The test script is using some sort of technique to track the user's progress through the quiz. Without understanding it there is no way to help you understand why it's broken. We need the source code for the quiz script.
  19. Use variable names that actually mean something. I can't understand your code because you've omitted important details like where you get the random value. Off the top of my head, the first issue is that you have the statement inside the loop. You only want one table, so you should emit that table tag first. Then you need 2 loops Outer ( 1 - $x Will print the tag) Inner (1 - $x will print x) After the inner for loop, you print the end tag.
  20. There is no reason to grab the vote count, when SQL already solves this problem for you. Try this: UPDATE screenshots SET votes = votes +1 WHERE id = '$id'
  21. Those are not errors, they are warnings. A warning *could be a problem* but it might not be. As it's unlikely you are going to patch a 3rd party script that you don't understand the simplest answer for you is to turn down the error setting so that the server does not display warnings, and furthermore, on a production server you should not be displaying errors to the end users, as this can leak important internal information to attackers. In the case of your warnings, most if not all of them appear to be related to uninitialized variables. Since this appears to be related to a shopping cart, it's not surprising that you would have uninitialized variables because nothing is in the user's cart yet. This is a nice blog entry that covers the topic: http://wheel.troxo.com/2007/06/21/php-error-reporting-on-production-and-development-servers/ They are doing the settings in .htaccess but you could do them in the php.ini directly assuming this is a server you control and admin.
  22. First off, all I did was use a sql select from the mysql command line. If you used the same select and fetched the data and displayed it, you will get the same results. The 2nd issue with that structure is that you have a mix of two things: 1. Owner 2. The Unit owned What you really want is 2-3 tables. At minimum with a 2 table setup what you want is Owner - Where you have an Owner table and a Unit table related 1 - M (One Owner can have many units). Depending on what the application needs to do, what your current structure can not do right now for example, is to query and find which owner owns a unit in any sensible way. Sure you can do "%$unit%" but try that for '1-1' and then question why you also get '1-10' and '11-1' in your results! Not to mention that no indexes can ever be used in a %% like query. Well, the rest, as they say is up to you. You can attempt to code around the eggregiously bad structure, or you can restructure to something that will make development sensible and provide functionality. What's most prudent really requires your input.
  23. Also, given your test data, order by works fine: mysql> select * from ts order by addy; +-----------------------------------------------+ | addy | +-----------------------------------------------+ | 1-1 Markman | | 1-13 Duane son | | 1-2 Depend Service | | 1-3,1-9,1-11 Sayer P Sawyer | | 1-5 K Manage | | 1-6 CSJL John Law | | 1-7 Diagnostic Systems Ron | | 1-8, B-12, B-13 Sky Skan | | 2-1, 2-2, 2-3, 2-4, 2-5, 2-6, 2-8 Sempco Dong | | 2-7 Wameist Group, L Bradley | | 3-1 akumi Studio Ric Cruze | | 3-10 wilight LLC | | 3-2, 3-11, 4-1, 4-3, 4-8 TwoOne Manufactur | | 3-4, 4-4 WHOB Mario | | 3-6 Systems, Inc. | | 3-7 Collins Precision | | 3-8 LTeagu | | 4-2 Joseph Joseph | | 4-5, 4-7 Quailty P Inc | | 4-6 Robert Robert | | B-1 R Machine | | B-10, B-17 Three Machine | | B-2 D.L.R370 | | B-4 , B-5 Joyce H Anthony | | B-9, B-11, B-14, B-16 Joseph KJKal | +-----------------------------------------------+ 25 rows in set (0.00 sec)
  24. In some browsers, you can have problems if you don't set the path for the cookie. If it's for the entire site, then the path should be set as '/'. Also, why not be extra safe with the time and make it 30 days in the past. So I'd suggest: setcookie("pi", "PI-1234456832", $expire, "/"); and to clear setcookie("pi", "PI-1234456832", -2592000, "/");
×
×
  • 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.