0

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);

?>

Edited by kirtan_thakkar: n/a

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by rajarajan07
0

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);
?>
0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.