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

Help =( !! Upload Pics [PHP script]
Hello
I need help with a php script [MULTIPLE UPLOAD IMAGES] , where I want to add a feature (wat

foreach iterator
Hi Guys
Does the foreach loop have an inbuilt iterator ?

How to know if online site made with PHP
Hello,
I see some sites that does not display extensions at all , for example:

www.site.co

Upload file!
Ok i have a form..
Code: <form name="form1" method="post" action=&quo

Check Digits and extracting digits
I think I can figure out the code for this but I am having a very hard time getting past the first s

Batch Related Pricing
Hi, I need some clarity on the batch related pricing

For example the following are the b

Sales orders ans reservations not taken into account on MPS / MRP
Hello,

I am implementing the MPS / MRP and I have the following problem:

I ha

change text color with a jQuery code
Hihow can I change the text in a asp:TextBox to a different color when I start typing using jQuery?I

How to get exact 3 moths post date from today date using javascript
How to get exact 3 moths post date from today date using javascript
Please help

Need help making a script that moves data into acrhive table
Hi,

I'm kinda new to php/mysql

And i wrote a simple script to store sales lead for a b

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