Jump to content

PHPFAN10

Members
  • Posts

    74
  • Joined

  • Last visited

Profile Information

  • Gender
    Male

PHPFAN10's Achievements

Member

Member (2/5)

0

Reputation

  1. Hi, Managed to solve it, I changed it to: RewriteRule ^verify/([a-z0-9]+)?$ user-verify.php?key=$1 [NC,L] and did not add the: RewriteCond %{ENV:x} !yes Thanks AyKay47, much appreciated, without your example i could not have sorted it, much appreciated. Thanks phpfan
  2. Hi, I have a url like: http://www.example.com/user-verify.php?key=(40 alphanumeric characters here) I want to Rewrite it so it displays like this: http://www.example.com/verify/(40 alphanumeric characters here) Could anyone help in making the Rewrite Rule please ? I did look at the cheat sheet in sticky and cannot work it out. Note sure if it makes any difference to the RewriteRule, but i want it so if someone types url in like: http://www.example.com/verify/ (without a 40 char key) it will load the user-verify.php page still, as my php code displays an invalid activation key if one has not been specified. Whilst i am at it, can i ask how i stop links in my posts being automatically linked ? , i'm sure someone said to me use example.com so they don't get parsed as urls but seems to be parsing them for me. Thank you, phpfan
  3. Hi, Thanks for your time and effort, i marked this topic solved as i am getting help somewhere else on it now, dont mean to sound nasty or anything by that. Something on what you posted: activation key is always 40 characters in length as i use sha1, therefore because it will always be the same length you would use CHAR(40) not VARCHAR(150) as your wasting space and although i don't know all the technicalities, it's poor practice/design and to my knowledge can slow down the database. Using $_REQUEST, now i'm no expert but i always learnt to avoid using $_REQUEST as much as possible, i use $_POST, $_GET, $_COOKIE individually when needed. Also i am not using the old mysql, i am using PHP PDO. But thanks, still appreciate all your time and effort. phpfan
  4. What do you mean exactly ? perhaps giving an example, if that is ok of course. As mentioned, this code is how you put PDO into exception mode: $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); When you do that, then whenever there is an error PDO will throw a PDOException which will then be caught by your try/catch block. Great! Thanks so much for explaining .... So basically because i have PDO in exception mode, i don't need to do if statement on execute() because if it failed it will be caught by the catch block ? and then my function will obviously log it. To my understanding now, use try and catch blocks when i want to catch an error, not nessecary syntax errors because obviously they should be fixed in development with php errors to display all errors and log them, but i guess if i'm thinking rite now that use try and catch blocks when theres a possibility that something may not happen or go as planned and by using a try and catch block we can catch the error and log it. I hope i am thinking rite now after your much appreciated effort in explaining to me. I'm hopeless at explaining and can confuse people so sorry if i have done. Thanks, phpfan
  5. Hi, Thanks for the reply much appreciated. When you say: What do you mean exactly ? perhaps giving an example, if that is ok of course. Basically in the sample code i gave, in the catch block i call a function ExceptionErrorHandler() this basically logs an error to file. Apart from that i have not changed any configuration options so PDO to use exceptions, not sure what you mean exactly by that ? and when you say When you say using exception mode, do you mean ... using try and catch block ? again sorry if i sound dumb. In my sql_con() function i have it set to: $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); So you know what my ExceptionErrorHandler does, i have provided it below: ( i use the below function in a catch block so i can catch an error and log it to a .txt file and display a friendly message to user and not any valuable details thats could compromise my database for example) <?php #################################### # Exception Handler Error Function # #################################### function ExceptionErrorHandler ($e) { // get pdo error log location to store pdo errors in global $pdo_exception_error; // display user friendly error message echo '<h2>Holy Mother of God </h2>'; echo '<p>Don\'t get angry and don\'t cry. We was unable to fulfill your request at this time. Please try again. '; echo 'If the problem persists please try again later.</p>'; // log all the below errors, do not show to users $e->getMessage(); // get error code, 0, as we didn't pass a code along as second parameter $e->getCode(); // location of file $e->getFile(); // get line error occured on $e->getLine(); // get current date time (server set date/time) and add to error $date = date('d/m/Y H:i:s'); // log error to file // file name and location, can be altered in config.php $FileName = $pdo_exception_error; // open file for writing; a = append to file (keeps any existing date in file and appends to it) $FileHandle = fopen($FileName, 'a'); // write error to file fwrite($FileHandle, "[$date] - ".$e."\n\n"); // close file after finishing with it fclose($FileHandle); } ?> Thanks for your time and help, much apprecaited! phpfan
  6. Hi, I did put a key in the quotes intentially on this line users_status.user_activation_key = ' ' i put a key in it knowing it exists in database aswell, this part .USER_STATUS_ACTIVE.", that is a constant from the constants.php file and is included and does work. I have asked on another site and i we are getting close to the problem but thanks for helping, much appreciated! Cheers! phpfan. PS: Yeah reading other peoples scripts is a great way to learn web development and then testing yourself is the only real way you will ever get to understand how something works, hence why i love the challenge.
  7. Hi, I will take a look so i can study the code and learn from it but the only way to learn is by doing it yourself i love a challenge, i could use many scripts but love the challenge doing it myself. But thanks for the links will take a good look at them Also will mark this topic solved as know why im getting that error. Thanks phpfan
  8. Well, it was working to some extent but not quite now in my actual php code for some reason, getting an error: [15/04/2012 18:24:34] - exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '' for key 'user_activation_key'' in C:\wamp\www\user-verify.php:53 Stack trace: #0 C:\wamp\www\user-verify.php(53): PDOStatement->execute(Array) #1 {main} Not sure why as the user activation key column is unique so not sure what it means Doh! but to answer your question, i did build a fully pledged member system site when i first started to learn PHP, since then i have learnt a ton and decided to do another membership site based on web development, but with better database design, more efficent coding, using PHP PDO etc, not learnt OOP yet and won't be until i feel i have learnt more about PHP PDO first.
  9. YAY! This worked, thank you! I remove the ticks ` and its all dandy now UPDATE users JOIN users_status ON users_status.user_activation_key = '959e1a8dc42fd836a84160a7ec45ad12221fef3c' SET users.user_status = 1, users_status.user_activation_key = NULL WHERE users_status.user_uid = users.user_uid Thank you! phpfan
  10. I dont know what happened then, I tried with the WHERE clause aswell and got same error. [Err] 1054 - Unknown column 'users.user_status' in 'field list' UPDATE `users` JOIN `users_status` ON `users_status.user_activation_key` = '959e1a8dc42fd836a84160a7ec45ad12221fef3c' SET `users.user_status` = 1, `users_status.user_activation_key` = NULL WHERE `users_status.user_uid` = users.user_uid Thanks phpfan
  11. Hi, If i remove the LIMIT 1, i get the following error: [Err] 1054 - Unknown column 'users.user_status' in 'field list' Now this table does 100% infact exist on the `users` table. I think it is trying to look in the wrong place maybe in the query Thanks phpfan
  12. Hi, I run the query in Navicat and entered an activation key that i knew existed in database to see if it would work and got the following error: [Err] 1221 - Incorrect usage of UPDATE and LIMIT UPDATE `users` JOIN `users_status` ON `users_status.user_activation_key` = '959e1a8dc42fd836a84160a7ec45ad12221fef3c' SET `users.user_status` = 1, `users_status.user_activation_key` = NULL AND `users_status.user_uid` = `users.user_uid` LIMIT 1 Thank you, phpfan
  13. Hi, This query would not work because there is no ON clause. It can only be allowed to update based on the condition that the `user_activation_key` in the `users_status` can be found based on value from $_GET and also based on the condition that the `user_uid` in the `users_status` table matches the `user_uid` on the `users` table, these condtions need to match. The query you gave has no ON clause. Thanks for your help.
×
×
  • 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.