Jump to content

aebstract

Members
  • Posts

    1,105
  • Joined

  • Last visited

Posts posted by aebstract

  1. <?php
    if(empty($_POST)) exit;
    
    include 'config.php';
    include_once 'connect.php';
    
    // declare post fields
    
    $post_username = $_POST['username'];
    $post_password = $_POST['password'];
    
    $post_autologin = $_POST['autologin'];
    
      $query = "select username, password from app_members where username='$post_username' and password='$post_password'";
      $result = mysql_query($query) or die("Could not query players");
      $result2 = mysql_fetch_array($result);
      if ($result2)
      {
        $_SESSION['username'] = $post_username;
    
    // Autologin Requested?
    
    if($post_autologin == 1)
    
    
    
    {
    
    
    
    
    
    
    setcookie ($cookie_name, 'usr='.$config_username, time() + $cookie_time);
    
    
    
    }
    
    exit('OK');
    }
    else
    {
    echo '<div id="error_notification">The submitted login info is incorrect.</div>';
    }
    ?>

     

    You weren't telling it to check password vs the password column.

  2. [sat Mar 06 12:03:07 2010] [error] [client 12.248.157.94] PHP Notice:  Undefined offset:  0 in /var/www/vhosts/outlawracing.com/httpdocs/insert.php on line 48
    [sat Mar 06 12:03:07 2010] [error] [client 12.248.157.94] PHP Notice:  Undefined offset:  0 in /var/www/vhosts/outlawracing.com/httpdocs/insert.php on line 49
    [sat Mar 06 12:03:07 2010] [error] [client 12.248.157.94] PHP Notice:  Undefined offset:  0 in /var/www/vhosts/outlawracing.com/httpdocs/insert.php on line 50
    [sat Mar 06 12:03:07 2010] [error] [client 12.248.157.94] PHP Notice:  Undefined offset:  0 in /var/www/vhosts/outlawracing.com/httpdocs/insert.php on line 51
    [sat Mar 06 12:03:07 2010] [error] [client 12.248.157.94] PHP Notice:  Undefined offset:  0 in /var/www/vhosts/outlawracing.com/httpdocs/insert.php on line 52
    [sat Mar 06 12:03:07 2010] [error] [client 12.248.157.94] PHP Notice:  Undefined offset:  0 in /var/www/vhosts/outlawracing.com/httpdocs/insert.php on line 53
    [sat Mar 06 12:03:07 2010] [error] [client 12.248.157.94] PHP Notice:  Undefined offset:  0 in /var/www/vhosts/outlawracing.com/httpdocs/insert.php on line 54
    [sat Mar 06 12:03:07 2010] [error] [client 12.248.157.94] PHP Notice:  Undefined offset:  0 in /var/www/vhosts/outlawracing.com/httpdocs/insert.php on line 55
    [sat Mar 06 12:03:07 2010] [error] [client 12.248.157.94] PHP Notice:  Undefined offset:  0 in /var/www/vhosts/outlawracing.com/httpdocs/insert.php on line 56
    [sat Mar 06 12:03:07 2010] [error] [client 12.248.157.94] PHP Notice:  Undefined offset:  0 in /var/www/vhosts/outlawracing.com/httpdocs/insert.php on line 57
    

     

    This is a continuation of the other post, though the memory issue has been taken care of. How does an undefined offset: 0 error come up? I need to get it fixed.

     

    Here is my entire script I am running:

     

    <?php
    error_reporting(E_ALL);
    ini_set("display_errors", 1);
    include_once "connect.php";
    
    
    
    
    
    $textData = file('array2.txt');
    
    $dataArray = array();
    $tempArray = array();
    $array_start = false;
    
    foreach ($textData as $line)
    {
       if ($array_start && preg_match("/\[([^\]]*)\] => (.*)/", $line, $keyValue)!= 0)
       {
          $tempArray[$keyValue[1]] = $keyValue[2];
       }
    
       if(substr($line, 0, 1)=='(')
        {
          $array_start = true;
       }
    
       if(substr($line, 0, 1)==')')
        {
          $array_start = false;
          $dataArray[] = $tempArray;
          $tempArray   = array();
       }
    }
    
    $arraycount = count($dataArray);
    
    
    for ($i = 0; $i <= $arraycount; $i++) {
    
    
    $dataArray0 = $dataArray[$i][0];
    $dataArray1 = $dataArray[$i][1];
    $dataArray2 = $dataArray[$i][2];
    $dataArray3 = $dataArray[$i][3];
    $dataArray4 = $dataArray[$i][4];
    $dataArray5 = $dataArray[$i][5];
    $dataArray6 = $dataArray[$i][6];
    $dataArray7 = mysql_real_escape_string($dataArray[$i][7]);
    $dataArray8 = $dataArray[$i][8];
    $dataArray9 = $dataArray[$i][9];
    $dataArray10 = $dataArray[$i][10];
    $dataArray11 = $dataArray[$i][11];
    $dataArray12 = $dataArray[$i][12];
    $dataArray13 = $dataArray[$i][13];
    $dataArray14 = $dataArray[$i][14];
    $dataArray15 = $dataArray[$i][15];
    
    
    }
    
    
    ?>
    

     

    The errors I got were sent to me from my web host, I get a solid white blank page.

  3. I got an email from my host and he said this is the error that was being displayed:

    [sat Mar 06 12:03:07 2010] [error] [client 12.248.157.94] PHP Notice:  Undefined offset:  0 in /var/www/vhosts/outlawracing.com/httpdocs/insert.php on line 48
    [sat Mar 06 12:03:07 2010] [error] [client 12.248.157.94] PHP Notice:  Undefined offset:  0 in /var/www/vhosts/outlawracing.com/httpdocs/insert.php on line 49
    [sat Mar 06 12:03:07 2010] [error] [client 12.248.157.94] PHP Notice:  Undefined offset:  0 in /var/www/vhosts/outlawracing.com/httpdocs/insert.php on line 50
    [sat Mar 06 12:03:07 2010] [error] [client 12.248.157.94] PHP Notice:  Undefined offset:  0 in /var/www/vhosts/outlawracing.com/httpdocs/insert.php on line 51
    [sat Mar 06 12:03:07 2010] [error] [client 12.248.157.94] PHP Notice:  Undefined offset:  0 in /var/www/vhosts/outlawracing.com/httpdocs/insert.php on line 52
    [sat Mar 06 12:03:07 2010] [error] [client 12.248.157.94] PHP Notice:  Undefined offset:  0 in /var/www/vhosts/outlawracing.com/httpdocs/insert.php on line 53
    [sat Mar 06 12:03:07 2010] [error] [client 12.248.157.94] PHP Notice:  Undefined offset:  0 in /var/www/vhosts/outlawracing.com/httpdocs/insert.php on line 54
    [sat Mar 06 12:03:07 2010] [error] [client 12.248.157.94] PHP Notice:  Undefined offset:  0 in /var/www/vhosts/outlawracing.com/httpdocs/insert.php on line 55
    [sat Mar 06 12:03:07 2010] [error] [client 12.248.157.94] PHP Notice:  Undefined offset:  0 in /var/www/vhosts/outlawracing.com/httpdocs/insert.php on line 56
    [sat Mar 06 12:03:07 2010] [error] [client 12.248.157.94] PHP Notice:  Undefined offset:  0 in /var/www/vhosts/outlawracing.com/httpdocs/insert.php on line 57
    

  4. Okay, I have my memory_limit set to 100M now, I am getting now errors but am still getting a blank white page. I have an echo statement ABOVE my file() and it isn't getting displayed either. Could something in the file be causing it to do this? If so, what would trigger such an event? Wouldn't I still get information up until the point that it causes error? The smaller file still works, the larger one is just blanking out.

  5. A far more useful solution would be to go through the file (often line-by-line) so as to only load a small portion of it into memory at any one time.  Unless there is some particular need to load 71 MB into memory every time the script is executed, I would advise against it.  I'd also echo the others' suggestion of enabling and displaying all errors during development.

     

    I placed this at the top:

    error_reporting(E_ALL);
    ini_set("display_errors", 1);
    

     

    but, with the .htaccess fix I mentioned above, I'm not getting an error just white space. I could do it one line at a time, but not too sure where to start as to write that, as right now I have a little function to do some array work so I can loop through every value and insert it in to the database. This is going to be a one time access deal, then it will be trashed and never ran again.

  6. Sorry for not running that, which was completely stupid:

    Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 75023834 bytes) in /var/www/vhosts/outlawracing.com/httpdocs/insert.php on line 8

     

    Is this something I can change or do I have to have my host change it?

  7. Okay, this script:

    <?php
    $textData = file('array.txt');
    echo "hello";
    ?>
    

     

    hello is echo'd to the browser, no problems. If I change array.txt to array2.txt, it gives a white page and doesn't seem to even try to do anything.

    array.txt is just under 1MB

    array2.txt is just over 71MBs

     

    Is there a limit on file size that can be opened? Cause I don't think it's hitting something inside and stopping, it seems to not even be attempting to look inside the file. Any other information needed for this problem?

  8. My problem is that I'm pulling a lot of information out of a MSSQL database from one setup in to a new setup in a MYSQL database. The database structures are already setup, so I can't change them. That's why I'm trying to get the conversion. It's saved as a datetime field where I'm trying to pull from, but I need to enter it in to the new database as a unix timestamp.

     

    edit: Exactly what format should this be put in? Can use some regex or something to get it in the right format to do a clean conversion, no?

  9. $r[5] = strtotime("$r[5]");
    

     

    Returns a timestamp of  1157083500, which is 08 / 31 / 06 @ 11:05:00pm. It's suppose to be Sep 1 2006 12:05AM.

     

     

     

    edit: This gives the same result as just doing strtotime();

    $r[5] = preg_replace('/:[0-9][0-9][0-9]/','',$r[5]);
    $r[5] = strtotime($r[5]);

  10. LOL, That's my code from your other post today. What is the specific line that is producing the error?

     

    In any event that is some VERY inefficient code. First of all you are creating a loop with an artificial limit instead of using the actual count of the array and you only need to do one query to insert all the values.

     

    The error is exactly what I posted. That is all of the information that I get, then a white blank screen. I can post the entire array.txt file as it sits when I get back to work (about 15-20 minutes). mjdamato, I tried to get the serialize to work but I don't have the time to wait, you mentioned this code and it worked. If it is so inefficient, why did you suggest it?

     

    freakstyle: this isn't a select query, inserting information :(

  11. Here is my entire page:

    <?php
    include_once "connect.php";
    
    
    
    $textData = file('array.txt');
    
    $dataArray = array();
    $tempArray = array();
    $array_start = false;
    
    foreach ($textData as $line)
    {
       if ($array_start && preg_match("/\[([^\]]*)\] => (.*)/", $line, $keyValue)!= 0)
       {
          $tempArray[$keyValue[1]] = $keyValue[2];
       }
    
       if(substr($line, 0, 1)=='(')
        {
          $array_start = true;
       }
    
       if(substr($line, 0, 1)==')')
        {
          $array_start = false;
          $dataArray[] = $tempArray;
          $tempArray   = array();
       }
    }
    
    
    for ($i = 0; $i <= 3664; $i++) {
    
    $emailhash = $dataArray[$i][2];
    $emailhash = crc32(strtolower($emailhash)) . strlen($emailhash);
    
    $query = mysql_query("
    INSERT INTO users (user_id, user_type, group_id, user_permissions, user_perm_from, user_ip, user_regdate, username, username_clean, user_password, user_passchg, user_pass_convert,
    user_email, user_email_hash, user_birthday, user_lastvisit, user_lastmark, user_lastpost_time, user_lastpage, user_last_confirm_key, user_last_search, user_warnings, user_last_warning,
    user_login_attempts, user_inactive_reason, user_inactive_time, user_posts, user_lang, user_dst, user_style, user_rank, user_colour, user_new_privmsg,
    user_unread_privmsg, user_last_privmsg, user_message_rules, user_full_folder, user_emailtime, user_topic_show_days, user_topic_sortby_type, user_topic_sortby_dir, user_post_show_days,
    user_post_sortby_type, user_post_sortby_dir, user_notify, user_notify_pm, user_notify_type, user_allow_pm, user_allow_viewonline, user_allow_viewemail, user_allow_massemail, user_options,
    user_avatar, user_avatar_type, user_avatar_width, user_avatar_height, user_sig, user_new, user_reminded, user_reminded_time)
    VALUES ('$dataArray[$i][0]', '0', '2', '', '0', '', '$dataArray[$i][3]', '$dataArray[$i][1]', '$dataArray[$i][1]', '', '', '0',
    '$dataArray[$i][2]', '$emailhash', '', '0', '', '0', '', '', '0', '', '0',
    '0', '0', '0', '$dataArray[$i][4]', 'en', 'dst', '1', '0', '', '0',
    '0', '0', '0', '-3', '0', '0', 't', 'd', '0',
    't', 'a', '0', '1', '0', '1', '1', '1', '1', '230271',
    '', '0', '0', '0', '', '0', '0', '0')
    ") or DIE(mysql_error());
    
    
    $query2 = mysql_query("INSERT INTO user_group (group_id, user_id, group_leader, user_pending) VALUES ('2', '$dataArray[$i][0]', '0', '0'')") or DIE(mysql_error());
    $query3 = mysql_query("INSERT INTO user_group (group_id, user_id, group_leader, user_pending) VALUES ('7', '$dataArray[$i][0]', '0', '0'')") or DIE(mysql_error());
    
    
    
    }
    ?>

     

    What does the error mean? If I know what it's trying to say more clearly, maybe I can get it fixed?

     

    Is it just saying that $dataArray[$i][2] contains a duplicate somewhere? Is that not okay?

  12. Here is my entire page:

    <?php
    include_once "connect.php";
    
    
    
    $textData = file('array.txt');
    
    $dataArray = array();
    $tempArray = array();
    $array_start = false;
    
    foreach ($textData as $line)
    {
       if ($array_start && preg_match("/\[([^\]]*)\] => (.*)/", $line, $keyValue)!= 0)
       {
          $tempArray[$keyValue[1]] = $keyValue[2];
       }
    
       if(substr($line, 0, 1)=='(')
        {
          $array_start = true;
       }
    
       if(substr($line, 0, 1)==')')
        {
          $array_start = false;
          $dataArray[] = $tempArray;
          $tempArray   = array();
       }
    }
    
    
    for ($i = 0; $i <= 3664; $i++) {
    
    $emailhash = $dataArray[$i][2];
    $emailhash = crc32(strtolower($emailhash)) . strlen($emailhash);
    
    $query = mysql_query("
    INSERT INTO users (user_id, user_type, group_id, user_permissions, user_perm_from, user_ip, user_regdate, username, username_clean, user_password, user_passchg, user_pass_convert,
    user_email, user_email_hash, user_birthday, user_lastvisit, user_lastmark, user_lastpost_time, user_lastpage, user_last_confirm_key, user_last_search, user_warnings, user_last_warning,
    user_login_attempts, user_inactive_reason, user_inactive_time, user_posts, user_lang, user_dst, user_style, user_rank, user_colour, user_new_privmsg,
    user_unread_privmsg, user_last_privmsg, user_message_rules, user_full_folder, user_emailtime, user_topic_show_days, user_topic_sortby_type, user_topic_sortby_dir, user_post_show_days,
    user_post_sortby_type, user_post_sortby_dir, user_notify, user_notify_pm, user_notify_type, user_allow_pm, user_allow_viewonline, user_allow_viewemail, user_allow_massemail, user_options,
    user_avatar, user_avatar_type, user_avatar_width, user_avatar_height, user_sig, user_new, user_reminded, user_reminded_time)
    VALUES ('$dataArray[$i][0]', '0', '2', '', '0', '', '$dataArray[$i][3]', '$dataArray[$i][1]', '$dataArray[$i][1]', '', '', '0',
    '$dataArray[$i][2]', '$emailhash', '', '0', '', '0', '', '', '0', '', '0',
    '0', '0', '0', '$dataArray[$i][4]', 'en', 'dst', '1', '0', '', '0',
    '0', '0', '0', '-3', '0', '0', 't', 'd', '0',
    't', 'a', '0', '1', '0', '1', '1', '1', '1', '230271',
    '', '0', '0', '0', '', '0', '0', '0')
    ") or DIE(mysql_error());
    
    
    $query2 = mysql_query("INSERT INTO user_group (group_id, user_id, group_leader, user_pending) VALUES ('2', '$dataArray[$i][0]', '0', '0'')") or DIE(mysql_error());
    $query3 = mysql_query("INSERT INTO user_group (group_id, user_id, group_leader, user_pending) VALUES ('7', '$dataArray[$i][0]', '0', '0'')") or DIE(mysql_error());
    
    
    
    }
    ?>
    

     

    The error:

    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''0'')' at line 1

     

     

     

    EDIT: I just reuploaded my file and refreshed and now I got a new error, don't think it's a mysql error?

    Duplicate entry 'Array[1]' for key 2

  13. Got it to work with this:

    SELECT ordnn_Users.userid, CAST(ordnn_Users.username as varchar), CAST(ordnn_Users.email as varchar), ordnn_UserPortals.CreatedDate, COUNT(ordnn_NTForums_Posts.UserID) AS postcount
    FROM ordnn_Users
    LEFT JOIN ordnn_UserPortals
    ON ordnn_UserPortals.UserID = ordnn_Users.UserID
    LEFT JOIN ordnn_NTForums_Posts
    ON ordnn_NTForums_Posts.UserID = ordnn_Users.UserID
    GROUP BY ordnn_Users.UserID, ordnn_Users.Username, ordnn_Users.email, ordnn_UserPortals.CreatedDate, ordnn_NTForums_Posts.UserID
    

  14. SELECT ordnn_Users.userid, CAST(ordnn_Users.username as varchar), CAST(ordnn_Users.email as varchar), ordnn_UserPortals.CreatedDate
    FROM ordnn_Users
    LEFT JOIN ordnn_UserPortals
    ON ordnn_UserPortals.UserID = ordnn_Users.UserID

     

    This is my current query above. I'm wanting to join a table called ordnn_NTForums_Posts. I'm just needing to get a total of how many rows are in that table where userid = ordnn_users.userid

  15. This code will read the text file and convert it into an array variable.

     

    <?php
      
    $textData = file('array_data.txt');
      
    $dataArray = array();
    $tempArray = array();
    $array_start = false;
      
    foreach ($textData as $line)
    {
       if ($array_start && preg_match("/\[([^\]]*)\] => (.*)/", $line, $keyValue)!= 0)
       {
          $tempArray[$keyValue[1]] = $keyValue[2];
       }
       
       if(substr($line, 0, 1)=='(')
        {
          $array_start = true;
       }
       
       if(substr($line, 0, 1)==')')
        {
          $array_start = false;
          $dataArray[] = $tempArray;
          $tempArray   = array();
       }
    }
      
    print_r($dataArray);
      
    ?>

     

    I was giving the serialize a try, but I don't have the time to get it figure out. This worked and I can easily reference any value in the file now. A while loop will be easy to build with this. Thanks a lot.

×
×
  • 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.