Jump to content

RickXu

Members
  • Posts

    14
  • Joined

  • Last visited

    Never

About RickXu

  • Birthday 07/18/1981

Contact Methods

  • MSN
    riconxu@hotmail.com
  • Website URL
    http://www.rickxu.com

Profile Information

  • Gender
    Male
  • Location
    England

RickXu's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. If the page you call foo() has included the file, the global would still work although it's not neat. Like xyph suggested, you should stick to functions and returns or even consider putting them into classes if necessary.
  2. if(!preg_match('/{3,20}/', $username)) As the error suggested, this line is not right. You may consider checking the preg_match and regular expression. I'd write the regex as: /^[\w]{3,12}$/im Hope it helps.
  3. $sql = mysql_query( "SELECT * FROM users WHERE id='".$_SESSION['id']."'" ); This is not quite to my eyes. I'd suggest you use sprintf all the time as technically you don't need quotes for integers, only string needs quotes around. So I'd write the query like this: $query = sprintf("SELECT * FROM users WHERE id = %d", $_SESSION['id']); $result = mysql_query($query, $conn) or die(mysql_error()); For references of sprintf, please see http://uk.php.net/manual/en/function.sprintf.php It's my practice anyway.
  4. If you do have `user_id` in your `images` table, you can easily get around this by query: SELECT `images`.`img`, COUNT(`images`.`id`) AS count_img, `users`.* FROM `images` LEFT JOIN `users` ON `images`.`user_id` = `users`.`id` GROUP BY `images`.`user_id` In this way, users who didn't upload any image wouldn't even be included in the return results. Not sure if this is what you're expecting.
  5. You may still use your own logic or adapt the solutions offered by the above two. From regular expression point of view, This may help. $result = preg_replace('/^([\w]{4})([\w]{4})([\w]{4})$/sim', '\1-\2-\3', $subject);
  6. while($row = mysql_fetch_array($sql)) { $user = $id; echo "<h2>Profile</h2> <table>"; The problem is here. You've got 2 fetches and the second one would return empty. So if you get rid of the second $row = mysql_fetch_array($sql), it should all show up.
  7. Both cases are technically not wrong but really depends on what your ajax request returns. For stuff like this, you could use jQuery to handle the ajax. 100% worry free and it would look more professional too. But still you need to be clear what you expect to receive from the ajax request.
  8. if(!empty($_GET['id'])) { echo "ID not gotten from myprofile.php"; } else { echo "ID Retreived"; $id = $_GET['id']; } This logic is wrong. Get rid of ! in the if statement and you should be good to go.
  9. There's no $sql_user_verify defined anywhere unless it's included. Might be an idea to turn on your error reporting for debugging purpose.
  10. Could you do a var_dump of $query_check_credentials first to start your debug please?
  11. If your 'correct' is returned as string, the if statement would always be true. Try: if(correct == 'true') or try to handle it in a different way.
  12. You didn't execute your queries, did you?
  13. You may try change the character set to utf8 and collation to utf8_unicode_ci Change both settings for the specific table and field.
  14. This is a joke, right? People here have seen how much help MadTechie has offered over the past few year. The problem is that some people never understand or even bother to learn how to ask for help. Coding wise, if you don't debug, or simply put, if you don't read your error messages and post back to the person who has been trying to help you with the returned errors. What are you expecting? I feel sorry for myself wasting my very virgin post...
×
×
  • 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.