Jump to content

djlee

Members
  • Posts

    44
  • Joined

  • Last visited

    Never

Everything posted by djlee

  1. thats because it runs from the current working directory. simply give it a path to start from. $path = "."; //-- current directory of the php executing script $path = ".."; //--- the first parent folder of he current working directory $path = "/"; //--- the root of the system (not a good idea) $path = "~"; //--- the home directory of the executing user (depends on server setup) $path = "/absolute/path/to/folder/to/start/at"; //-- probably the one you want (i.e. /var/www/) Those are based on linux but should give you an idea of how paths work in regards to the execution environment
  2. yep they had reg globals on. You need to change everything to use $_POST[] that is passed through the form. Also id advise getting rid of that extract() on the request vars and declare them properly. its just horrible. Also dont forget to sanitize your data. If your sending the id through teh form, at very least typecast the post var to an int before putting it in the query. That way if someone changes the id to an injection string in the form, your code will convert it to zerio and it just wont do anything
  3. Did you create this yourself or get it from somewhere. It looks as if it uses register_globals . Which means it takes all post and get variables and puts them into common php variables. This is a bad idea and you should change it to specifically use $_POST and $_GET then deactivate register globals if you have that setting switched on
  4. AuthUserFile /path/to/htpasswd AuthType Basic require valid-user
  5. basically yes, its actually called a "ternary statement" $month = ($month == 1 ? 'Jan': ($month == 2 ? 'Feb' : ($menth == 3 ? 'Mar' : ($month == 4 ? 'Apr' : ( $month > 4 ? 'I got bored here' : 'Thats not right!' )))));
  6. The stretching is because your maths is wrong. im guessing you want it so if the width is more than the height. then the new width is applied, and the same scaling ratio from old to new width is applied to the new height so /** * $w = max width the thumbnail can be * $h = max height the thumb should be * $old_w, $old_h = source image dimensions * $new_w, $new_h = the dimensions you should resize the source image to, to create a thumbnail */ if($old_w > $old_h) { $new_w = $w; $scale_factor = $w/$old_w; $new_h = $old_h * $scale_factor; } else { ///do the opposite }
  7. $r = mysql_query('select articles'); while($a = mysql_fetch_assoc($r) { echo "article".$a['article_name']; $r2 = mysql_query('select commects where article = '. $a['articleID']); while($a2 = mysql_fetch_assoc($r2) { //echo comment here } }
  8. i may not understand the problem. but from what i can tell, could you not use json ? php has a json plugin, and theres both javascript and php libraries for json out there if you dont have the php_json or a library like jquery to work with. Just json encode the form elements and then decode in php. Failing that, why not use post arrays, you can send a limitless number of data via a single variable name using []. for example <textarea name="body[]"></textarea> Then you can just do foreach($_POST['body']) dont know if any pof those two are pertinent to your problem however edit: thorpe seems to type quicker than me
  9. well you need to know BEFORE any output can begin, you cant get a count in the same query so your left with two options. Get a count via query by grouping on item id, or store everything into an array such as $products = array(); $query = xxx while($row = mysql_fetch_assoc($query)) { $products[$row['product_id']][] = $row } That will give you an array where the key is the item id (which is not unique in this context) andthe value is an array of products, so then you can do foreach($products as $productid => $arr) { if(count($arr) > 1) { // more than 1 } else { // only 1 } } However it may be better to seperate it out, so you have products in a table, then another table with the product_id, size and price. That way your not duplicating data and it just makes life easier (i.e. the array would be a value of products with a nested array of sizes => prices, which would be much better)
  10. compare the code, your defining $img in the first one but not the second block of code for output.
  11. djlee

    newbe

    id contact the site first and let them know some devious hacker has forwarded there domain to search.url.com. You may need to assist them in reconfiguring their DNS so that http://url/ points to the corrcet place
  12. stamp1 is a date string, fifteenpastthishour is an INT
  13. the best option would be to use the http referer. that way they dont get annoyed browsing your site but if they type it in the url then they get redirected. Put this in a core file thats included everytime and no matter what url they type in they will be redirected to the landing page by default. Put it only on the index page and it will only redirect to landing page if index is visted from somewhere other than your own site. Which ever one is more in line with your site i guess, ive used both ways in the past.
  14. you would have to post up the mod_rewrite code and an example that doesnt work. I believe if you are setting variables in your mod_rewrite code as GET vars, it will ignore the GET vars in the url. This is why a lot of CMS type systems mod_rewrite everything to a single index page then handle the load from there. So just patse up that code and someone will help
  15. since your using jquery, the easiest way is to echo "var xx = jQuery.parseJSON(".json_encode($array).");"; the var xx will be a javascript object. so you can get the data using //--- string based keys xx.key //-- integer keys xx[0]
  16. This would be more suitable, so you dont badger the visitor too much in quick concession. <?php session_start(); //-- times before landing page is disabled $lpcount = 5; //-- time between landing page shows $halt_time = 60 * 10; //10 minutes // default the variable to avoid a notice error: $_SESSION['views'] = !empty($_SESSION['views'])?$_SESSION['views']:0; $_SESSION['last_land'] = (int)$_SESSION['last_land'] > 0 ? $_SESSION['last_land'] : 0; if ($_SESSION['views'] < $lpcount && $_SESSION['last_land'] < (time() - $halt_time)) { $_SESSION['views'] += 1; $_SESSION['last_land'] = time(); header("location: /landingpage.php"); exit; } ?> However if you just want to stop the loop then add a check in the IF() that says "if http_refferer is my own site, then do not redirect to landing page"
  17. Your quotes are all over the place, that could be breaking it. the first one should be the one you want. but you have no quote ending the width attribute and the quote that ends the src attribute is in the wrong place. Fix that and try again.
  18. i see the problem (and probably confusion). The back button your referring to is the browser back button (or an equivalent hijacking of its function via javascript anchor). What your trying to accomplish is difficult, simply because you have to contend with browser caching and everything else. Plus you cant post back data. You have 2 options. 1. use the session. Its generally frowned upon, but sometimes it's the only way 2. create your own back button link that does as adam suggested basically <form> <div style='display:hidden'> <!-- put all your inputs here with their names the same as the real form and the value attribute set to $_POST[input_name]--> </div> <input type='submit' value='Go Back' /> </form> That would basically cause you to go back to the form page, but it will post back all the form data so you can prepopulate the form again. However javascript validation should cover most error's anyway. So if you implement ood JS validation, the odd user getting caught out via the backend script shouldn't be an issue
  19. Im just gonna reply for the sake of it really. But when your asking should a specialist question, its hard to find answers. Its bad enough asking about printing via php. But when you limit the scope of response to a specific vendor or product you limit the amount of possible support. But i digress. Pretty much anything is possible in PHP. You'lld just have to use PHP as an abstraction layer to a server side program. I dont have a test environment or the printers or the software in order to work it all out otherwise i'd have had a blast purely for a small challenge. Best thing to do would be to find the appropriate software for managing your "setup" on your server (hopefully linux, as linux dev's usually make their CLI interfaces user friendly) and see what you can do via CLI. If you can find out how to do everything you need in a CLI environment, then you can always use system/exec/e.t.c. to do what you need
  20. would it not be easier to add them into the database and use an order by score when pulling them out ? Just knocked up some example code if you dont wanna go the database route <?php $horses = array(); $horses[] = array('name'=>'fred', 'score'=>34); $horses[] = array('name'=>'gary', 'score'=>12); $horses[] = array('name'=>'lee', 'score'=>45); $horses[] = array('name'=>'duke', 'score'=>10); $horses[] = array('name'=>'bill', 'score'=>13); $scores = array(); foreach ($horses as $key => $row) { $scores[$key] = $row['score']; } array_multisort($scores, SORT_DESC,$horses); print_r($horses); ?> whack it in a php script, run it and mess around with it
  21. since my magic ball has rolled under the desk and im too lazy too pick it up. i'd have a wild stab in the dark and suggest header ('Location: abc.php?id='.$id);
  22. That is aweful database design, ive used concated strings instead of using "linker" tables before, but only with very good reason. This just isn't one of them. However based on the code it would appear like silkfire's sugestion would be the best option. You only want to get the category results for the first category (otherwise you'd have multiple's of the same property if a property is in more than one category). so something like this would force it to join the category details only mysql_query("SELECT a.*, b.c_id, b.c_title FROM properties AS a JOIN cat AS b ON SUBSTRING_INDEX(a.pr_category, ',', 1) = b.c_id",$connect);
  23. the best way to do this is to find a unique key. For example the id of the record of the database. Pass that unique id through with the form, then you can use an insert statement and use "on duplicate key". Basically you'll never want to insert, but the unique id will always cause the on dupe key action to be called for every insert for example lets say you have a database product_id | name | price ---------------------------------------- 1 | some name | 23 2 | another name | 32 3 | abcdefg | 12 the form <form> <input name=product[1] /> <input name=product[2] /> <input name=product[3] /> </form> the php $insert = array(); foreach($_POST['product'] as $id => $val) { $insert[] = "($id, $val)"; } mysql_query(" INSER INTO products(id,price) VALUES " . implode(',', $insert) . " ON DUPLICATE KEY UPDATE price=VALUES(price)");
  24. i personally use epoch time for all timestamps apart from DOB's. then use php's date() to format as required. Integer comparison is quicker than other comparitors, and i find it easier to understand. If you have the timestamp you can in php just do if($timestamp > (time() + 1200)) { /pregnancy ends } However it really just comes down to personal preference since the performance differences are negligable. When inserting into a DATETIME field in mysql, you can just use "NOW()".
×
×
  • 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.