Jump to content

Search the Community

Showing results for tags 'pdo import table database'.

  • 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 1 result

  1. Hi Everyone I'm currently trying to learn PHP whilst writing my own custom control panel I had a working import csv page but I got told its not really good to use mysql_* anymore, so I've started again with trying to do it with pdo, but i think I'm well over my head with this one, my page says is successfully uploaded but there is nothing in the Leads table I created so its not putting the data into the table. here's my code so far <?php $used=0; error_reporting(E_ALL); ini_set('display_errors', '1'); if (isset($_POST['submit'])) { require "database/pdo_connection.php"; //upload file if (is_uploaded_file($_FILES['fileName']['tmp_name'])) { echo "<h1>" . "File " . $_FILES['fileName']['name'] . " uploaded Successfully." . "</h1>"; } $filename = $_FILES['fileName']['name']; //Now Lets import the file to the database/connection $handle = fopen($_FILES['fileName']['tmp_name'],"r"); $import=$pdo_connection->prepare( "INSERT IGNORE into Leads(number,date,used,fileName) values(?,?,?,?)" ); while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { $import->bindParam(1, $data[0], PDO::PARAM_STR); $import->bindParam(2, $data[1], PDO::PARAM_STR); $import->bindParam(3, $used, PDO::PARAM_INT); $import->bindParam(4, $filename, PDO::PARAM_INT); $import->execute(); } fclose($handle); } else { print "<div id='box'>"; print "Upload new csv by browsing to file and clicking on Upload<br/>\n"; print "<form enctype='multipart/form-data' action='Leads2.php' method='post'>"; print "File name to import:<br/>\n"; print "<input id='test' size='10' type='file' name='fileName' ><br/>\n"; print "<input type='submit' name='submit' value='Upload'></form>"; print "</div>"; } ?> Thanks in advance for any help given
×
×
  • 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.