Jump to content

syntax error


aebstract

Recommended Posts

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

Link to comment
Share on other sites

$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());

 

Both of those have an extra ' after the last 0.

 

And in this section:

('$dataArray[$i][0]', '0', '2', '', '0', '', '$dataArray[$i][3]', '$dataArray[$i][1]', '$dataArray[$i][1]'

 

You need to encapsulate arrays (when accessing multiple dimensions) in curly braces:

('{$dataArray[$i][0]}', '0', '2', '', '0', '', '{$dataArray[$i][3]}', '{$dataArray[$i][1]}', '{$dataArray[$i][1]}',

 

See if those help you out.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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