Member Avatar for kirtan_thakkar

I have created one php file which open a mysql database in my local system...
I want to know that i have created a database in PhpMyAdmin..
What would be the user and password..
And how to run that php file..
Can I run it in a web browser to do actions..
I have posted the code here..
Please help..

<?php
$link = mysql_connect("localhost","","") or die("Could not connect".mysql_error());
mysql_select_db("db1") or die("Could not select Database");
opendir("F:\databases\homefile");
$i=1;
while($i<=58)
{
	
	fopen($i.".txt");
	$data=file_get_contents($i.".txt");
	mysql_query("INSERT INTO db1 (field2,field3)
	VALUES ("Hello",$data)");
	$i=$i+1;
}
mysql_close($link);

?>
Member Avatar for kirtan_thakkar

I have created a new code with my online database but i am geeting the error that unable to access 1.txt..

code is this

<?php
$link = mysql_connect("localhost", "qyl", "*****") or die("Could not connect".mysql_error());

mysql_select_db("qyl") or die("Could not select Database");


$dir=opendir("quotations/authors/Abraham Lincoln/");

$i=1;

while($i<=58)
{
	
	$data=file_get_contents($i.".txt");
	mysql_query("INSERT INTO quote_author
	VALUES ($i,'Abraham Lincoln',$data)");
	$i=$i+1;
}
mysql_close($link);

closedir($dir);
?>
Member Avatar for rajarajan2017

i) Check for the file 1.txt is present in the directory
ii) Also check just place your file wherever your php resides
iii) Check for the security or permission issue for the file or drive

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.