homepage Welcome to WebmasterWorld Guest from 54.237.98.229
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
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

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 8676 posted 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#: 8676 posted 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

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 8676 posted 7:14 pm on Jun 15, 2005 (gmt 0)

Yes it does.

coopster

WebmasterWorld Administrator coopster us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 8676 posted 11:13 pm on Jun 15, 2005 (gmt 0)

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

kodaks

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 8676 posted 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.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved