
djlee
Members-
Posts
44 -
Joined
-
Last visited
Never
Profile Information
-
Gender
Not Telling
djlee's Achievements

Newbie (1/5)
0
Reputation
-
List all Files in a Directory Including Sub-Folders
djlee replied to Orangeworker's topic in PHP Coding Help
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 -
simple Update form not update field on database help
djlee replied to Lisa23's topic in PHP Coding Help
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 -
simple Update form not update field on database help
djlee replied to Lisa23's topic in PHP Coding Help
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 -
AuthUserFile /path/to/htpasswd AuthType Basic require valid-user
-
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!' )))));
-
convert image into thumbnail before displaying them.
djlee replied to php_begins's topic in PHP Coding Help
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 } -
$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 } }
-
Updating mysql table info with js array on reload
djlee replied to spenceddd's topic in Javascript Help
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 -
looping through database and output to select list or not
djlee replied to AdRock's topic in PHP Coding Help
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) -
compare the code, your defining $img in the first one but not the second block of code for output.
-
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
-
stamp1 is a date string, fifteenpastthishour is an INT
-
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.
-
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
-
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]