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

Creating a custom API
I'm creating a site, and I need to create a basic API. Unfortunately I have no idea where to start.

Not capturing all the information we require in the form.......
Hi Guys,

I was wondering if you would share some more of your knowledge today, I'm hoping it

Php mysql - select?
Hi i have this code:
Code: $iteminfo = mysql_query("SELECT desc FROM wc_items WHERE itemid =

Auto fill in input value based on User_ID
Hello,

I'm looking form some input on the following problem.

User loads page ->

Share admin accross websites
I'm using .net memberships and roles in one of my sites, but I need to be able to share logins and p

ORA-01655: unable to extend cluster SYS.C_FILE#_BLOCK# by 128
Hi all,

Oracle 10g. Linux.

I'm facing the below error while trying to import a dumpfil

Problem writing URL into database
How would I write this into the database?

<?php echo "http://".$_SERVER['SER

Consuming third party Payment Gateway API from Procedure.
Hi All,

First of all i would like to thank all the people of the oracle forum for providi

Character increment
Hi,

I am facing a scenario like above,but in my case i want to show up like Col A,Col B etc..

Is it possible to stop reservation creation in PM Order?
Hi All,

Is it possible to stop reservation creation in PM Order?

Thanks in adv

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