Jump to content

gizmola

Administrators
  • Posts

    5,960
  • Joined

  • Last visited

  • Days Won

    146

Everything posted by gizmola

  1. 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?
  2. 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.
  3. 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.
  4. 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.
  5. 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?
  6. 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.
  7. 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.
  8. 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.
  9. 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.
  10. 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'
  11. 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.
  12. 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.
  13. 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)
  14. What does the database structure look like?
  15. 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, "/");
  16. 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.
  17. 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.
  18. 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
  19. 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.
  20. 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') ;
  21. 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) {
  22. 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.
  23. You access object properties using the -> accessor. So something like this: $cart = $_SESSION['cart']; if (count($cart->contents) // empty
  24. 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.
  25. 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.
×
×
  • 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.