problem with sql querry in php script


Posted on 16th Feb 2014 07:03 pm by admin

Hello guys,

What I want to do is I want to read out a csv file and then but te conent ot the file in a msql datbase .
So far it works but the problem I haven that if I want to let te script to the typing for me so that I dont have to fill in the Values of the MySQL query myself It doesn't work
Did you know?Explore Trending and Topic pages for more stories like this.

This is my code so far :

<?php
$dbhost = 'localhost';
$dbuser = 'y';
$dbpass = 'x';
$dbname = 'test';

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die;
mysql_select_db($dbname);


$file = fopen("test.csv", "r") or exit("Unable to open file!");
//Output a line of the file until the end is reached
while(!feof($file))
{

echo fgets($file). "<br />";
}
fclose($file);

mysql_query("INSERT INTO test
(Naam,Geboortedatum, Leeftijd,woonplaats, Geslacht) VALUES('$file','$file', '$file','$file','$file' ) ")
or die(mysql_error());


if (!mysql_query($sql,$conn))
{
die('Error: ' . mysql_error());

echo "Gegevens toegevoegd";
}
mysql_close($conn)
?>
No comments posted yet

Your Answer:

Login to answer
276 Like 25 Dislike
Previous forums Next forums
Other forums

writing a screen scraper
Hello,

I'm writing a screen scraper application and want to be able to get absolute addresses

Create PHP table grid help, please
I have a MySQL database setup, now it's time for the table (gridview) design in php. Here's the prob

understanding functions and classes
Code: [Select]
class person {
var $name = "Jimmy Goe";

function get_nam

Xacute search within SQL results
I have a query that is pulling data, and I want to return a specific value from the results of that

mails going in spam??
The mails I sent to folks in my database using mail(function) are going in spam??

Any idea ho

MySQL Primary key gap
Alright, so I have a table with 26 entries in it (id, filename, caption) for my image randomiser (ht

COde for a Cc
I'm not receiving $ft as a Cc. Why is that??

$to = "$email";
$headers = "Fr

Error In Syntax
I got this error:

Code: Parse error: syntax error, unexpected '>' in /home/bucket/publ

Load file in PHP
I have 2 files. The first is a PHP generated XML file that's dependent by 2 inputs. The second is a

PHP Thumbnail Creation
Ok so i use this function to create thumbnails:

Code: [Select]function createthumb($name,$fil

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash