Hi,
i am an extreme newbie to this forum and this php malarky, and am in need of some help.my main problem is that I need help converting the syntax from mssql to mysql, im trying to do it a php script so it will save time.

I want it to read the stuff in from a file, chnage the syntax so its valid and then write the correct syntax to another file. i have done the reading and the writing to files from the above code but the main problem(s) are:
1. i need to add the name to the end of the 'CREATE TABLES' as well of where it is. Also in this case where [DEPENDANCY ID] is, the IDENTITY(1, 1) may not be on the 1st create table line so i need to to search each 'block of mysql code' to find out which column IDENTITY(1, 1) belongs to and then to add it to the end.
This is an example of mssql
Code:
CREATE TABLE [dbo].[NimoiModuleDependencies] (
[DependencyID] [int] IDENTITY (1, 1) NOT NULL ,
[BaseModuleIDList] [nvarchar] (200) NOT NULL ,
[TopModuleID] [int] NOT NULL ,
[ORDependencyID] [bit] NOT NULL 
) ON [PRIMARY]
GO
And this is mysql and for some reason it will only work like this i dont know why, this is how it has to look
Code:
CREATE TABLE NimoiModuleDependencies (
DependencyID INT NOT NULL AUTO_INCREMENT ,
BaseModuleIDList VARCHAR(200) NOT NULL ,
TopModuleID INT NOT NULL ,
ORDependencyID BIT NOT NULL,
ON PRIMARY KEY (DependencyID) );
as you can see that IDENTITY (1, 1) has been replaced with AUTO_INCREMENT (after NOT NULL) and dependencyID is placed at the end.

Here is my PHP code
PHP Code:
<?php 
$filename 
"text1.txt"
$fp fopen($filename"r"); 
//fread function -contain 2 parameters 1 fpopen function 2 filesize 
$fileread fread($fp,filesize($filename)); 
fclose($fp); 

$str str_replace("[int]","INT",$fileread); 
$str str_replace("[dbo].",""$str); 
$str str_replace("[bit]","BIT",$str); 
$str str_replace("[nvarchar]","VARCHAR",$str); 
$str str_replace("VARCHAR (200)","VARCHAR(200)",$str); 
$str str_replace("CHAR (10)","CHAR(10)",$str); 
$str str_replace("ON [PRIMARY]","PRIMARY KEY(id))",$str); 
$str str_replace("GO","",$str); 

$MySQL "$str"
$filename "text2.txt"
$fp fopen("$filename","a"); 
If (!
$fp) { 
       print 
"error! cant be opened"
exit; 

$stringtowrite=$MySQL
$filewrite fwrite($fp$stringtowrite); 
$fclose fclose($fp); 
print 
"written <br><br>$stringtowrite "
?>
Hope this explains it abit more for you. When its done ill be mor than happy to post the script for anyone who has a similar senario.

Thanks for your help guys its much appreciated.

Andy