premiso
Members-
Posts
6,951 -
Joined
-
Last visited
-
Days Won
2
Everything posted by premiso
-
Re-indexing can be done with a script. But as said, if you are referencing an image and someone linked to that image you essentially make it so it may not be the original image that was linked to, thus can cause some problems for them. Unless you do not want people linking to the image, but yea. Re-indexing a database for a few thousand rows can be alright, but if your database grows, the longer the process can and will take and to be consistent you would need to do it everytime an image is erased, which is a mass overhaul on the DB. I would suggest against it. Regarding the side note, that is a decent idea. But instead of putting that row in the DB why not just have your database test for that, IE if no row is returned for that ID display the "no image" image. That is done quite often and I would say that is the right way to go!
-
Post the code you are setting the cookie with. Note that if you set the cookie on the same page it will not be available until a page reload.
-
He means with an auto_increment field this is not possible. To do what you want you either have to just find gaps and fill them in or re-index your table each time an id is deleted. Re-indexing is hardly an option as it is intense and if your pages a linked by google, could cause some confusion (or being linked to by members). Why is this a big deal? It is better to have a previous page or number that has been deleted to stay deleted, or do not delete and just add a column "active" to the table and set it inactive, so you have an audit trail of sorts. Either way, I would suggest to deal with it or make the column non-auto-increment and increment the value yourself in your script.
-
You will want to use glob: foreach (glob("/path/to/folders/", GLOB_ONLYDIR) as $dir) { $folder = explode("/", $dir); $folder = $folder[count($folder)-1]; echo $folder . "<br />"; foreach (glob($dir . "/*.pdf", $file)) { $file = basename($file); echo "<a href='$file'>$file</a><br />"; } } Is one way to do what you want.
-
Using variables in single quotes take them literally. Try using: $grid_array[$xdoc1->challenge1] = $response1; $grid_array[$xdoc1->challenge2] = $response2; $grid_array[$xdoc1->challenge3] = $response3; Should give you correct results.
-
Add array elements dynamically from a query result
premiso replied to MqTontoh's topic in Third Party Scripts
Move the $new_array=array(); out of the loop, as you erase the data each time it loops: $new_array=array(); while($row=mysql_fetch_array($thumbs)){ Should increment just fine. -
You cannot get their MAC address, namely because you do not have access to their computer. If you install an ActiveX control you can probably get it. But what you want to do is not possible through PHP, as far as I know. And definitely not in the way you are trying to. Sorry bud.
-
For future reference, please use the to surround code in To display the testimonials: $res = mysql_query("SELECT id, `date`, firstname, lastname, testimonial FROM testimonials ORDER BY date DESC LIMIT 10"); while ($row = mysql_fetch_assoc($res)) { echo "<b>{$row['firstname']} {$row['lastname']}</b><br />on {$row['date']}<br />{$row['testimonial']}<br /><br />"; } Would be an example how to display them.
-
Post your table structure and the code that is taking 1 second per query (if it is in a loop post the whole loop code), as it could be causing it.
-
Display Based on Secondary Database Information Being Present or Not
premiso replied to Sethm's topic in PHP Coding Help
I would suggest using mysql_num_rows if (mysql_num_rows($sql) > 0) { //echo "information returned."; } Should work for you. -
This topic is a bit different. If you would like someone to address this issue, please create your own topic for it. Thanks. As to the original OP, if you have not solved your issue, please post the link you are trying to test if it is dead or not.
-
I believe adding the period will match any character except newline, so adding that in there may help. (I am unsure where, but yea).
-
Yep, you can add your site to your "Trusted" list in your browser, or buy a valid SSL certificate.
-
You may have to have a pattern, if that is the case I would suggest posting it in the REGEX forum with an example line from the file and highlighting the section that you would like replaced.
-
You could possibly read in the file to a string using file_get_contents then use preg_replace to replace what you need to replace and write the string back to the file.
-
If you are doing a URL shortening service, I take it that you are storing each item in the database. If so the cache is easy, add a column to the database for description then when the user submits their page you can fetch the pages infromation using either cURL or file_get_contents and parse it with preg_match for the meta tags and grab the data you need and store it in that column. Hope that helps.
-
$filenameNew = getcwd() . '\\avatars\\' . $id . $label . '.jpg'; The \ is an escape key. So it was escaping the single quote. Try that and it should fix it, pending any other errors.
-
Do you have a fiddle in your band?
-
You would have to have software on the computer that allows a commandline interface to send the commands to the scanner. This will also require the scanner drivers. As far as how to do that, I have no clue. You will have to look up how to utilize scanners by a command line interface on the operating system you are using. This is not possible with PHP alone.
-
Yea, that is the idea. So it is not accessible from the web, but it is accessible to the script.
-
What I was talking about: /home/www/site/folder/index.php Is the index.php file of your site. You would store config.php in: /home/www/site/config.php That way they cannot just browse to http://www.yoursite.com/config.php as it would not exist. But you can still include the file by going up one directory with ../ and then it is safe incase somehow your server decides to stop parsing php etc.
-
It would not matter if they did, if it was properly coded in PHP and as long as your server still parses PHP. However, it is good practice to place config files outside of the webroot, to prevent such items from happening.
-
Because < and > are html characters. Use htmlentities on the text: <?php print htmlentities("<?php //username:password ?>"); ?> Should show it to the browser.
-
This would delete the session cookie. So the user would get a new session after that expires and would have to re-authenticate, as that session would no longer be valid. You can add that before the session_start, or you can change it in the php.ini file, however, this change will be reflected on all sites. You may also be able to set it using .htaccess, so you do not have to modify your code to reflect it. Here is an example of the code for the .htaccess: php_value session.cookie_lifetime 5400 Which should effect all folders / files where that file is located (given that you are using Apache).
-
Regex should not be needed for this, given that you are asking what I think you are you should be able to use $_GET: $id = isset($_GET['id'])?$_GET['id']:null; $increment = isset($_GET['increment'])?$_GET['increment']:null; If you have it inside of a string I would use parse_url: $text = "www.mysite.com/?id=xyz&increment=01"; $queryString = parse_url($text, PHP_URL_QUERY); list($id, $increment) = explode("&", $queryString); Not sure which you were after, but there it is.