General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old September 16th, 2003, 06:21 PM
Bruski Bruski is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Toronto, Canada
Posts: 192 Bruski User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Comments

i have a news script i created, however i want to add comments... on top of that i have another problem...i want only ppl who are logged in to post comments...and it takes the name of the person as the poster...any suggestions?

Reply With Quote
  #2  
Old September 16th, 2003, 07:48 PM
compman compman is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 13 compman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
You could integrate it with some forum software... like Invision Power Board www.invisionboard.com

Reply With Quote
  #3  
Old September 17th, 2003, 05:30 PM
FrankieShakes FrankieShakes is offline
Frank The Tank!
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: Jun 2002
Location: Toronto, Canada
Posts: 1,246 FrankieShakes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via ICQ to FrankieShakes Send a message via MSN to FrankieShakes
What you would need to do is store their username either in a cookie or in a SESSION when they login, and then use the value that's stored as the username for the comments...

There's a nice article on here titled PHP Authentication 101, from Havard Lindset. I suggest checking it out, as it's a really easy read!

Hope that sheds some light...
__________________
____________________________________________
Developer Shed Weekly Writer | DevArticles Forum Moderator
Build Your Own KlipFolio Klip With PHP
FrankManno.com - Under Construction
Design Interactive Group - Under Construction

Reply With Quote
  #4  
Old September 17th, 2003, 05:40 PM
Bruski Bruski is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Toronto, Canada
Posts: 192 Bruski User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
many thanks...ive already solved it =]

Reply With Quote
  #5  
Old September 17th, 2003, 05:49 PM
Bruski Bruski is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Toronto, Canada
Posts: 192 Bruski User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
whats the command to display date not just time...like...Tuesday January o1 instead of 02-02-01...with mysql ive looked at the mysql site but cant find it...any suggestions

Reply With Quote
  #6  
Old September 17th, 2003, 05:59 PM
FrankieShakes FrankieShakes is offline
Frank The Tank!
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: Jun 2002
Location: Toronto, Canada
Posts: 1,246 FrankieShakes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via ICQ to FrankieShakes Send a message via MSN to FrankieShakes
Are you wanting to format the date using MySQL or PHP? I believe MySQL's function is DATE_FORMAT:

Code:
DATE_FORMAT(date_field, '%W, %M %e, %Y');


HTH!

Reply With Quote
  #7  
Old September 17th, 2003, 06:06 PM
Bruski Bruski is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Toronto, Canada
Posts: 192 Bruski User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
put that in mysql or when im selecting my rows from the table?

Reply With Quote
  #8  
Old September 17th, 2003, 06:07 PM
FrankieShakes FrankieShakes is offline
Frank The Tank!
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: Jun 2002
Location: Toronto, Canada
Posts: 1,246 FrankieShakes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via ICQ to FrankieShakes Send a message via MSN to FrankieShakes
When you're selecting from your tables...

Reply With Quote
  #9  
Old September 17th, 2003, 06:07 PM
Bruski Bruski is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Toronto, Canada
Posts: 192 Bruski User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
let me give it a try

Reply With Quote
  #10  
Old September 17th, 2003, 06:12 PM
Bruski Bruski is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Toronto, Canada
Posts: 192 Bruski User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
hmm i think im placing it wrong....can u explain just a bit more of where to put it =]

Reply With Quote
  #11  
Old September 17th, 2003, 06:15 PM
FrankieShakes FrankieShakes is offline
Frank The Tank!
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: Jun 2002
Location: Toronto, Canada
Posts: 1,246 FrankieShakes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via ICQ to FrankieShakes Send a message via MSN to FrankieShakes
Sure, it goes directly in your SQL statement:

PHP Code:
 $sql "SELECT DATE_FORMAT(date_field, '%W, %M %e, %Y') FROM table_name";

// Execute query
... 


HTH!

Reply With Quote
  #12  
Old September 17th, 2003, 06:18 PM
Bruski Bruski is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Toronto, Canada
Posts: 192 Bruski User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
PHP Code:
 $query "SELECT id,title, news, name, country, grade, DATE_FORMAT(date, '%W, %M %e, %Y') FROM news ORDER BY id DESC LIMIT 10"


comes out blank ... maybe because i already formated it in mysql...did the 0000-00-00 00:00:00 thing =[...anyway to do it with sql?

Reply With Quote
  #13  
Old September 18th, 2003, 09:04 PM
FrankieShakes FrankieShakes is offline
Frank The Tank!
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: Jun 2002
Location: Toronto, Canada
Posts: 1,246 FrankieShakes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via ICQ to FrankieShakes Send a message via MSN to FrankieShakes
Hmmm... That's weird... What if you try enclosing your date field in single quotes:

Code:
$query = "SELECT id,title, news, name, country, grade, DATE_FORMAT('date', '%W, %M %e, %Y') FROM news ORDER BY id DESC LIMIT 10";


Here's the link to the MySQL manual:

http://www.mysql.com/doc/en/Date_an..._functions.html

Reply With Quote
  #14  
Old September 19th, 2003, 07:13 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
You shouldn't need to enclose the field name in quotes. I think the issue is just that you've got an invalid date. I inserted "0000-00-00 00:00:00" and NOW() into a date field and selected date_format(field,'%W %M %e %Y') from the table. For the 0000-00-00 entry, it returned null. The other returned correctly. So make sure you've got a valid date and try the code again.

Reply With Quote
  #15  
Old September 19th, 2003, 07:47 AM
Bruski Bruski is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Toronto, Canada
Posts: 192 Bruski User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
i made another date field in the db ....

CREATE TABLE news (
id INT (11) not null AUTO_INCREMENT,
title VARCHAR (50),
news TEXT ,
name VARCHAR (50) ,
country VARCHAR (50) ,
grade VARCHAR (50) ,
date DATE ,
PRIMARY KEY (id)
);

in the date i have 2003-09-19

in my sql i have same as above and i still cannot get it to display

it doesnt display anything now =[

Reply With Quote
  #16  
Old September 19th, 2003, 07:51 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
Weird. Works like a charm for me:

Code:
mysql> select * from news;
+----+-------+------+------+---------+-------+------------+
| id | title | news | name | country | grade | date       |
+----+-------+------+------+---------+-------+------------+
|  1 | NULL  | NULL | NULL | NULL    | NULL  | 2003-09-19 |
+----+-------+------+------+---------+-------+------------+
1 row in set (0.00 sec)

mysql> SELECT id,title, news, name, country, grade, DATE_FORMAT(date, '%W, %M %e, %Y') FROM news ORDER BY id DESC LIMIT 10;
+----+-------+------+------+---------+-------+------------------------------------+
| id | title | news | name | country | grade | DATE_FORMAT(date, '%W, %M %e, %Y') |
+----+-------+------+------+---------+-------+------------------------------------+
|  1 | NULL  | NULL | NULL | NULL    | NULL  | Friday, September 19, 2003         |
+----+-------+------+------+---------+-------+------------------------------------+
1 row in set (0.00 sec)


What os/mysql version are you running? Maybe there's something weird with the date_format() command on mysql for Windows or something?

Reply With Quote
  #17  
Old September 19th, 2003, 07:52 AM
Bruski Bruski is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Toronto, Canada
Posts: 192 Bruski User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
just incase you want to see my script here it is

http://bruski.hell-yeah.net/news.phps

PHP version 4.3.3
MySQL version 4.0.15-standard

Last edited by Bruski : September 19th, 2003 at 08:11 AM.

Reply With Quote