Question:
Can someone make this from MySQL to PHP?
Ben
2009-01-31 08:12:24 UTC
Is it possible to make the code below into php coding....I really need this to be PHP...Thanks in advance!!!

-- MySQL Administrator dump 1.4
--
-- ------------------------------------------------------
-- Server version 5.0.67-community-nt


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;

/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;


--
-- Create schema username
--

CREATE DATABASE IF NOT EXISTS username;
USE username;

--
-- Definition of table `deleted`
--

DROP TABLE IF EXISTS `deleted`;
CREATE TABLE `deleted` (
`From` varchar(256) default NULL,
`Subject` varchar(256) default NULL,
`Date` varchar(256) default NULL,
`Message` text
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `deleted`
--

/*!40000 ALTER TABLE `deleted` DISABLE KEYS */;
/*!40000 ALTER TABLE `deleted` ENABLE KEYS */;


--
-- Definition of table `inbox`
--

DROP TABLE IF EXISTS `inbox`;
CREATE TABLE `inbox` (
`From` varchar(256) default NULL,
`Subject` varchar(256) default NULL,
`Date` varchar(256) default NULL,
`Message` text
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `inbox`
--

/*!40000 ALTER TABLE `inbox` DISABLE KEYS */;
/*!40000 ALTER TABLE `inbox` ENABLE KEYS */;


--
-- Definition of table `info`
--

DROP TABLE IF EXISTS `info`;
CREATE TABLE `info` (
`Username` varchar(256) default NULL,
`Password` varchar(256) default NULL,
`Alternative E-mail` varchar(256) default NULL,
`First Name` varchar(256) default NULL,
`Gender` varchar(256) default NULL,
`Year Of Birth` int(10) unsigned default NULL,
`Security Question` text,
`Security Answer` text
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `info`
--

/*!40000 ALTER TABLE `info` DISABLE KEYS */;
/*!40000 ALTER TABLE `info` ENABLE KEYS */;


--
-- Definition of table `sent`
--

DROP TABLE IF EXISTS `sent`;
CREATE TABLE `sent` (
`To` varchar(256) default NULL,
`Subject` varchar(256) default NULL,
`Date` varchar(256) default NULL,
`Message` text
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `sent`
--

/*!40000 ALTER TABLE `sent` DISABLE KEYS */;
/*!40000 ALTER TABLE `sent` ENABLE KEYS */;


--
-- Definition of table `spam`
--

DROP TABLE IF EXISTS `spam`;
CREATE TABLE `spam` (
`From` varchar(256) default NULL,
`Subject` varchar(256) default NULL,
`Date` varchar(256) default NULL,
`Message` text
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `spam`
--

/*!40000 ALTER TABLE `spam` DISABLE KEYS */;
/*!40000 ALTER TABLE `spam` ENABLE KEYS */;




/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
Four answers:
Ghroth
2009-01-31 08:41:34 UTC
If i were you, i would keep the file as a text and let the php execute each line.. something like this:




$sqlcon = mysql_connect($host,$user,$pass);

mysql_select_db($database, $sqlcon);



$file = fopen("sqlquery.txt","r");

while(!feof($file)) { mysql_query(fgets($file)); }

fclose($file);



mysql_close($sqlcon);

?>



Edit: wait wait! this won't work. There is gonna be a problem according to the stracture of the text file like this. For example "SQL_MODE='NO_AUTO_VALUE_ON_ZER... */;" will cause some trouble. You will have to parse the text to get the correct syntax of commands.
ElephantHop
2009-01-31 08:24:32 UTC
That's a database query. You cannot convert it to PHP code.



You have two options:

1. Connect to your database management software and paste and run that code as an sql query.

2. Use PHP to connect to database and run that query.



I recommend the first option
?
2016-10-14 11:35:26 UTC
Make it much less complicated on your self. Use the underscore ('_') to split words as destructive to a hyphen ('-'). occasion: $table = 'menu_pizza'; then you definitely do not would desire to apply the break out sequence "-". you would be conscious the opposite lessen is used to flee a definite character.
MRK
2009-01-31 08:38:19 UTC
hi





it's database.sql (db exported file). check out mysql database application link,



mysql-admin

xampp-lite (http://www.apachefriends.org/en/xampp-windows.html)



here, you can just upload your .sql file to db.



or you just what you convert to PHP. You need to know PHP and MySql. Use http://www.w3schools.com/ to know about it.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...