homepage Welcome to WebmasterWorld Guest from 54.226.230.76
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Building a table for a blog.
Scotty13




msg:4441679
 9:59 pm on Apr 16, 2012 (gmt 0)

I'm trying to build a blog_sections_table in phpMyAdmin / MySQL and getting...
Success in database CONNECTION.....
no TABLE created. You have problems in the system already, backtrack and debug!

Here's my table, what 'am I missing?

<?php

require_once "connect_to_mysql.php";

print "Success in database CONNECTION.....<br />";

$result = "CREATE TABLE blog_sections (
int(11) NOT NULL AUTO_INCREMENT,
title varchar(88) NOT NULL,
ordered int(11) NOT NULL,
PRIMARY KEY (id),
) ";
if (mysql_query($result)){
print "Success in TABLE creation!......
<br /><br /><b>That completes the table setup, now delete the file <br />
named 'section.php' and you are ready to move on. Let us go!</b>";
} else {
print "no TABLE created. You have problems in the system already, backtrack and debug!";
}
exit();
?>

Thanks, Scott

 

eelixduppy




msg:4441725
 12:19 am on Apr 17, 2012 (gmt 0)

Try replacing this:

print "no TABLE created. You have problems in the system already, backtrack and debug!";


With this:


print "no TABLE created. You have problems in the system already, backtrack and debug!";
echo "\n" . mysql_error();


This will provide you with information as to why the query is failing. Then you will have to rewrite your query to fix the issue. If you need help, post the error that results from changing this code.

Scotty13




msg:4441825
 7:27 am on Apr 17, 2012 (gmt 0)

Error:
Success in database CONNECTION.....
no TABLE created. You have problems in the system already, backtrack and debug! You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'int(11) NOT NULL AUTO_INCREMENT, title varchar(88) NOT NULL, ' at line 2

topr8




msg:4441852
 8:47 am on Apr 17, 2012 (gmt 0)

doesn't look like you've named your first column.

rocknbil




msg:4442061
 4:49 pm on Apr 17, 2012 (gmt 0)

Also there's a trailing comma after (id), <--

Scotty13




msg:4442107
 6:23 pm on Apr 17, 2012 (gmt 0)

GOT IT! Thanks ALL for your help.

<?php

require_once "connect_to_mysql.php";

print "Success in database CONNECTION.....<br />";

$result = "CREATE TABLE blog_sections (
id int(11) NOT NULL AUTO_INCREMENT,
title varchar(88) NOT NULL,
ordered int(11) NOT NULL,
PRIMARY KEY (id)
) ";
if (mysql_query($result)){
print "Success in TABLE creation!......
<br /><br /><b>That completes the table setup, now delete the file <br />
named 'section.php' and you are ready to move on. Let us go!</b>";
} else {
print "no TABLE created. You have problems in the system already, backtrack and debug!";
echo "\n" . mysql_error();
}
exit();
?>

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