PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
AT&T devCentral & BlackBerry(r) Webcast Series: BlackBerry and GPS -Build Location Awareness into your BlackBerry Applications, July 10th-1:00PM EST. Register Today!
  #1  
Old August 22nd, 2002, 07:12 PM
seiya seiya is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: NYC, NY, USA
Posts: 45 seiya User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via AIM to seiya
Creating tables, if no errors display X message.. help!

Well, how do i do what i said in the topic title, here is the code i wrote. i have an idea of how to do what i have in mind but i dont want to mess it up. Can someone help me as i am still a n00b... :-/

CODE:

<b>
<?

//DO NOT EDIT BELOW THIS LINE!!!

include_once("db_connect.php");

$create_rtable = mysql_query("

create table reviews (
reviewID int(4) NOT NULL auto_increment,
reviewmenut varchar(255) NOT NULL,
review text ,
reviewtitle varchar(250) ,
PRIMARY KEY (reviewID),
KEY contenttitle (reviewtitle)
)
");
$create_ptable = mysql_query("

create table previews (
previewID int(4) NOT NULL auto_increment,
previewmenut varchar(255) NOT NULL,
preview text ,
previewtitle varchar(250) ,
PRIMARY KEY (previewID),
KEY contenttitle (previewtitle)
)
");
$create_atable = mysql_query("

create table previews (
articleID int(4) NOT NULL auto_increment,
articlemenut varchar(255) NOT NULL,
article text ,
articletitle varchar(250) ,
PRIMARY KEY (articleID),
KEY contenttitle (articletitle)
)
");
$create_itable = mysql_query("

create table previews (
iID int(4) NOT NULL auto_increment,
imenut varchar(255) NOT NULL,
i text ,
ititle varchar(250) ,
PRIMARY KEY (iID),
KEY contenttitle (ititle)
)
");
?>
<B>

Reply With Quote
  #2  
Old August 22nd, 2002, 07:13 PM
seiya seiya is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: NYC, NY, USA
Posts: 45 seiya User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via AIM to seiya
RE: Creating tables, if no errors display X message.. help!

Forget the b, i wanted it to be bold, oh well.

Reply With Quote
  #3  
Old August 22nd, 2002, 10:04 PM
guyer guyer is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Bloomington, IN USA
Posts: 47 guyer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via Yahoo to guyer
RE: Creating tables, if no errors display X message.. help!

mysql_query() returns TRUE on success. Check the manual.

Reply With Quote
  #4  
Old August 23rd, 2002, 07:42 PM
Taoism Taoism is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Winnipeg, MB, Canada
Posts: 81 Taoism User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 30 sec
Reputation Power: 2
RE: Creating tables, if no errors display X message.. help!

something like:

php Code:
Original - php Code
  1.  
  2. <?
  3.  
  4. //DO NOT EDIT BELOW THIS LINE!!!
  5.  
  6. include_once("db_connect.php");
  7.  
  8. $create['rtable']="
  9. CREATE TABLE reviews (
  10.   reviewID    INT(4) NOT NULL AUTO_INCREMENT,
  11.   reviewmenut VARCHAR(255) NOT NULL,
  12.   review      TEXT ,
  13.   reviewtitle VARCHAR(250) ,
  14. PRIMARY KEY (reviewID),
  15. KEY contenttitle (reviewtitle)
  16. )
  17. ";
  18.  
  19. $create['ptable']="
  20. CREATE TABLE previews (
  21.   previewID    INT(4) NOT NULL AUTO_INCREMENT,
  22.   previewmenut VARCHAR(255) NOT NULL,
  23.   preview      TEXT ,
  24.   previewtitle VARCHAR(250) ,
  25. PRIMARY KEY (previewID),
  26. KEY contenttitle (previewtitle)
  27. )
  28. ";
  29.  
  30. $create['atable']="
  31. CREATE TABLE previews (
  32.   articleID    INT(4) NOT NULL AUTO_INCREMENT,
  33.   articlemenut VARCHAR(255) NOT NULL,
  34.   article      TEXT ,
  35.   articletitle VARCHAR(250) ,
  36. PRIMARY KEY (articleID),
  37. KEY contenttitle (articletitle)
  38. )
  39. ";
  40.  
  41. $create['itable']="
  42. CREATE TABLE previews (
  43.   iID    INT(4) NOT NULL AUTO_INCREMENT,
  44.   imenut VARCHAR(255) NOT NULL,
  45.   i      TEXT ,
  46.   ititle VARCHAR(250) ,
  47. PRIMARY KEY (iID),
  48. KEY contenttitle (ititle)
  49. )
  50. ";
  51. //note the last three CREATE statements
  52. //use the same table name...
  53. //you need to change that.
  54.  
  55. foreach($create as $k=>$v){
  56.   if(!mysql_query($v)){
  57.     echo "<h3>Error creating table: $k</h3>";
  58.   }else{
  59.     echo "<h3>Table: $k created successfully!</h3>";
  60.   }
  61. }
  62. //to make this work even better, make the
  63. //key values for the array the actual table
  64. //name you are creating.
  65. ?>
  66.  


Cheers,
Keith.

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > Creating tables, if no errors display X message.. help!


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway