Jessica
Staff Alumni-
Posts
8,968 -
Joined
-
Last visited
-
Days Won
41
Everything posted by Jessica
-
Then you need to dynamically generate it like I suggested before. For each of the fields they submit, put it in an array like this: "fieldX = 'SearchX'" then use explode to add the ' AND '
-
[SOLVED] Excluding Quotes (") from a MYSQL query to reduce problems
Jessica replied to jonoc33's topic in PHP Coding Help
Then you're not using it right...your code only shows stripslashes which will do the OPPOSITE. You don't have anything to escape data. -
Adding Image Resize To My Current Upload Script
Jessica replied to sintax63's topic in PHP Coding Help
I always say there's a reason they called it GD. It's a G--D--- pain. -
You can use CURL to fetch data from other websites.
-
Can't get array_walk to show changes to array.
Jessica replied to Jessica's topic in PHP Coding Help
You have an extra $ in there, but after I removed it it still didn't work. Still got: -
So you have your answer now. Use OR and put in the 7 fields...
-
Adding Image Resize To My Current Upload Script
Jessica replied to sintax63's topic in PHP Coding Help
I prefer to use the filesystem for files, so I never store images in my db. You create the image the same way he said, only output it to a file instead of a string. http://php.net/imagejpeg - look at the arguments you can send it. -
That's why it sucks to have big tables You could create an array of the fields names and dynamically create the WHERE clause using explode. You should probably look into fulltext searches, for one thing.
-
This should be in third-party scripts. As the errors say, you need to use your FTP client to change the permissions of those files. It depends on what client you're using, but try right clicking on the files and selecting Permissions. Then type in what the error says to.
-
Cant Get my Button to work!!..please help me...
Jessica replied to gsanghera's topic in PHP Coding Help
The problem is in your HTML, not PHP. As revras said, you need a form element. Here's a good tutorial: http://www.tizag.com/htmlT/forms.php -
You will want to use OR "SELECT * FROM table WHERE field1 = 'search' OR field2 = 'search'"
-
[SOLVED] Excluding Quotes (") from a MYSQL query to reduce problems
Jessica replied to jonoc33's topic in PHP Coding Help
You need to research "SQL Injection" to find out why you need to escape and sanitize data and sql statements, and you should find articles with techniques on how to fix your problem. -
I have tried both: array_walk(&$files, 'htmlentities'); array_walk($files, 'htmlentities'); Using PHP5 Nothing changes, it still prints & instead of & Do I have to wrap htmlentities in a in a custom function or am I doing something wrong? EDIT: I tried wrapping it in a function and no change. $h = create_function('$txt', 'return htmlentities($txt);'); array_walk(&$files, $h); print_r($files);
-
'5' Is a string, 5 is a number. I think MySQL has stricter typing than PHP so if that doesn't work try just 5.
-
You can use a combination of substr and strpos.
-
[SOLVED] Recursive file listing of directories
Jessica replied to Jessica's topic in PHP Coding Help
Sweet, now I get all 5 folders The only problem is it shows the entire directory, so I'm going to figure out some way to remove the main directory and just show the folder on the subdirectories. Thanks! Edit: Here's my version now. I changed the code to my style so I'd be able to read it later function dirList($folder, $add='') { $out = array(); $han = opendir($folder); $f = (!empty($folder)) ? $folder . '/' : ''; while($file = readdir($han)) { if($file != '.' && $file != '..'){ if(!is_dir($f.$file)) { $out[] = $add.$file; continue; } $out = array_merge($out, dirList($folder.$file, $file.'/')); } } return $out; } Works great, I get all my folders and files. I spent an hour on this, should have come here a bit sooner -
[SOLVED] Recursive file listing of directories
Jessica replied to Jessica's topic in PHP Coding Help
Appends the results from the dirList of the subdirectory to the current list of results. I changed it to: $results += dirList($directory.$file, $file.'/'); And now it shows the first subdirectory for the first print_r, and for the other three, the first TWO subdirectories only. I am so confused, it has got to be something simple. Corbin: I don't want to use empty folders, just the files, so I'll try yours. Thanks! -
I am using this function to get all of the files in a directory, and also in any subdirectories in that directory. For the subdirectories, it needs to append the subdirectory to the file. Here is what I am using: function dirList($directory, $add=''){ $results = array(); $handler = opendir($directory); while($file = readdir($handler)){ if($file != '.' && $file != '..'){ if(is_dir($directory.$file)){ $dirResults = dirList($directory.$file, $file.'/'); $results = $dirResults+$results; print_r($results); }else{ $results[] = $add.$file; } } } closedir($handler); return $results; } However, my print_r() only shows the results for the current subdirectory - just $dirResults, not $dirResults+$results. There are four subdirectories, after the first subdirectory it should show the contents of both the first and second in results, then first, second and third, etc. The final array returned has the last subdirectory and all of the files in the main folder. Help Please?
-
Converting scropt from using register_globals to not using
Jessica replied to tagert123's topic in PHP Coding Help
In the past you could use $id to mean the value of id passed in the URL or Posted. Now you need to do $id = $_POST['id']; or $id = $_GET['id']; depending if it was posted or in the url. You also need to sanitize your data, look up SQL injection on google. -
Yes, if they are hotlinking your image, everytime someone views their website with the image on it, it uses your site's resources. Use a decent host MediaTemple is a great one.
-
As much as I hated template engines for the first few years I used PHP, I've recently started using Smarty and I finally understand why template engines exist. The syntax is really not that difficult, I learned how to use it effectively in a few hours. The separation of code and presentation is important to some people or in some cases, and for them, I'd suggest Smarty.
-
[SOLVED] shorter way of selecting 1 specific thing from DB?
Jessica replied to scarhand's topic in PHP Coding Help
mysql_result is slower than mysql_fetch_assoc (according to w3schools), and its about the same amount of coding. Please don't answer my question with another question. Haven't you ever heard of the Socratic Method? -
Make a function which checks if they are logged in or not, and call it on every page.
-
In each category you need to store it's parent category, then select out all of the categories with parentID of the current category.