Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

Truncate table before LOAD DATA LOCAL INFILE

I wan't to truncate the table before the load data local infile query executes, but I can't figure out where to execute it without my server giving me an error,

<?php

$sql = "LOAD DATA LOCAL INFILE 'http://services.runescape.com/m=clan-hiscores/members_lite.ws?clanName=made+in+norway' 
        INTO TABLE clan 
        FIELDS TERMINATED BY ',' 
        OPTIONALLY ENCLOSED BY '\"' 
        LINES TERMINATED BY '\n' 
        IGNORE 1 LINES;";

$con=mysqli_connect("localhost","root","","minrs");
// Check connection
if (mysqli_connect_errno()){
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
};


$result = mysqli_query($con,$sql);

if (mysqli_affected_rows($con) > 0){
  $message = "The data was successfully added!";
} else {
  $message = "The user update failed: ";
  $message .= mysqli_error($con); 
};

echo $message;


?>