0

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 !

Edited by vedro-compota: n/a

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by vedro-compota
0

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

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.