dcd018 — 2011-08-05T10:35:38-04:00 — #1
I just finished reading Build your own Database Driven Website by Kevin Yank and decided to edit some of the php so I could use the Administrative pages.. I'm using the source code from chapter 9 in admin folder.
The only thing I've edited was changing "joke" to "article". What i did was use Dreamweaver's find/replace feature to replace every "joke" instance with "article".. I tipple checked everything to make sure "joke" instances were the only things that were changed (along with the associated MySQL table name) and caps/plurals are where they should be.
Everything seems to be fine with the revised code except whenever I try to submit a new article (joke) or delete an author, I get:
[B]when I try to submit article:[/B]
Error adding submitted article.
[B]When I try to delete author:[/B]
Error getting list of articles to delete.
include $_SERVER['DOCUMENT_ROOT'] . '/includes/db.inc.php';
$text = mysqli_real_escape_string($link, $_POST['text']);
$author = mysqli_real_escape_string($link, $_POST['author']);
if ($author == '')
$error = 'You must choose an author for this article.
Click ‘back’ and try again.';
$sql = "INSERT INTO article SET
if (!mysqli_query($link, $sql))
$error = 'Error adding submitted article.';
I'm guessing the problem is in this portion of the jokes index located in admin folder, but it's identical to the original source code except for "article" so I'm stuck because my includes folder is updated and it can't be a connection issue with MySQL because the rest of the scripts are running fine. Any suggestions as to what the problem might be?
r937 — 2011-08-05T11:04:15-04:00 — #2
it's not wise to drink and code... [/ot]
dcd018 — 2011-08-05T11:08:57-04:00 — #3
Haha, I just loled.. irony wasn't what I was aiming for. It's not even noon!
r937 — 2011-08-05T11:11:31-04:00 — #4
test your sql statements outside of php, i.e. directly in mysql
that way you'll get the actual mysql error message
dcd018 — 2011-08-05T11:47:47-04:00 — #5
Ok, I tested
INSERT INTO article SET
#1054 - Unknown column 'authorid' in 'field list'
However, when I run
INSERT INTO article SET
My "article" table gets updated
So here's what my "article" table looks like, and I still have no clue what the problem is since there's an id column in my field list.
id name email password
1 John John@mail.com d8a6582c02d188df9ad89a6affa412f7
Thanks for the suggestion :hangin:
r937 — 2011-08-05T11:54:14-04:00 — #6
could you do a SHOW CREATE TABLE for the article table please
samanime — 2011-08-05T11:55:33-04:00 — #7
I see an "id" column, but not "authorid". The column names you use in SELECT statements (and all other statements for that matter) must match them exactly as they're written. =)
dcd018 — 2011-08-05T12:13:45-04:00 — #8
I think adding authorid might have fixed the issue, I'm checking if it will disorient the rest of my code. Since I'm using the source code from chapter 9, didn't think it would be an issue, thanks samanime!
Table Create Table
article CREATE TABLE `article` (
`id` int(11) NOT NULL A...
Solved... I hope
r937 — 2011-08-05T12:24:38-04:00 — #9
according to post #5, your article table has columns id, name, email, and password
i couldn't see anything beyond id in your last post, eh
it looks like you might've renamed your user table as the article table
but if you say it's solved, then carry on
blz — 2011-08-06T18:26:14-04:00 — #10
A table called 'article' with absolutely no columns for article related data is a bit weird, huh?
r937 — 2011-08-06T18:28:21-04:00 — #11
as miracle max said in the princess bride, "i've seen worse"