
06-15-03, 01:33 PM
|
|
Wannabe Coder
|
|
Join Date: Jun 2003
Location: Florida
Posts: 188
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
|
More inserting problems
Ok, heres my problem.
Im working on the commenting system now on my news script.
And it inserts the data.. but in the newsid feild it wont insert the right id for the particular news.
heres the db structure.
comment.php
insert.php
thanks in advance for the help.
and like i said.. the only thing going wrong it the wrong id for the newsid feild isnt right.
edit: i had my news.php mixed with my comment.php sorry
Last edited by Psybadek; 06-15-03 at 01:47 PM.
|

06-15-03, 11:53 PM
|
 |
Newbie Coder
|
|
Join Date: Jun 2003
Location: Indonesia
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I think there's a syntax error on file insert.php
this command below is not valid MySQL Quaery syntaxx
mysql_query ("INSERT INTO al_comments (author, date, comment) VALUES ('$author', '$date', '$comment',) WHERE newsid='$id'") or
die('Error executing query: ' . MySQL_Error());
Try change to that query above with this query bellow :
mysql_query("insert into al_comments (newsid, author, date, comment) VALUES ('$id', '$author', '$date', '$comment')");
I think you send a variable call "id" which set for news id,
so it have to be store on field newsid on table al_comments,
And INSERT command con not be set with an condition such as "WHERE", it would only works on UPDATE command.
Just try... if it doesn't work, let me know.
__________________
-=ridwank=-
<b><a style='text-decoration:none' href="http://www.ridwank.com">CLICK : ridwank.com : PHP SCRIPT CENTER</a></b>
|

06-16-03, 12:36 AM
|
|
Wannabe Coder
|
|
Join Date: Jun 2003
Location: Florida
Posts: 188
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
thats my newest comment.php file.
i still have the same problem. the comment page with the news looks like comment.php?commid=$id
and it just wont insert the $id into $newsid
|

06-16-03, 01:03 AM
|
 |
Newbie Coder
|
|
Join Date: Jun 2003
Location: Indonesia
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I think you forgot about variable "S"
you have to put it on the form
<input type="hidden" name="s" value="add">
Because you have describe that
the insert command will only be execute
if $S="add"
Im sorry I can not try ur script, because u don't give the other pages that related to this "comment.php"
And I think I can not explain a lot in this forum, i u like ask more about it, you can chat me on Yahoo Messenger,
my Yahoo id = ridwank_yh
__________________
-=ridwank=-
<b><a style='text-decoration:none' href="http://www.ridwank.com">CLICK : ridwank.com : PHP SCRIPT CENTER</a></b>
|

06-16-03, 01:09 AM
|
|
Wannabe Coder
|
|
Join Date: Jun 2003
Location: Florida
Posts: 188
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
i only have aim and msn messenger
but heres the most recent zip...
edit: i forgot to update the installer.. in the comments table..
change 'id' to 'commid'
edit2: attachement removed because this isnt a release
Last edited by Psybadek; 06-16-03 at 01:51 AM.
|

06-16-03, 03:41 AM
|
 |
Newbie Coder
|
|
Join Date: Jun 2003
Location: KSA
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Psybadek, i got to tell you man.. you got some weird way of
writing codes.
one of the mistakes is :
<input type="hidden" name="newsid" value="<? echo '$newsid' ?>">
it should be something like this :
<input type="hidden" name="newsid" value="<? echo $newsid ?>">
anyway i managed to fix your problem, and added a counter
for the comments in news.php & comment.php, now it shows
the news when you press (view). just take a look and see.
* advice : try to use blocks of functions insted of one big flat
of code, its easier to debug.
__________________
"The strong is not the one who overcomes the people by his strength, but the strong is the one who controls himself while in anger."
|

06-16-03, 12:26 PM
|
|
Wannabe Coder
|
|
Join Date: Jun 2003
Location: Florida
Posts: 188
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
thanks for your help..
and yea.. i do got weird coding ways 
|

06-17-03, 04:39 AM
|
|
Wannabe Coder
|
|
Join Date: Jun 2003
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
<input type="hidden" name="newsid" value="<? echo $newsid ?>">
use long php tags
<?php
some servers have short tags disabled.
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|