Jump to content

gizmola

Administrators
  • Posts

    5,945
  • Joined

  • Last visited

  • Days Won

    145

Everything posted by gizmola

  1. There's no way to know without you getting the value of mysql_error(). I suspect there's some issue with either the values or the column list, for example, is the key of user_info really named user_infoid? At any rate, when you do a query you should get the return value. $retval = mysql_query(....); if (!$retval) { // query failed. // This is for debugging, should handle errors better than this, but for now, it's ok: echo 'Error: ' . mysql_error(); die(' insert failed!'); }
  2. You have to capture the starting price the first time. At the bottom of the loop set the previous price. $1_details = ''; $priordate = ''; $priorprice = null; while ($row = mysql_fetch_array($result)) { $date = $row['date']; $price = $row['price']; if ($priordate == '') { $priordate = $date; $priorprice = $price; } $diff = $price - $priorprice; $1_details .= $date $price $diff EOD; $priordate = $date; $priorprice = $price; } $1_footer ="";
  3. I'm not sure we're on the same page in regards to cardinality. When you do: select style_name, count(*) as countof FROM lunapr_c1price GROUP BY countof What do you get?
  4. Tripic: straylight has some great tips for you. Additionally, I'd ask: How is the user and userinfo table related? Do you need to do the user query first and then get the AUTO_INCREMENT id generated, so that you can set one of the columns in userinfo to be the same? If so you need to do the first query then call mysql_insert_id() to get the newly generated user_id. Also, you might find that php's string interpolation could make writing your queries a lot simpler. This works: $query = "INSERT INTO TABLENAME ('foo_id', 'fooname', ...) VALUES (NULL, '$variable', '{$arrayvar['somekey']}' ... ";
  5. It's not like the session_id is hard coded .. it's typically a hash value. Someone needs to intercept or access this value, which is typically stored in a cookie. How are these attackers going to get access to this value? The answer to almost all these questions typically involves sniffing traffic, or some xss exploit where people have their cookie files dumped. If you really need to insure that sniffing can never happen, there's an answer: https:// At very least your admins can use https://, and they should also be aware that if they're using a shared computer, they shouldn't use a remember me feature.
  6. The describe command will give you the table definition. If you have access to the server via ssh, and can run the mysql command line client this is helpful. If you only have phpMyAdmin, then use the export, uncheck data and export to sql. You will get something like this: CREATE TABLE IF NOT EXISTS `innotest_utf8` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `vc1` varchar(35) NOT NULL, `vc2` varchar(35) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=10001 ; Don't worry about the code for now, but for future posts use the php bbcode tag around your code.
  7. The only way you limit down the size of result set is to have where clauses that use indexes. If you want to join a bunch of tables that have thousands of rows and produce result sets of thousands of rows, things are going to be slow. In your explain plan, you can see that: 1 SIMPLE p range style_name style_name 27 NULL 13607 Using where; Using temporary; Using filesort Which is making a temporary table with 13607 rows, which it then sorts. Does the style_name column have an index on it? Even with an index it may not use it if this is a low cardinality column (only a few style_names).
  8. Hi, Let's start with the information you've provided. It is not accurate, because you are apparently (and in my opinion correctly) using id's however you haven't indicated that in your preface. In looking at your tables, I'm not sure what you're doing with Categories, but it looks like you might need some restructuring. Please do this using either the mysql client or phpMyAdmin: describe Recipes; describe Categories; Also please wrap your php blocks in: [code=php:0] ... and use code /code for your describes. This makes it easer to read, and to copy... paste, for those analyzing your problem. [/code]
  9. date_default_timezone_set('America/Los_Angeles'); $date = strtotime('2010-02-19T17:23:53-05:00'); echo date('r', $date); You'll want to look at the manual page for the date function to figure out what your desired date string is. I used 'r' because it was simple and close, but you can construct any date format you desire. In some cases, you need to set default_timezone_set(), so you should set that relative to your server.
  10. cwarn: i thought we went over this in irc. What you are doing is a dead end. You can not reverse a sha1 hash and "decrypt" it. It is a hash, not encrypted ciphertext.
  11. Would need to see your assignment code, but clearly, $array['sex'] is not an array, so you probably have more issues than trying to get a sort. With that said, arsort is probably something that could help you, but given your current structure. Understanding more about your application would be helpful in suggesting whether you're heading down a dead end.
  12. Ok, but what is the current issue?
  13. Try this, fixed an obvious issue, and added some checking to make sure that the getimgsize actually works. foreach($_FILES['new_image'] as $image) { $imagename = $image['name']; $source = $image['tmp_name']; $target = "photos/".$imagename; move_uploaded_file($source, $target); $imagepath = $imagename; $save = "photos/" . $imagepath; //This is the new file you saving $file = "photos/" . $imagepath; //This is the original file $modheight = 350; $imgsize = getimagesize($file); if ($imgsize !== false) { $width = $imgsize[0]; $height = $imgsize[1]; $diff = $height / $modheight; $diff = ($diff) > 0 : $diff ? 1; $modwidth = $width / $diff; $tn = imagecreatetruecolor($modwidth, $modheight) ; $image = imagecreatefromjpeg($file) ; imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ; imagejpeg($tn, $save, 100) ; $save = "photos/thumbs/" . $imagepath; //This is the new file you saving $file = "photos/" . $imagepath; //This is the original file list($width, $height) = getimagesize($file) ; $modheight = 100; $diff = $height / $modheight; $diff = ($diff) > 0 : $diff ? 1; $modwidth = $width / $diff; $tn = imagecreatetruecolor($modwidth, $modheight) ; $image = imagecreatefromjpeg($file) ; imagecopyresampled($tn, $image, 0, 0, 0, 0,$modwidth, $modheight, $width, $height) ; imagejpeg($tn, $save, 100) ; echo "Large image: "; echo "Thumbnail: "; } else { echo "Unable to get image dimensions."; } } ?>
  14. There's another thread by the OP that covers the same ground. I'm locking this one so nobody else wastes their time.
  15. No. When you join 2 tables you get a row for every time the tables intersect. So if that means that you have a school with 10 images, you're going to get 1 x 10 rows, where all that will be different is the columns you pull from images. You also have the image_school table, but I don't understand how that table figures in, although relationally the rules are the same. So you have 2 choices: -Make your loop code more sophisticated, so that you only emit a new school markup when the school_id changes. This is fairly standard and easy enough to do -Inside your loop do a 2nd query for images for that school and fetch those seperately.
  16. Ok Prashanth. Could you please explain in detail the differences between Cake, Symfony, QCodo and CodeIginitor?
  17. Really, nobody here gives a hoot whether you stay or go. I do find it kind of amusing that this entire thread exists because according to you -- and I'm paraphrasing your -- that you have a "friend" who wrote some code, and you were hosting that code to "be a test server" and when the code doesn't work, rather than the "friend" who wrote this code coming here, you come and post this thread, which of course we all assumed was your code, or at very least, code that you wrote. Right away, when I question you -- do you understand the code? You state -- "of course how dare you" now why does it --- (jump to uninformed conclusion)", when in fact, you didn't understand what the function did, nor did you explore in even the most basic way what might be causing you the problem. So, in hindsight, now that we look back at the first few posts of this thread ----> HAMMER NAIL HEAD.
  18. So now you have your answer. It works exactly as intended. The $_SERVER["SCRIPT_NAME"] variable is set to be /cgi-sys/php5, so you get php5 as your result. This has nothing to do with your php version, as I stated. Probably the reason this doesn't work is that your your webhost has implemented php as a cgi program, and thus, many of the $_SERVER variables are unreliable. You should make a simple phpinfo() script and take a look at the section that shows you the $_SERVER variables, and pass that back as a bug report, I guess.
  19. You can use eval() to run php code. It's very dangerous to run code dynamically if you're not 100% sure what you're doing, but if you can't possibly think of a better design, it is possible to take strings of php code and run them dynamically. http://us2.php.net/eval
  20. You don't seem to understand the problem. The problem is PEBKAC. You are what I consider to be an unreliable poster. Everything you have posted is unreliable and suspect. After my many years answering questions and helping people out, I have a finely tuned Bullshit detector. You also don't seem to read very well, and looking back (just now) at some of your prior posts, you seem to have a proclivity for getting in over your head, and then using these forums to try and wade out, often because you employ the code of others that you don't understand, and apparently are too stupid or lazy to investigate yourself. What you don't get is that the people here who seem to repeatedly get fed up with your crap, really do want to help people. They just don't want to spoonfeed lazy people who lie and obfuscate and omit important details that might actually lead to a resolution just as you have. Here's a test script. Run this and only this. Cut and paste the results. function curPageName() { return substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1); } echo $_SERVER["SCRIPT_NAME"]; echo ' '; echo curPageName();
  21. But there's no comparison. Joomla is a CMS which includes its own database schema, objects, user authentication, controller structure, modules, templates etc. etc. etc. Smarty is just a simple templating library. About the only thing the 2 have in common is that they are both written in PHP. One is a developer library that is by its very nature nothing but a library that goes in a developer toolbox, and the other is a working site. Comparing them is beyond apples and oranges. Now let's just say for a moment that you built a wysiwig ajax page that allowed people to move around blocks and widgets, and put placeholder variables in certain locations. Ultimately what would you want to do with this? One completely viable answer, is that the system would write out a template file. This would still go back to the original question, which had to do with how you would implement conditionals (and possibly looping, partials etc.) . Eventually you will get back to the same issues that thorpe and I have both brought up. You could have this write out any sort of template file you wanted. If you want to go ahead and rewrite something that already exists in various template libraries out there, nobody is going to stop you from doing so. That doesn't change the fact that the functionality you originally requested already exists in these template solutions. The wysiwig requirement is a red herring and has nothing to do with the original question you asked. It seems to just go back to the NIH (not invented here) arguments you made, that involve a simple solution to a simple problem, and which are no longer applicable because the new requirement exceeds the capabilities of the design of the original system. In the abstract, it's hard to say much more to help you. You'd definately be better posting specific targetted code examples, along with specific examples of what the new requirement is, and perhaps people could offer you something that's actually usable.
  22. It will return whatever the last portion of the $_SERVER['SCRIPT_NAME'] is. Apparently in your environment that portion is 'php5'. This is why I asked you if you understood what the function does. You said you do, but you appear not to. Then we asked you for the code that generates the links, and you posted something that is clearly not the code. We can't help you when you don't provide the information requested.
  23. Apache was written to run under unix, and takes advantage of the way unix is designed. For example, it has 2 fundamentally different ways of working -- prefork vs. worker. The windows version of apache is a port, due to the fact that windows threading involves a parent program that then spawns child threads, whereas unix is designed around processes and interprocess communication. The version of apache that provides the most flexibility then, is the unix version.
  24. We don't locate scripts for people. This site is for helping developers using php. Try hotscripts or someplace like that.
×
×
  • 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.