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
25
Other forums
[RESOLVED] Socket/Port remains open after app crashes
I'm having this problem with a networked app in vb.net.
If the program exits normally the por
need help in update query
hi
i have a dynamic form. i need help in how can i use update query when values from dynamic for
need help in creating captcha
hi i have a problem creating captcha system. i create some basic script for image displaying but it
Is STL important?
I'm just starting programming and I've made it until the Standart Template Library. But the chapter
need help in dynamic select menu in php
hi i have created a dynamic select menu using php. i have a problem in that which is when the user s
tag inside php... hi
Code: <?php echo "<td width="$columnWidth%" align="es changing hi all
in my content
opening quotes " changes to “
close qu Phase Error I can't seem to find :(` Hey guys, I can seem to find my phase error on this. I am getting this error
[error] Pars Post, not working, please help The error is: Method Not Allowed The requested method POST is not allowed for the URL /student If a record matches an existing record do nothing So I don't know if I should put this here or in mysql, but what my script is for is for people to ad
|