Reply to Re: Different approach?

Your name:

Reply:


Posted by John Taylor-Johnston on 03/19/05 01:30

Sorry to bother. I was hoping for inspiration. The code works. I wonder if there is a cleaner way?

John


> John Taylor-Johnston wrote:
> Hi,
>
> I've read:
>
> > http://dev.mysql.com/doc/mysql/en/create-table.html
>
> Would anyone code/approach this differently?
>
> #################################################
> $server = "localhost";
> $user = "myname";
> $pass = "mypass";
> $db = "mydb";
> $table = "demo_assignment1";
>
> #################################################
> $myconnection = mysql_connect($server,$user,$pass);
>
> #################################################
> $sql = "CREATE TABLE IF NOT EXISTS `demo_assignment1` (
> `StudentNumber` varchar(8) NOT NULL default '',
> `Exercise1` varchar(100) NOT NULL default '',
> `Exercise2` varchar(100) NOT NULL default '',
> `TimeStamp` timestamp(14) NOT NULL,
> PRIMARY KEY (`TimeStamp`)
> ) TYPE=MyISAM COMMENT='place something here';";
>
> mysql_select_db($db,$myconnection);
> mysql_query($sql) or die(print mysql_error());
>
> #################################################
> $sql = "INSERT INTO $table
> (StudentNumber,Exercise1,Exercise2) values
> ('$StudentNumber','$Exercise1','$Exercise2')";
>
> mysql_select_db($db,$myconnection);
> mysql_query($sql) or die(print mysql_error());
>
> mysql_close($myconnection);

--
John Taylor-Johnston
-----------------------------------------------------------------------------
"If it's not Open Source, it's Murphy's Law."

' ' ' Collège de Sherbrooke:
ô¿ô http://www.collegesherbrooke.qc.ca/languesmodernes/
- 819-569-2064

°v° Bibliography of Comparative Studies in Canadian, Québec and Foreign Literatures
/(_)\ Université de Sherbrooke
^ ^ http://compcanlit.ca/ T: 819.569.2064

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация