Current location: Hot Scripts Forums » Programming Languages » PHP » a query problem


a query problem

Reply
  #1 (permalink)  
Old 12-20-03, 11:36 AM
darkcarnival's Avatar
darkcarnival darkcarnival is offline
PHP/MySQL coder
 
Join Date: Jun 2003
Location: Michigan
Posts: 939
Thanks: 0
Thanked 0 Times in 0 Posts
a query problem

hi,

I have a program that i want to log submitions so i know what people are asking for but it doesnt log it :S heres the line of code im using:

PHP Code:

while ($row mysql_fetch_array ($resultsMYSQL_ASSOC)) {

 echo 
"<A HREF=\"{$row['Address']}\">{$row['Name']}</A> - {$row['Description']}<br>\n";

}
mysql_query("INSERT INTO SSearch_log (Catagory, Keyword, Date) VALUES ($Choice$keyword$date);"); 
i think i know what i did wrong but im not 100% could someone help me thx
__________________
Elite Bulletin Board
http://elite-board.us
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 12-20-03, 11:44 AM
NeverMind's Avatar
NeverMind NeverMind is offline
Community VIP
 
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
this peice of code doesn't help much !
but anyway the log should be done in the page that displays the item you want ..
so it gets the name and INSERT all the info about this $name in the log table ..
that what I use..
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9]
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 12-20-03, 12:22 PM
darkcarnival's Avatar
darkcarnival darkcarnival is offline
PHP/MySQL coder
 
Join Date: Jun 2003
Location: Michigan
Posts: 939
Thanks: 0
Thanked 0 Times in 0 Posts
ok i think i know what your talking about ill give it a try.thx
__________________
Elite Bulletin Board
http://elite-board.us
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 12-20-03, 12:52 PM
darkcarnival's Avatar
darkcarnival darkcarnival is offline
PHP/MySQL coder
 
Join Date: Jun 2003
Location: Michigan
Posts: 939
Thanks: 0
Thanked 0 Times in 0 Posts
hi,

i fixed it but theres still 1 small problem. the date doesnt appear it shows 0000-00-0000 heres the fixed code:

PHP Code:



while ($row mysql_fetch_array ($resultsMYSQL_ASSOC)) {
 echo 
"<A HREF=\"{$row['Address']}\">{$row['Name']}</A> - {$row['Description']}<br>\n";

mysql_query("INSERT INTO SSearch_log (Catagory, Keyword, Date) VALUES ('$Choice', '$keyword', '$date')");

and if you need to know what $date look like:

PHP Code:

$date Date("j-d-Y"); 

i hope someone can help me with this. thx
__________________
Elite Bulletin Board
http://elite-board.us
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 12-20-03, 01:05 PM
mdhall's Avatar
mdhall mdhall is offline
Aspiring Coder
 
Join Date: Oct 2003
Posts: 510
Thanks: 1
Thanked 1 Time in 1 Post
I usually make a field named "current_date" ( field-type is date ) in the table row, and have the insert query use 'now()' to insert the date in the field. Then display it as

$current_date=$date;
$date = Date("m-d-Y");
or
$date = Date("d-m-Y");

Don't know if its the best way but it works.

Last edited by mdhall; 12-20-03 at 01:18 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 12-20-03, 04:22 PM
darkcarnival's Avatar
darkcarnival darkcarnival is offline
PHP/MySQL coder
 
Join Date: Jun 2003
Location: Michigan
Posts: 939
Thanks: 0
Thanked 0 Times in 0 Posts
well what is the problem with the code i got now. is there a way to fix the code i got now?
__________________
Elite Bulletin Board
http://elite-board.us
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #7 (permalink)  
Old 12-20-03, 04:32 PM
mdhall's Avatar
mdhall mdhall is offline
Aspiring Coder
 
Join Date: Oct 2003
Posts: 510
Thanks: 1
Thanked 1 Time in 1 Post
What is the value of $date when it is inserted? Is it coming from a form or being added automatically?

$date = Date("j-d-Y");

Change the "j" to "m", see if that helps.

Wasn't inferring that I had a better way to do it, just offering another option.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #8 (permalink)  
Old 12-20-03, 04:39 PM
darkcarnival's Avatar
darkcarnival darkcarnival is offline
PHP/MySQL coder
 
Join Date: Jun 2003
Location: Michigan
Posts: 939
Thanks: 0
Thanked 0 Times in 0 Posts
it should be added automatically. and i guess m would be correct ill give it a try
__________________
Elite Bulletin Board
http://elite-board.us
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Declared Functions skipper23 PHP 4 12-17-03 11:06 AM
Trouble with query coolblu PHP 1 12-17-03 01:47 AM
index page not showing up skipper23 PHP 3 12-15-03 02:10 PM
Show query results by in a different way mdhall PHP 4 11-09-03 12:18 PM
ASP SQL query string problem CollinAmes ASP 2 10-24-03 12:09 PM


All times are GMT -5. The time now is 09:46 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.