I wish you all the correct code)) Hi)
There was a problem reading the file. Actually, I want to read from file command for MySQL (originally, this team is destined for Orcle, but I think it will be right for MySQL). I think the problem in the encoding (I do not have much experience in working with files). Here's the code -
12.php =

<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>  Work with database script </title>
</head>
<body>
<center>
<?php
  $filename = "cd2.sql" ; //  the name of the file.
  $fdata = fopen ($filename, "r+"); //  file in read + write.
  if (!$fdata) 
  { 
    echo ("Unable to open file");
    exit;
  }
		
  $i=0;
  $str="";
  while (!feof($fdata)&&($i<=7))
  { 
    $simb = fgetc($fdata); // read file character by character

    $str = $str + $simb;
    if  ($simb = ";")  // if found with a semicolon - write a line on the screen.
    {
	  echo ($str."<br>");
	  $str = '';
	  ++$i; // counter cultivated rows.
    }
  }   
  echo ("4) The script is executed successfully )) treated  ".($i)." commads.");
  
 ?>
</center> 
 </body>
</html>

cd2.txt =

create table SUBJECT
(
  SUBJ_ID   NUMBER not null,
  SUBJ_NAME VARCHAR2(60),
  HOUR      NUMBER,
  SEMESTER   NUMBER
);

result in the browser =

0
0
0
0
0
0
0
0
4) The script is executed successfully )) treated 8 lines.

it turns out that the condition

if  ($simb = ";")  // if found with a semicolon - write a line on the screen.

isn't working properly .... please tell me what went wrong.


----------------------
i've uploaded both files to the site. Thanks in advance to all who respond !

Change your code as
line no:23 ----->>>> $str = $str . $simb;
line no:24 ----->>>> if ($simb == ";")

commented: thank you! +1

Thank you)) I cant break the habit of Delphi syntax and make stupid mistakes ..... thanks again))

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.