-
Posts
3,584 -
Joined
-
Last visited
-
Days Won
3
Everything posted by JonnoTheDev
-
Fact 2: Fact 1 is bollox and makes as much sense as a left handed screwdriver.
-
It seems you are trying to add more parameters onto an already rewritten url. I don't think this is possible. Paramaters start with ? i.e. http://dsfsdf.php? As the position of this has already been defined in the rewrite rule adding another after params will no work. If the url is not using the rewrite then you can use as many paramaters as you like ie. control.php?request=hello&you=me
-
Sort files from directory in date created order
JonnoTheDev replied to Bricktop's topic in PHP Coding Help
I would set the filename as the key not the date as 2 files could have the same date however filenames are unique within a directory. -
Sort files from directory in date created order
JonnoTheDev replied to Bricktop's topic in PHP Coding Help
Create a function that you can reuse. You will pass in a directory to the function and it will return an array of all files in date order. Do some research to teach yourself. If I lay down the whole code it will mean nothing. Read on arrays and functions. Complete this function and look at php.net to understand the core functions used within it <?php // return all files by date order in a given dir function getFilesFromDir($dir) { $fileArray = array(); // return empty array if not a directory if(!is_dir($dir)) { return $fileArray; } $dObj = dir($dir); while(false !== ($file = $dObj->read())) { // ignore directories if($file != '.' && $file != '..' && !is_dir($dir.$file)) { // store the file in the array // use the file date as the array value i.e $fileArray[image.jpg] = 20090412 $fileArray[$file] = ; } } // now sort the array // sort code here // return array return $fileArray; } // run the function $files = getFilesFromDir("/usr/local/src/php/"); // loop through files foreach($files as $file => $date) { print $file." (".$date.")<br />"; } ?> -
No you use the primary key of the category and pass it through the url to the page that displays the pdfs. Select the category using the id in the url. You only need 2 pages for the whole system: 1. Home page to display categories 2. Inner page to display pdfs from selected category database categories ======== catId title pdfs ======== pdfId catId title filename The category page select all categories SELECT * FROM categories ORDER BY title ASC loop out the data and make each link i.e category.php?catId=1 - Cat 1 category.php?catId=2 - Cat 2 category.php?catId=3 - Cat 3 On category.php select the pdfs from the catId SELECT * FROM pdfs WHERE catId=$_GET['catId'] loop out the pdfs Also select the category SELECT * FROM categories WHERE catId=$_GET['catId']
-
Its not really a true function as it has no definable parameters. It checks a string is between 5 & 15 characters in length. Where would you re-use the function in your script? If the min and max characters were parameters then the function becomes more useful as you could use in a variety of forms you may have on the same site. Simple example function checkStrMinMax($string, $min, $max) { $len = strlen(trim($string)); if($len < $min) { return false; } if($len > $max) { return false; } return true; } if(!checkStrMinMax($string, 3, 15)) { print "username must be 3 - 15 characters"; } Also don't use global variables in functions. Add as parameters
-
Sort files from directory in date created order
JonnoTheDev replied to Bricktop's topic in PHP Coding Help
You need to create an array of all the files in the directory first. At the moment you are just printing them out and there is no way you can sort the data. Make a function that creates an array of files from a given directory. The array must contain the file date. You can then sort the array by this value and return it from the function. You can then loop over the array to print to the screen. -
You cannot use arrays in a url src="editor/fckeditor.html?InstanceName=texte[]&Toolbar=Basic" Rather than an array why not use a counter to identify each instance $numItems = 4; // produce editors text1,text2,text3,text4 for($x = 1; $x <= $numItems; $x++) { $oFCKeditor = new FCKeditor('text'.$x) ; }
-
Smarty is great. I think HTML embedded in a php document looks nasty and is a nightmare for designers to work with. You won't have the issues where designers may knock a semi-colon out of place and cause syntax errors.
-
This is just simple sql. Why do you need a specific script? SELECT * FROM abc WHERE x LIKE 'myfile%'
-
just use strip_tags()
-
You dont want to be using the function file_get_contents() for this job. To create a scraper, spider, whatever you should learn CURL. Checkout the PHP manual. I would also look ad the 'tidy' funtions to clean HTML on remote sites prior to using any regular expression pattern matching as people use all kinds of variations of HTML syntax.
-
Ajax makes requests to server side scripts (ajax is javascript, not a language in itself). A server script has nothing to do with the download process. This is done via the users operating system. Aslo javascript will not help as it is parsed by a web browser. I have never heard of websites that perform actions after a download has completed (as it's impossible).
-
I wouldn't recommend even using this script. It is badly programmed and parts are obsolete. Obsolete $HTTP_GET_VARS The use of global variables is a major security risk and poor design.
-
This is invalid <form method="post" action="abc.php"> <input type="text" name="order[]" value="1" /> <form method="post" action="abc.php"> <input type="hidden" name="gvjhv" value="mhbhb" /> </form> <input type="text" name="order[]" value="2" /> </form> I would expect this to only give me a value of 1 if I print the values of $_POST['order'] as the nested form is ending the main form. Some browsers obviously accept this but it is bad practice.
-
nested forms probably ending the main form at the </form> of the nested only giving you 1 POST[order] you shouldn't use neseted form tags - invalid
-
There is no issue with the following in any version of IE <input type='text' name='order[1]' size='3' value='123' /> I use this method very frequently. Your HTML has to be invalid no matter what W3C states. The browser does not have anything to do with php (php is server side). It is what you are sending to the php processor (POST data from HTML) that is invalid. Some browsers are more forgiving with invalid HTML like FF and may auto-correct it hence you have no issue with those browsers. Like the PP states you need to post the HTML produced by your script.
-
Need to run command as root without sudo or cron
JonnoTheDev replied to tibberous's topic in PHP Coding Help
No, if the apache user had root permissions and you had a script that modifys files then it could be possible to inject code. Anyhow this question is probably better posted in the linux forum as it is not php specific. -
You dont need a script you can do it with SQL INSERT INTO table1(id, name) SELECT id, name FROM table2 http://dev.mysql.com/doc/refman/5.1/en/insert-select.html
-
Need to run command as root without sudo or cron
JonnoTheDev replied to tibberous's topic in PHP Coding Help
If that were possible the security risks would be unbelievable. You could destroy a server. -
intergrating mouse overs image with php script
JonnoTheDev replied to DigitalExtremeMediaGroup's topic in Third Party Scripts
Google 'javascript image enlarge' -
I'd make your own. Doing this with an off the shelf system like osCommerce will be a fuc*** nightmare. If you have your own database design then it makes the job 10 times easier. osCommerce is good if all you need is an online shop and not fussed about specifics. If you have bespoke requirements it could be hell attempting to modify it.
-
Try to use code tags to surround your code! You have an error here $orderrow = "<td><input type='text' name='order[$vid_id]'' size='3' value='$ordering'</td>"; Your HTML element is incomplete and has an extra ' after the array. It is much easier to spot if you use the following standard <?php $orderrow = "<td><input type='text' name='order[".$vid_id."]' size='3' value='".$ordering."' /></td>"; ?>