Jump to content

Search the Community

Showing results for tags 'import'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 9 results

  1. HI, Why can't I import a table into my existing DB using the command below: mysql -u root -p mydatabase < file.sql; This has always worked but now I get the following error. mysql version is Thanks !
  2. I have 5 tables that I changed on my development server (laptop) that I'd like to upload to my test server. I can export just those tables from PhpMyAdmin but on import it drops all of the other tables first. Short of editing the SQL before I upload it (finding the drop and deleting it) is there an easy way to uncheck a box and change that behavior that I am just not seeing?
  3. I have some code that I edited for importing csv into mysql using PDO to bind parameters. I thought it was working before, but tested it again and the issue I have is that only one line (the fourth line) of the csv file is getting imported. The first line is the header which are the table field names. The first method below is what's used to parse the csv files and bind the field names with the data. The second method, loops through. I need another pair of eyes, so if anyone can help me figure out my issue, I would greatly appreciated. public function getSQLinsertsArray($sqlTable) { $data = $this->getCSVarray(); $queries = []; $fieldsStr = ""; while(list($k, $field) = each($data)) { if(empty($fieldStr)) $fieldStr = implode(", ", array_keys($field)); //$valueStr = "'".implode("', '", $field)."'"; $placeholders = array_map(function($col) { return ":$col"; }, $field); $bind = array_combine($placeholders,$field); $queries[] = DB::inst()->query("INSERT INTO ".$sqlTable." (".$fieldStr.") VALUES (".implode(",", $placeholders).");",$bind); //error_log(var_export($queries,true)); } return $queries; } public function queryInto($sqlTable) { $queries = $this->getSQLinsertsArray($sqlTable); while(list($k, $query) = each($queries)) { $q = $query; } if($q > 0) { return true; } else { return false; } }
  4. Hello to all!! I really have a problem and i can t find any solution on the web. I'M trying to import in mysql database (using phpmyadmin on windows) a .BIN file. but it doesnt work. I receive this error : MySQL a répondu: Documentation #1064 - 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 ' A?S' at line 1 Any suggestion? thanks a lot
  5. I have found some code that I am trying to work with to import some data from a CSV file into a table of my database. It works and imports the data, but always inserts a NULL row for each column. Here is the code: <?php $self = $_SERVER['PHP_SELF']; $request = $_SERVER['REQUEST_METHOD']; if (!isset($_GET['success'])) { $get_success = ""; } else { $get_success = $_GET['success']; } if (!empty($_FILES)) { /* Format the errors and die */ function get_last_error() { $retErrors = sqlsrv_errors(SQLSRV_ERR_ALL); $errorMessage = 'No errors found'; if ($retErrors != null) { $errorMessage = ''; foreach ($retErrors as $arrError) { $errorMessage .= "SQLState: ".$arrError['SQLSTATE']."<br>\n"; $errorMessage .= "Error Code: ".$arrError['code']."<br>\n"; $errorMessage .= "Message: ".$arrError['message']."<br>\n"; } } die ($errorMessage); } /* connect */ function connect() { if (!function_exists('sqlsrv_num_rows')) { // Insure sqlsrv_1.1 is loaded. die ('sqlsrv_1.1 is not available'); } /* Log all Errors */ sqlsrv_configure("WarningsReturnAsErrors", TRUE); // BE SURE TO NOT ERROR ON A WARNING sqlsrv_configure("LogSubsystems", SQLSRV_LOG_SYSTEM_ALL); sqlsrv_configure("LogSeverity", SQLSRV_LOG_SEVERITY_ALL); $conn = sqlsrv_connect('cslogs', array ( 'UID' => 'mailreport', 'PWD' => '123456', 'Database' => 'Mail', 'CharacterSet' => 'UTF-8', 'MultipleActiveResultSets' => true, 'ConnectionPooling' => true, 'ReturnDatesAsStrings' => true, )); if ($conn === FALSE) { get_last_error(); } return $conn; } function query($conn, $query) { $result = sqlsrv_query($conn, $query); if ($result === FALSE) { get_last_error(); } return $result; } /* Prepare a reusable query (prepare/execute) */ function prepare ( $conn, $query, $params ) { $result = sqlsrv_prepare($conn, $query, $params); if ($result === FALSE) { get_last_error(); } return $result; } /* do the deed. once prepared, execute can be called multiple times getting different values from the variable references. */ function execute ( $stmt ) { $result = sqlsrv_execute($stmt); if ($result === FALSE) { get_last_error(); } return $result; } function fetch_array($query) { $result = sqlsrv_fetch_array($query, SQLSRV_FETCH_ASSOC); if ($result === FALSE) { get_last_error(); } return $result; } $conn = connect(); /* prepare the statement */ $query = "INSERT Records values ( ? , ? , ? )"; $param1 = null; // this will hold col1 from the CSV $param2 = null; // this will hold col2 from the CSV $param3 = null; // this will hold col3 from the CSV $params = array( $param1, $param2, $param3 ); $prep = prepare ( $conn, $query, $params ); $result = execute ( $prep ); //get the csv file $file = $_FILES["csv"]["tmp_name"]; /* Here is where you read in and parse your CSV file into an array. That may get too large, so you would have to read smaller chunks of rows. */ $csv_array = file($file); foreach ($csv_array as $row_num => $row) { $row = trim ($row); $column = explode ( ',' , $row ); $param1 = $column[0]; $param2 = $column[1]; $param3 = $column[2]; // insert the row $result = execute ( $prep ); } /* Free statement and connection resources. */ sqlsrv_close($conn); header( "Location: test.php?success=1" ); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Import a CSV File with PHP & MS SQL Server</title> </head> <body> <?php if (!empty($get_success)) { echo "<b>Your file has been imported.</b><br><br>"; } //generic success notice ?> <form action="" method="post" enctype="multipart/form-data" name="form1" id="form1"> Choose your file: <br /> <input name="csv" type="file" id="csv" /> <input type="submit" name="Submit" value="Submit" /> </form> </body> </html> Now I know it is at this part wiht the $param1, $param2 and $param 3 that it is inserting the NULL values for each column: /* prepare the statement */ $query = "INSERT Records values ( ? , ? , ? )"; $param1 = null; // this will hold col1 from the CSV $param2 = null; // this will hold col2 from the CSV $param3 = null; // this will hold col3 from the CSV $params = array( $param1, $param2, $param3 ); $prep = prepare ( $conn, $query, $params ); $result = execute ( $prep ); But if I take that out them three out, the php errors out then doesn't import the data. Is there a way with what I have to ignore the first row to import? Or am I going about this all wrong?
  6. Hi there, I am busy to create an e-commerce site where I need to import products from product feeds (in XML/CSV). I import the data to mysql and display those on my website. However, I am stuck where I need to match their categories with my site's categories. For example, I have category laptops which is under computer, but the data has no category laptops, instead they put most laptops under category notebooks. Or sometimes the feeds give you a laptop bags under category laptop. How could I possibly grab the right products under categories in the productfeed and put those into the right categories in my site? What could be the best logic to accomplish this? I have tried making keywords, however, I can't get it really neat. Could someone give me an advice here? Thank you
  7. Hi All, I want to create a webpage that allows a user to import a csv file into a database. Can anyone help me start with this? Or at least refer me to a really good source that can help me get this working.
  8. I am newbie when it comes to PHP.You probably know this from the question i am about to ask. I have created a php file in Notepad text editor. I want the file to connect to my database in mysql. I am unsure what the best approach is to link the file to the database in mysql that i wish to activate ?
  9. this is the scrip i currently have but i get "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 'range,groups,b_m,product_code,desc_1,desc_2,qty,nett_price,goods_value) VALUES (' at line 1" <?php if (isset($_POST['submit'])) { if(is_uploaded_file($_FILES['filename']['tmp_name'])){ $handle = fopen($_FILES['filename']['tmp_name'], "r"); while(($data = fgetcsv($handle,1000,",")) !==false) { $ST=$data[0]; $date=$data[1]; $actual_date=$data[2]; $account=$data[3]; $branch=$data[4]; $customer_name=$data[5]; $i_c=$data[6]; $invoice_num=$data[7]; $category=$data[8]; $order_no=$data[9]; $order_item=$data[10]; $range=$data[11]; $groups=$data[12]; $b_m=$data[13]; $product_code=$data[14]; $desc_1=$data[15]; $desc_2=$data[16]; $qty=$data[17]; $nett_price=$data[18]; $goods_value=$data[19]; $query = "INSERT INTO sales_orders (ST,date,actual_date,account,branch,customer_name,i_c,invoice_num,category,order_no,order_item,range,groups,b_m,product_code,desc_1,desc_2,qty,nett_price,goods_value) VALUES ('$data[0]','$data[1]','$data[2]','$data[3]','$data[4]','$data[5]','$data[6]','$data[7]','$data[8]','$data[9]','$data[10]','$data[11]','$data[12]','$data[13]','$data[14]','$data[15]','$data[16]','$data[17]','$data[18]','$data[19]')"; mysql_query($query) or die(mysql_error()); } } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR...nsitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title><?php echo COMPANY_NAME; ?> | Sales Figures Upload Screen</title> <link href="<?php echo ROOT; ?>css/login.css" type="text/css" rel="stylesheet" /> <link type="text/css" href="<?php echo ROOT; ?>css/start/jquery-ui-1.8.7.custom.css" rel="stylesheet" /> <script type="text/javascript" src="<?php echo ROOT; ?>js/jquery-1.4.4.min.js"></script> <script type="text/javascript" src="<?php echo ROOT; ?>js/jquery-ui-1.8.7.custom.min.js"></script> </head> <body> <div id="box"> <div id="content"> <h1>Sales CSV Update</h1> <p>Please use a valid CSV file extracted from Exant Exporter.</p> <form method="post" action="uploadsale.php" enctype="multipart/form-data"> <p> <input type="file" name="filename"/> </p> <input name="submit" type="hidden"/> <button tabindex="4" type="submit">Upload Data</button> </form> </div> </div> </body> </html> <?php mysql_close($connection); ?>
×
×
  • 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.