Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8991863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:49:31+00:00 2026-06-15T22:49:31+00:00

I have a large SQL file I’m trying to insert into the database. It

  • 0

I have a large SQL file I’m trying to insert into the database. It wouldn’t work via phpMyAdmin since it was so large, so I created a custom script:

<?php

ini_set('max_execution_time', 0);

$file = file_get_contents('./mySQLfile.sql');

//var_dump($file); die();

$conn = new mysqli('localhost', 'myUserName', 'myPassword', 'myDatabase');

$q = $file;

if ($result = $conn->query($q))
{
    echo '<font color="red">'.$conn->error.'</font>';
    echo '<br />';
}

?>

The file var_dump()’s properly. The connection to the database is created (I’ve tested it by returning values from the database). However, when I run the code, no data is inserted into the database. The beginning of the SQL file is as follows:

-- phpMyAdmin SQL Dump
-- version 3.4.5
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Dec 05, 2012 at 04:01 PM
-- Server version: 5.5.16
-- PHP Version: 5.3.8

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;

--
-- Database: `myDatabase`
--

-- --------------------------------------------------------

--
-- Table structure for table `content_field_image_cache`
--

CREATE TABLE IF NOT EXISTS `content_field_image_cache` (
  `vid` int(10) unsigned NOT NULL DEFAULT '0',
  `nid` int(10) unsigned NOT NULL DEFAULT '0',
  `delta` int(10) unsigned NOT NULL DEFAULT '0',
  `field_image_cache_fid` int(11) DEFAULT NULL,
  `field_image_cache_list` tinyint(4) DEFAULT NULL,
  `field_image_cache_data` text,
  PRIMARY KEY (`vid`,`delta`),
  KEY `nid` (`nid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `content_field_image_cache`
--

INSERT INTO `content_field_image_cache` (`vid`, `nid`, `delta`, `field_image_cache_fid`, `field_image_cache_list`, `field_image_cache_data`) VALUES
(1000, 1000, 0, 1000, 1, NULL),
(1001, 1001, 0, 1001, 1, NULL),
(1002, 1002, 0, 1002, 1, NULL),

Why won’t these values get inserted?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T22:49:32+00:00Added an answer on June 15, 2026 at 10:49 pm

    PHP’s mysql driver (mysql/mysqli/pdo) doesn’t allow multiple queries in a single call as a security measure. You cannot feed an entire dump into a single query call like that.

    You’d be better off simply doing something like

    exec("mysql -u xxx -p < dump.sql");
    

    instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a large sql dump file ... with multiple CREATE TABLE and INSERT
I have a large database dump.sql file I am importing from the command line
When I try to paste a large(5000 lines) sql file into PhpMyAdmin, I get
I am trying to import a large CSV file into a MySQL database. I
I have a rather large SQL file which starts with the byte order marker
Hello I have a very large SQL script and while trying to execute it
I have a .SQL file containing a large number of queries. They are being
I have the following MySQL install SQL file. What I'm trying to do is
I have a large file from 2007 containing a backup (as a SQL Script)
I have a rather large database exposed to my application using LINQ-to-SQL. I need

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.