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

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

DirectoryIterator and Hacked Website
Hi Everyone.

My problem:
Some one has been sneaking in to my website hidden Iframes. I've

I would like "for" to wait 5 sec
I would like my 'for' loop to wait 5 sec before second iteration.


for ($i=0; $i<10

some questions
Hello,

I am looking for the answers for following questions:

1) Does PHP support overl

dynamic table with forms
I have a table that is populated with mysql data and in teh first column there is a raido button tha

Multiple if statements
Ok so seems basic but for some reason I'm not doing it right. What I want is to be able to have 2 se

array & querys help/advice.
Ok so here goes , I have a mysql database and basically here's what I need to do.

// foreach

Help on code output
My CODE:

Code: [Select] echo "<phone>".$line["phone"].&qu

how do i make new line after *
First check this page here. and you see my report. Im pulling form a mysql db. I want to beable to m

How to assign JS screen.width to ASP.Net variable
I've got this ASP.net routine that gets the cookie value of the screen width, but now I need to chan

Validation
Hello

I know this is a really vag question.

I need to have a input field on a form th

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