Jump to content

DaveyK

Members
  • Posts

    289
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by DaveyK

  1. Display the error and put the different scripts in their respective script tags
  2. Or you can try doing it in one clean script. This is somewhat the same script as gmaestroo's but... cleaner <?php $i = 0; foreach($db_res as $value) { if ($i == 0) { echo '<div class="something">'; } echo $value['some_key_name']; if ($i == 4) { echo '</div>'; $i = 0; // reset to 0 for future rows. } ++$i; } ?> I havent tested the script but the logic is there. Also, if the number of rows is not exactly x*4 this script will fail to add the last </div>. Im sure you can figure that out.
  3. I think that that code will return in undefined index error if the mail is not in the array. I would suggest this: $to = array( 'Pedicure Price Inquiry' => '[email protected]', 'Manicure Price Inquiry' => '[email protected]', 'Booking Time' => '[email protected]', ); $send_to_email= (isset($to[$_POST['category']])) ? $to[$_POST['category']]: $to['Booking Time']; EDIT: Markup
  4. Also, you say you are getting a 500 error (server error). What I want to know, is if you show errors? Do you have error reporting turned on?
  5. and this code doesnt work? Whats the problem?
  6. Do you have error reporting turned on? If not, turn it on: error_reporting(E_ALL); ini_set("display_errors", 1);
  7. Requinix, this is the function I am currently using: function find_parent_id_0 ($k, $comments) { if (!isset($comments[$k])) { return false; } $parent = $comments[$k]['parent_id']; if ($parent == 0) { return $comments[$k]['comment_id']; } else { $id = find_parent_id_0 (($k - 1), $comments); } return $id; }
  8. You are using the mysqli class on the update query, rather than the MySQL class. This will caus an error . The use for MySQL is discouraged though. Feel free to use mysqli or pdo_mysql. Don't harm kittens!
  9. I already edited the function because it didn't act the way I wanted to. I don't really follow your logic, but I'll post the new version here tomorrow.
  10. You get a 500 error because you are not using quotes? That seems awfully strange. Never heard that before. Are you sure o_O ?
  11. Well, I tried to follow your logic but I did it a little differently. I wrote this function: function find_parent_id_0 ($k, $comments, $array2) { $parent = $comments[$k]['parent_id']; if ($parent == 0) { return $comments[$k]['comment_id']; } else { $prev = prev($comments); $parent = $prev['parent_id']; if ($parent != 0) { $id = find_parent_id_0 (key($comments), $comments, $array2); } else { $id = $prev['comment_id']; } } return $id; } I also made that array you suggested like this: $array2 = array(); foreach ($comments as $k => $comment) { $array2[$comment['comment_id']] = $k; } but Im not using it >.< It appears to work though. any comments?
  12. Hey freakers, I am stumbling upon a problem I dont know how to solve, so here it is. Its something of a luxery problem, even if I cant fix it I dont mind. However, I would like to know if its possible. What I would like is this. I have this array: Array ( [0] => Array ( [comment_id] => 1 [user] => Array ( [id] => 1 [name] => Davey Kulter [avatar] => /assets/img/user_images/1_avi.jpg ) [parent_id] => 0 [time] => March 19th, 5:24AM [content] => Some text ) [1] => Array ( [comment_id] => 2 [user] => Array ( [id] => 2 [name] => Jason Biondo [avatar] => /assets/img/user_images/2_avi.jpg ) [parent_id] => 1 [time] => March 19th, 5:24AM [content] => Some text ) [2] => Array ( [comment_id] => 5 [user] => Array ( [id] => 3 [name] => Rudolph [avatar] => /assets/img/user_images/3_avi.jpg ) [parent_id] => 1 [time] => March 19th, 5:45AM [content] => Some text ) [3] => Array ( [comment_id] => 6 [user] => Array ( [id] => 1 [name] => Davey Kulter [avatar] => /assets/img/user_images/1_avi.jpg ) [parent_id] => 1 [time] => March 19th, 5:45AM [content] => Some text ) [4] => Array ( [comment_id] => 4 [user] => Array ( [id] => 1 [name] => Davey Kulter [avatar] => /assets/img/user_images/1_avi.jpg ) [parent_id] => 2 [time] => March 19th, 5:25AM [content] => Some text ) [5] => Array ( [comment_id] => 3 [user] => Array ( [id] => 3 [name] => Rudolph [avatar] => /assets/img/user_images/3_avi.jpg ) [parent_id] => 0 [time] => March 19th, 5:25AM [content] => Some text ) [6] => Array ( [comment_id] => 7 [user] => Array ( [id] => 1 [name] => Davey Kulter [avatar] => /assets/img/user_images/1_avi.jpg ) [parent_id] => 0 [time] => March 19th, 7:47AM [content] => Some text ) ) This is an array of comments on a blog. Regardless, I would like to focus this area in specific: Array ( [0] => Array ( [comment_id] => 1 [user] => Array ( [id] => 1 [name] => Davey Kulter [avatar] => /assets/img/user_images/1_avi.jpg ) [parent_id] => 0 [time] => March 19th, 5:24AM [content] => Some text ) [1] => Array ( [comment_id] => 2 [user] => Array ( [id] => 2 [name] => Jason Biondo [avatar] => /assets/img/user_images/2_avi.jpg ) [parent_id] => 1 [time] => March 19th, 5:24AM [content] => Some text ) [2] => Array ( [comment_id] => 5 [user] => Array ( [id] => 3 [name] => Rudolph [avatar] => /assets/img/user_images/3_avi.jpg ) [parent_id] => 1 [time] => March 19th, 5:45AM [content] => Some text ) [3] => Array ( [comment_id] => 6 [user] => Array ( [id] => 1 [name] => Davey Kulter [avatar] => /assets/img/user_images/1_avi.jpg ) [parent_id] => 1 [time] => March 19th, 5:45AM [content] => Some text ) [4] => Array ( [comment_id] => 4 [user] => Array ( [id] => 1 [name] => Davey Kulter [avatar] => /assets/img/user_images/1_avi.jpg ) [parent_id] => 2 [time] => March 19th, 5:25AM [content] => Some text ) ) as you can see from parent_id, the first is a comment and the rest are replies to that comment (I only allow one level of replies, so no reply to a reply). However, if I loop through this array in a foreach() loop and I am at array key [4], how do I find out what the comment_id of the previous array key where parent_id = 0. SO, what I would like is a function that would, in this case, return id = 1. If I dont make sense, I am sorry. Its quite weird xD Thanks regardless
  13. You rock. What you pointed out makes a lot of sense, and so I changed the .htaccess file: <IfModule mod_rewrite.c> Options +FollowSymlinks RewriteEngine On </IfModule> # If requested resource exists as a file or directory, skip next two rules RewriteCond %{DOCUMENT_ROOT}/$1 -f [OR] RewriteCond %{DOCUMENT_ROOT}/$1 -d RewriteRule (.*) - [s=3] # Blog articles RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^/?blog/([^/]+)/(\d+)$ blog.php?title=$1&id=$2 [L] # Remove the .php extension RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^\.]+)$ $1.php [NC,L] #RewriteCond %{REQUEST_FILENAME} !-f #RewriteCond %{REQUEST_FILENAME} !-d #RewriteRule ^(.*)$ index.php?page=$1 [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ app.php?tag=$1 [QSA,L] # ---------------------------------------------------------------------- # Custom 404 page # ---------------------------------------------------------------------- # You can add custom pages to handle 500 or 403 pretty easily, if you like. ErrorDocument 403 /error.php?type=403 ErrorDocument 404 /error.php?type=404 ErrorDocument 500 /error.php?type=500 And this works. Thank you so much. EDIT: PS, if you have any suggestions as to how this can be tidied up, I would still be more than willing to implement them. As long as it works
  14. Nope, no success. One thing I would like to point out is that, in your clean up, something was removed and I suddenly had 404's everywhere. So I restored to the old version and added the rule you suggested, leading to this .htaccess: <IfModule mod_rewrite.c> Options +FollowSymlinks RewriteEngine On </IfModule> # If requested resource exists as a file or directory, skip next two rules RewriteCond %{DOCUMENT_ROOT}/$1 -f [OR] RewriteCond %{DOCUMENT_ROOT}/$1 -d RewriteRule (.*) - [s=2] # Remove the .php extension RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^\.]+)$ $1.php [NC,L] # Blog articles RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^/?blog/([^/]+)/(\d+)$ blog.php?title=$1&id=$2 [L] #RewriteCond %{REQUEST_FILENAME} !-f #RewriteCond %{REQUEST_FILENAME} !-d #RewriteRule ^(.*)$ index.php?page=$1 [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ app.php?tag=$1 [QSA,L] # ---------------------------------------------------------------------- # Custom 404 page # ---------------------------------------------------------------------- # You can add custom pages to handle 500 or 403 pretty easily, if you like. ErrorDocument 403 /error.php?type=403 ErrorDocument 404 /error.php?type=404 ErrorDocument 500 /error.php?type=500 Sadly, this still doesnt work. I hate this language, whatever it is.I can never get it to work properly. EDIT: grammar
  15. All one way algorythms are identifiable by their original text, otherwise they have no use. I would personnally always use crypt(), but you wont make it to 8 characters. WHy 8 characters?
  16. My whole life was a lie. Well, everyone has their methods EDIT: But I trust Christians method > my method. Just expressing my concern
  17. I just realized the .htaccess displayed in the previous post was not right. heres the right one Options +FollowSymlinks <IfModule mod_rewrite.c> RewriteEngine On # Remove the .php extension RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule ^([^.]+)$ $1.php [NC,L] # Blog articles RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^/?blog/([^/]+)/(\d+)$. blog.php?title=$1&id=$2 [L] #RewriteCond %{REQUEST_FILENAME} !-f #RewriteCond %{REQUEST_FILENAME} !-d #RewriteRule ^(.*)$ index.php?page=$1 [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ app.php?tag=$1 [QSA,L] </IfModule> # ---------------------------------------------------------------------- # Custom 404 page # ---------------------------------------------------------------------- # You can add custom pages to handle 500 or 403 pretty easily, if you like. ErrorDocument 403 /error.php?type=403 ErrorDocument 404 /error.php?type=404 ErrorDocument 500 /error.php?type=500 the result is the same though
  18. Im pretty sure the total the OP is referring to are total per day, so that wont return the totals for the entire week, but rather the totals per day.
  19. What is your date? Is it a datestamp, timestamp, unix_timestamp, datetime? I suggest you look into SUM() in SQL
  20. remember, english you still use the exit(); after a redirect and validate the variable you use in queries
  21. In addition, since you've requested a script for learning purposes, I would suggest an extended tutorial. This is a video series by alex garett from phpacademy. Its very large, you can cut to the episodes you want if you like. Dont take all he says for granted, even he makes mistakes, but the logic behind it is great for leaning. Its much better fro learning then copy pasting.
  22. Can't say I see anything wrong with it... the redirect at least. However, I would use something like this: if($result){ header("Location: /index.php"); exit(); I dont know if it makes a difference, but I dont see why you shouldnt give it a shot. On a side note.... For security sake, dont ever use a variable in a query without at least validating it. You can read more about validation on php.net, look into mysql_real_escape_string() as well as htmlentities(), like such: $name = mysql_real_escape_string(htmlentities($_POST['name'])); $url = mysql_real_escape_string(htmlentities($_POST['url']));
  23. I see. Can you show the script that handles the creation of links, particularly the lines around the redirect? Also, you dont just have this issue with adding/creating links, its also occuring on editing/removing them.
  24. Well, again thanks for the suggestion, but I tried what you mentioned ^/?blog/([^/]+)/(\d+)$. (both with and without that last dot, didnt know if that was an error or not). Leading to this .htaccess file: Options +FollowSymlinks <IfModule mod_rewrite.c> RewriteEngine On # Remove the .php extension RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule ^([^.]+)$ $1.php [NC,L] # Blog articles # RewriteCond %{REQUEST_FILENAME} !-f # RewriteCond %{REQUEST_FILENAME} !-d # RewriteRule ^/?blog/([^/]+)/(\d+)$ blog.php?title=$1&id=$2 [L] #RewriteCond %{REQUEST_FILENAME} !-f #RewriteCond %{REQUEST_FILENAME} !-d #RewriteRule ^(.*)$ index.php?page=$1 [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ app.php?tag=$1 [QSA,L] </IfModule> # ---------------------------------------------------------------------- # Custom 404 page # ---------------------------------------------------------------------- # You can add custom pages to handle 500 or 403 pretty easily, if you like. ErrorDocument 403 /error.php?type=403 ErrorDocument 404 /error.php?type=404 ErrorDocument 500 /error.php?type=500 this is the version where I left the dot (.) out. Sadly, $_SERVER says: [REQUEST_URI] => /blog/title/1 [sCRIPT_NAME] => /app.php [php_SELF] => /app.php Im sorry for being such a pain in the.... but I dont know whats wrong
  25. I dont think you need the extra slash '/'. Just to summarize, this code: if($result) { header("Location: /index.php"); will infact give this url: /index.php/voegtoe.php ?
×
×
  • 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.