Jump to content

gizmola

Administrators
  • Posts

    5,945
  • Joined

  • Last visited

  • Days Won

    145

Everything posted by gizmola

  1. Please copy and paste the exact script here. Do not omit or edit anything. I took the script you provided, made the edit i recommended and created the table last night. There is something that doesn't match up if you're getting an error.
  2. So this means you don't understand it? How will doing anything in javascript help you with this situation? That code makes it very clear: if the form has no price filled out, it will not get to the shipping code. Why don't you try commenting out that if -then block and see what happens. You might be surprised. If you're really this befuddled with the simplest of code, I don't know what you hope you to gain from posting these sorts of questions here. It also doesn't help you at all when you claim to write code you didn't write. I looked at your previous posting history and my suspicions were confirmed within 10 seconds.
  3. NSERT INTO `7stat` (`usrid`, `date`, `num`, `hits_delivered`) VALUES That line is incomplete. I thought you intentionally removed some of it for some reason. There is nothing left of value there, just delete the line.
  4. Javascript runs "clientside" in the user's browser. PHP runs on a server. Right and test a php script that accepts the values you require for the mysql insert. Be sure that you have error checking, and the same type of security you would have if this was going to be a form submission via post. In other words, there is nothing magic about javascript that makes it more secure and less prone to tampering or malicious input. Yes I'd suggest you use jquery. This may look confusing to you as a php programmer, due to their use of $. Forget that php uses $ for variables. jQuery is constructed as one giant class named jQuery, and the $ is an alias for "jquery". So when you see: $.post("test.php", { name: "John", time: "2pm" } ); Keep in mind that this is the same as: jQuery.post("test.php", { name: "John", time: "2pm" } ); Take a look at the examples on http://api.jquery.com/jQuery.post/ and see if you can figure out what you specifically need to do. jQuery can also be of help with what you'll need to with the like button itself, as it will help you grab the button click and execute the wrapper function you'll need. This should explain it very simply: http://www.learningjquery.com/2008/03/working-with-events-part-1 As much as these api's hide complexity, there is a point at which you just have to bite the bullet and learn a modicum of javascript syntax and rules to pull this type of thing off typically.
  5. I don't know what you mean. Do you understand that code, and what the problem is with it?
  6. Some how you got a spurious comma in your create statement: KEY `site_id_date` ( `site_id` , `date` ) , That comma does not belong. It should just be: KEY `site_id_date` ( `site_id` , `date` )
  7. gd and imagecopyresampled
  8. gizmola

    Hello

    This site is a good resource if used the right way. Becoming an "awesome php coder" mostly involves doing a lot of reading, and like most things, spending a significant portion of your time actually writing php code.
  9. Well you have this code: // Minimal form validation: if ( is_numeric($_POST['price']) ) { if(!empty($_POST['weight'])){ At quick glance it's pretty obvious you can't do that if you want to calculate the shipping cost without a price, because your code doesn't allow it. I'm having a hard time reconciling the fact that you could have written all this code and at the same time profess not to understand something so simple, but I guess anything is possible.
  10. Here's the key part of the manual: You might ask him if you need to match every option, because some of those functions have a lot of flexibility. As you can see this defaults to taking 2 parameters, so your function needs to start with those 2, and you need to implement it. Assuming you need complete replication, you have 2 default parameters you need to define in your function. function my_str_pad($input, $length, $padchar = ' ', $location = STR_PAD_RIGHT) { // now you need to start coding it. $inputLen = strlen($input); $padsize = $length - $inputLen; if ($padsize > 0) { switch ($location) { case STR_PAD_BOTH : break; case STR_PAD_LEFT : break; default: // STR_PAD_RIGHT $repeat = ceil($padsize / strlen($padchar)); $t = $input; for ($x=0; $x $t .= $padchar; } return substr($t, 0, $length); } else { return $input; } } That should be a good start for you. As you can see i threw in one of the 3 cases, albeit probbly the easiest one. It also occurs to me that there is a better way to handle the padding string -- figure that out seperately and concat it at the very end when you return it, would be better. At any rate, flesh it out, and you have an idea how to approach the rest of these. Fair warning, there could be problems but with this, it's all off the top of my head, but at least it should give you an idea how you should start approaching the process of coding these.
  11. You need to replicate the behavior of the functions with php code. So you need the same arguments, and your task is to figure out how to match the behavior. Start with str_pad
  12. I would have to see all the code. You keep posting snippets but omitting key things, so I'm left wondering if there's a critical piece that is not in the right place.
  13. Brenda, If you are truly in the process of and invested in learning web development and php then you are welcome here. You question was missing a number of key elements that would have made it clear you did in fact write the original code, and the question was not as clear or as well illustrated as it could have be. Like most everything in life, the more that you put into the process of asking a question, the better your results tend to be. Best of luck.
  14. What operating system are you running? Did you install php? The first thing you should do is create a script named test.php or something similar in your webroot with this in it: That should come back with information about php but i suspect you don't have php installed, or at least not installed correctly.
  15. I took it that way, just felt the need to clarify.
  16. Yes, looks like you have your work cut out for you, your teacher is tough. The php manual is very nice, you can go to the manual page of any function by adding the name to the php.net url. Read the description of the functions and then start writing your code. I can give you a tip, since a lot of these are string related, and that is that a php string is also an array of characters. Try: $str = 'This is a test string'; echo $str[3]; echo ' '; $strlength = strlen($str); for ($x=0; $x echo "Character $x = $str[$x] " } You can go through an array using foreach(). Good luck, and the only way to learn is to dive into it.
  17. IP Address can be trusted. It comes directly from the IP layer and the web server. It just isn't guaranteed to work as a unique identifier, since many different people can share the same IP address, come through proxies etc. Data that can not be "trusted" is data that comes from users and can be tampered with like referer, cookies, form input and url parameters etc. Sorry to be nitpicking, but the question of trust has a generally accepted specific meaning. The IP address will be the one that made the tcp connection to the webserver, even though that might be very misleading when all is said and done.
  18. You also might find this post helpful, along the same lines of what I posted but with further explanation. Note the author: http://www.phpfreaks.com/forums/index.php?topic=336865.0;topicseen
  19. Technically, I posted code and it's not working as I intended. I described what I'd like my code to be able to do and instead of just helping and explaining so everyone can learn you're just turning people away from the idea. What exactly have you contributed in this thread besides basically telling people to figure out how on their own? Please respect our community and the contributions of people like Alex. He has answered 1000's of questions for people and that's why he has a blue badge next to his name. We expect people to put some effort into learning the language and how to use it. You posted 2 lines of code that shows you didn't even read a paragraph from the php manual. My advice is to let it go, and stop attempting to defend the indefensible if you hope to get more help here.
  20. Based on your description of what you want, there is no reason to code anything. You could also use a simple tracking cookie. Tracking by IP is already built into every webserver in the web log! Of course many different people may have the same IP address (see NAT). There's literally 100's if not thousands of posts on this forum that involve php sessions, many of which have code and detailed information in them. We have a search mechanism on the forum for that reason. Alex was already kind enough to indicate that you need to issue session_start() at the top of each page. Forget tutorials -- looking at the php manual pages on sessions for a few minutes should tell you everything you need to know. I wrote this simple script to illustrate the simplicity of basic session handling the other day. sessiontest.php session_start(); if (!isset($_SESSION['pagecount'])) { $_SESSION['pagecount'] = 1; } else { $_SESSION['pagecount']++; } echo 'Session tester'; echo "Ran this {$_SESSION['pagecount']} times.";
  21. List out all the columns you want. In order to union the names and number of columns from each result must be exactly the same. You keep using *. That pulls all the columns from the table. If the names of all the columns in credit and debit are the same then you can use: SELECT *, 'C' as type ... and SELECT *, 'D" as type. If you only really need a few of the columns, then you might want to just list those. It's up to you. Otherwise, you are getting close to the answer. Make sure you use UNION ALL so that no duplicate rows are removed. I don't think you would have any duplicate rows, but you don't want to take a chance on that. You can add on your ORDER BY after the 2nd query in the UNION in order to sort the entire result by date or whatever your need be.
  22. With SQL you can make an alias for a column. So the best solution is to make the results of the 2 queries exactly the same. You can add an artificial column named "type" with a 'C' for Credit and 'D' for debit to identify the source. select amount, 'C' as type, date FROM credit where... UNION ALL ... etc. select amount, 'D' as type, date FROM debit where... [/code]
  23. This guy talks about the basic technique most people use: http://raventools.com/blog/create-a-modal-dialog-using-css-and-javascript/ And this article has all sorts of implementations including ones based on popular js frameworks like prototype and jquery: http://www.designlabelblog.com/2009/03/20-ways-to-create-javascript-modal.html
×
×
  • 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.