homepage Welcome to WebmasterWorld Guest from 54.198.224.121
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe and Support WebmasterWorld
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Need Help With Some MySQL Coding
kodaks




msg:1272410
 11:23 pm on Jun 14, 2005 (gmt 0)

Hello everyone,
I have little knowledge of MySQL, and am hoping someone can help me out with a question I have. I have some code that automatically installs a table into a MySQL database. This is for a forum software modification. Here is the code:
<?php

require "./global.php";

if($mybb['uid'] == 0)
{
nopermission();
}

$sql = "CREATE TABLE `".TABLE_PREFIX."whatever` (
`did` smallint(6) NOT NULL auto_increment,
`cid` smallint(6) NOT NULL default '0',
`uid` smallint(6) NOT NULL default '0',
`name` varchar(32) NOT NULL default '',
`description` text NOT NULL,
`url` varchar(200) NOT NULL default '',
`visible` char(3) NOT NULL default '',
`sticky` char(3) NOT NULL default '',
`validated` char(3) NOT NULL default '',
PRIMARY KEY (`did`)
) TYPE=MyISAM AUTO_INCREMENT=1;";

$query = $db->query($sql);
echo "<font face=\"arial\" size=\"2\" color=\"green\"><b>Table Added:</b> forumlinks</font><br />\n";

echo "<br />\n<br />\n";
echo "<font face=\"arial\" size=\"2\" color=\"green\"><b>Installation Complete!</b><br />Please delete this file now for security reasons.</font>\n";

?>

Notice the bold line, that basically creates the new table. Instead of this script creating a table, I would like this script to insert into the specified table that already exists (my example is "whatever"). What can I change in this script to make it insert sql into a pre-existing table? Thanks!

 

bonanza




msg:1272411
 12:21 am on Jun 15, 2005 (gmt 0)


So you want to modify this script so it changes your existing table to have these new fields?

Does this table already have data in it?

kodaks




msg:1272412
 7:14 pm on Jun 15, 2005 (gmt 0)

Yes it does.

coopster




msg:1272413
 11:13 pm on Jun 15, 2005 (gmt 0)

So you want to ALTER [dev.mysql.com] the table?

kodaks




msg:1272414
 11:43 pm on Jun 15, 2005 (gmt 0)

That's exactly what I was looking for. Thank you very much!

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved