Jump to content


  • Posts

  • Joined

  • Last visited

Posts posted by hitman6003

  1. What other text? The variable assignments aren't printed to the screen...the contents of the variable may/may not be echo'd or printed to the screen.


    I'm surprised that your sessions and redirect headers are working since there is data being sent to the browser before those are called.

  2. what if I wanted to use this for say, checking which users read a forum thread. If new post in thread update the list of ids to blank VS having to delete 1,000s of rows in "users_who_havent_read_thread" table; would that be efficient.

    It's always easier to store who has seen something like a thread than who hasn't. I've never looked at phpBB's code, but I would imagine they associate the user to the thread when it's been read. So, when I click on it, a row in a table is inserted that says "hitman6003 has read thread xyz at 0230GMT".

  3. but with 1,000 players each having 100 friends, that's 100,000 rows.

    meh... Are you hurting for space, than an extra MB or two (cause a row of 2 int columns doesn't take much room) is really gonna make a difference?


    Use an index and don't worry about it.


    Doing it the second way, if you wanted to query "Who's friends list is user 123 on?", you would have to query an expand everyone's list to get that information.

  4. The HTML input tag does not have an image type that is also a submit button.

    well...after further investigation, I appear to be wrong about that.


    I think the problem is that you are checking for "$_POST['submit']" to exist, but the image input type doesn't pass a value.

  5. if you start with the object style mysqli, you have to use it...can't switch between them...so your use of mysql_i_connect_error() won't ever return anything.


    Aside from that, add in some debug to check for expected results:


    function login($username, $password) {
    	$con = new mysqli("db_server.com", 'User', 'plain text password', 'whateverdb');
    	if ($con->connect_errno) {
    	$pass = md5($password);
    	$query = "SELECT * FROM user WHERE username = '$username' AND password = '$pass'";
    	if ($result = $mysqli->query($query)) {
    		if ($result->num_rows > 0) {
    			print "<pre>got the following results:\n\n";
    			while ($row = $result->fetch_assoc()) {
    		} else {
    			print "no rows were returned!";
    	} else {
  6. You're still not using the mysqli object correctly...it has four options: hostname, username, password, database.




    mysql_error will not work when using mysqli...use mysqli->connect_error or mysqli_connect_error().




    You're using "mysql_query" instead of the mysqli object's "query" method.




    $con= mysqli(whateverwebsite.com, 'Nameofthetable', 'hashedmd5password') or die (mysql_error());


    If you are going to use it like that, you'll need to adopt the object oriented style...


    $con = new mysqli($host, $user, $pass, $database);
    $result = $con->query("SELECT something FROM somewhere");
    if ($result->num_rows > 0) {
      while ($row = $result->fetch_assoc()) {
        echo $row['something'] . "\n";
  8. Add some debug output to your code and make sure that what you expect to happen is happening...


    //at the start of each page have:
    print "<pre>The contents of session are:\n" . print_r($_SESSION, 1);
    function login($username, $password){
      print "\n At function login with username $username";
      if ($count==1) {
        print "\nThe user was found";
        // this won't work because we've already output something to the browser
        header('Location:Aggiornamenti/Aggiornamenti.php'); /*this doesn't actually work*/
      } else {
        header('Location:index.php'); /*this doesn't actually work*/
        echo "Wrong login"; 
  9. Not sure if it affects the header or not, but I've always used a space between the colon and the location. Also, use an exit after the location header to stop execution (otherwise the php will continue to execute, even though you are redirecting the user.


    header("Location: some/page.php");
    I *think* leaving off the exit, if there is code further down that sends something to the browser, it will cause the location redirect to fail.
  10. Also check out the natsort function.


    Alternatively, you could brute force it with some loops...


    foreach ($results as $result) {
    	list($a, $b) = explode("/", $result);
    	$data[$a][] = $b;
    foreach (ksort($data) as $key => $values) {
    	foreach (sort($value) as $x) {
    		print $key . "/" . $x;
    Not exactly elegant though.
  11. Is any error output?


    Try adding some debug output...for example, check your $_POST and query:


    print '<pre>' . print_r($_POST, 1);
    print "my query is:
    INSERT INTO comments (id, userid, topicid, topicname, comment, date, name) 
      VALUES (
        '$content[name] Profile', 
    Does it look like you expect it to?
  • 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.