[PHP-DB] formatting a date from mysql

2005-12-12 Thread Eternity Records Webmaster
I need to figure out how to format the date format: year-month-day
(2005-12-06). It is a date(8) field in a mysql table that i pulled out of
the table with php 5.0.5. I need it in the format: Tue December 6, 2005 (or
in mysql's formatting: 6-12-2005). I am using the reformatting for display
only. So it would be something like this:

echo $journal['Date']; //with whatever formatting needed

If possible I need php to do the formatting for me. Thanks...

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] formatting a date from mysql

2005-12-12 Thread Adrian Bruce

farily straight forward to withinn the query itself, check out

http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html

or for php

http://uk.php.net/date

RTFM

Regards
Adrian

Eternity Records Webmaster wrote:


I need to figure out how to format the date format: year-month-day
(2005-12-06). It is a date(8) field in a mysql table that i pulled out of
the table with php 5.0.5. I need it in the format: Tue December 6, 2005 (or
in mysql's formatting: 6-12-2005). I am using the reformatting for display
only. So it would be something like this:

echo $journal['Date']; //with whatever formatting needed

If possible I need php to do the formatting for me. Thanks...

 



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] Re: formatting a date from mysql

2005-12-12 Thread El Bekko

Eternity Records Webmaster wrote:

I need to figure out how to format the date format: year-month-day
(2005-12-06). It is a date(8) field in a mysql table that i pulled out of
the table with php 5.0.5. I need it in the format: Tue December 6, 2005 (or
in mysql's formatting: 6-12-2005). I am using the reformatting for display
only. So it would be something like this:

echo $journal['Date']; //with whatever formatting needed

If possible I need php to do the formatting for me. Thanks...


An easy way to do it:

?php
explode(-,$date);
$journal['Date'] = $date[2] . - . $date[1] . - . $date[0];
?

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Minor Change

2005-12-12 Thread Micah Stevens

You're getting an error, after the query, put:

echo mysql_error();

to find out what's happening. 

On Monday 12 December 2005 11:05 am, [EMAIL PROTECTED] wrote:
 I made tiny changes to my php file and sql table and the table won't come
 up.  I updated the table name (and php file name) from 109fh5 to 109fh6.
 In the table, I changed 6 cells, leaving a couple blank.  Then I changed
 only the digit 5 to make it a 6 (109fh6) in the following:

 $get_data_query = select rep, party, state, cd, minority, afr_am, asian,
 am_indian, hispanic, med_hsehold_income, poverty from 109fh6 order by
 $sort_field $sort_order;

 Now I get Warning: mysql_fetch_assoc(): supplied argument is not a valid
 MySQL result resource in etc.

 I've done this many times without a problem (this is the 6th time in this
 sequence).  What could be wrong after such a minor change?

 Ken

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] Need a Help!

2005-12-12 Thread Mohamed Yusuf
I have table and insert data using song_id, that means one artist can have
many song_ids. my question is how can I query distinct artist with his/her
song_id while I will not get duplicate data like duplicate artist?
my code is like this

$content .=form id=\form1\ method=\post\ action=\\
  select name=\Quick\ onchange=\MM_jumpMenu('parent',this,0)\
option value=\#\Select Artist/option;


$result= $db-sql_query(SELECT distinct(artist), id FROM
.$prefix._lyrics order by artist asc);
if ($db-sql_numrows($result)) {
 while($row = $db-sql_fetchrow($result)) {
 extract($row);
 $content .=option value='modules.php
?name=$module_nameamp;file=artistamp;c_id=$id'$artist/option;
   }
}

$content .=/select
/form;

that code is fine except it gives me duplicate artist, so I want get rid off
that duplicate. any help


Re: [PHP-DB] Minor Change

2005-12-12 Thread kc68
After adding echo mysql_error(); I get the same result.  I tried changing  
the query to include 109fh7 (a table which doesn't exist) and got the same  
result as with 109fh6.  Changing to 109fh5 does pull up that table.  The  
line to which the error message refers is while ($row = mysql_fetch_assoc  
($data_set))  That is what always come up when there is an error in the  
query.


**
On Mon, 12 Dec 2005 14:13:10 -0500, Micah Stevens  
[EMAIL PROTECTED] wrote:




You're getting an error, after the query, put:

echo mysql_error();

to find out what's happening.

On Monday 12 December 2005 11:05 am, [EMAIL PROTECTED] wrote:
I made tiny changes to my php file and sql table and the table won't  
come

up.  I updated the table name (and php file name) from 109fh5 to 109fh6.
In the table, I changed 6 cells, leaving a couple blank.  Then I changed
only the digit 5 to make it a 6 (109fh6) in the following:

$get_data_query = select rep, party, state, cd, minority, afr_am,  
asian,

am_indian, hispanic, med_hsehold_income, poverty from 109fh6 order by
$sort_field $sort_order;

Now I get Warning: mysql_fetch_assoc(): supplied argument is not a  
valid

MySQL result resource in etc.

I've done this many times without a problem (this is the 6th time in  
this

sequence).  What could be wrong after such a minor change?

Ken




--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Minor Change

2005-12-12 Thread dpgirago

Ken:

Echo out the query. Check it. Run it from the MySQL client.

 What does the error message say? Does the table 109fh6 actually exist in
the database?

David

#  Ken responded:
#
# After adding echo mysql_error(); I get the same result.  I tried changing

# the query to include 109fh7 (a table which doesn't exist) and got the
same
# result as with 109fh6.  Changing to 109fh5 does pull up that table.  The

# line to which the error message refers is while ($row = mysql_fetch_assoc

# ($data_set))  That is what always come up when there is an error in the
# query.

**
On Mon, 12 Dec 2005 14:13:10 -0500, Micah Stevens
[EMAIL PROTECTED] wrote:


 You're getting an error, after the query, put:

 echo mysql_error();

 to find out what's happening.

 On Monday 12 December 2005 11:05 am, [EMAIL PROTECTED] wrote:
 I made tiny changes to my php file and sql table and the table won't
 come
 up.  I updated the table name (and php file name) from 109fh5 to 109fh6.
 In the table, I changed 6 cells, leaving a couple blank.  Then I changed
 only the digit 5 to make it a 6 (109fh6) in the following:

 $get_data_query = select rep, party, state, cd, minority, afr_am,
 asian,
 am_indian, hispanic, med_hsehold_income, poverty from 109fh6 order by
 $sort_field $sort_order;

 Now I get Warning: mysql_fetch_assoc(): supplied argument is not a
 valid
 MySQL result resource in etc.

 I've done this many times without a problem (this is the 6th time in
 this
 sequence).  What could be wrong after such a minor change?

 Ken


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Minor Change

2005-12-12 Thread tg-php
This isn't really a MySQL error (sorta), it's a PHP error.  You probably forgot 
to update a variable name when you updated everything else.

Here's an example sequence for querying using PHP/MySQL:

$TestQY = SELECT * from SomeTable;
$TestRS = mysql_query($TestQY) or die(Error executing query);
while ($TestRW = mysql_fetch_assoc($TestRS)) {
  $somearr[] = $TestRW;  // do something with data
}

Since you're getting a Not a valid MySQL result resouce error with the 
mysql_fetch_assoc() function, I'd search for all your mysql_fetch_assoc() 
statements and double check their $TestRS.  That error is saying that your 
$TestRS isn't a valid MySQL result set.  That could mean that $TestRS isn't 
defined (maybe you're still using $TestOldRS and forgot to change a variable 
name) or possibly that $TestQY is empty or bad somehow so mysql_query() isn't 
generating a proper MySQL result set (try echoing out your $TestQY to see what 
it is.. then try executing it manually on the MySQL server and see if you get 
an error).

You can try the or die() syntax I use above to see if mysql_query() is 
bombing out so you'll get notice before it even gets to the mysql_fetch_assoc().

Lastly.. someone recommended echoing out mysql_error(). Your response makes it 
sound like you think that this fixes your problem.  It's not going to fix 
anything, just possibly give you some information about what failed.  If you 
get a MySQL error message from mysql_error(), please post it. It might help us 
determine what the problem is.

It may not contain anything (under certain failing circumstances) so I'd step 
through the things I've listed above.  They may shed some light on where the 
error is and then we can figure out how to fix it.   Probably a typo in a 
query, variable name or table name I'm guessing.

Let us know if you find anything else out.

-TG

= = = Original message = = =

After adding echo mysql_error(); I get the same result.  I tried changing  
the query to include 109fh7 (a table which doesn't exist) and got the same  
result as with 109fh6.  Changing to 109fh5 does pull up that table.  The  
line to which the error message refers is while ($row = mysql_fetch_assoc  
($data_set))  That is what always come up when there is an error in the  
query.

**
On Mon, 12 Dec 2005 14:13:10 -0500, Micah Stevens  
[EMAIL PROTECTED] wrote:


 You're getting an error, after the query, put:

 echo mysql_error();

 to find out what's happening.

 On Monday 12 December 2005 11:05 am, [EMAIL PROTECTED] wrote:
 I made tiny changes to my php file and sql table and the table won't  
 come
 up.  I updated the table name (and php file name) from 109fh5 to 109fh6.
 In the table, I changed 6 cells, leaving a couple blank.  Then I changed
 only the digit 5 to make it a 6 (109fh6) in the following:

 $get_data_query = select rep, party, state, cd, minority, afr_am,  
 asian,
 am_indian, hispanic, med_hsehold_income, poverty from 109fh6 order by
 $sort_field $sort_order;

 Now I get Warning: mysql_fetch_assoc(): supplied argument is not a  
 valid
 MySQL result resource in etc.

 I've done this many times without a problem (this is the 6th time in  
 this
 sequence).  What could be wrong after such a minor change?

 Ken



___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Need a Help!

2005-12-12 Thread tg-php
Couple of things you can do:

1. Drop the song ID and only get the artist information  SELECT 
distinct(Artist) from songtable.  It doesn't look like your SELECT statement 
needs a song, but you include the song ID as $id anyway. Any reason for that or 
can you drop it so you only get artist?

2. Pre-parse the results of your current query so you only get one artist 
and/or compile a list of song ID's while you're at it.  Instead of doing your 
option in the database query result WHILE statement, do it outside:

while (results) {
  $artistinfo[$artist][] = $id;
}

Then:

echo select name='blah';
foreach ($artistinfo as $artist = $songsarr) {
  echo optgroup label='$artist';
  foreach ($songsarr as $songid) {
echo option value='$id'$id or whatever/option;
  }
  echo /optgroup;
}
echo /select;

3. Use a different DB structure.  I prefer this structure myself:

Table ARTISTS:
ArtistID
ArtistName
OtherArtistInfo

Table SONGS:
SongID
ArtistID
OtherSongInfo

Or, instead of having ArtistID, if more than one artist may be linked to a 
song, you can do:
Table xrefArtistsSongs:
ArtistID
SongID

Not sure why you'd want to do that for a song unless you're counting covers of 
songs and want all artists who've covered it to point to the same SongID data.

This way you can:

SELECT * from ARTISTS

for your ARTISTS select box

Then once an artist is selected, do a:

SELECT * from SONGS where ARTISTID = $artistid


Just some ideas.

Forgive the pseudo-code and mixed capitalizations.. I think you get the idea 
I'm trying to convey.

-TG

= = = Original message = = =

I have table and insert data using song_id, that means one artist can have
many song_ids. my question is how can I query distinct artist with his/her
song_id while I will not get duplicate data like duplicate artist?
my code is like this

$content .=form id=\form1\ method=\post\ action=\\
  select name=\Quick\ onchange=\MM_jumpMenu('parent',this,0)\
option value=\#\Select Artist/option;


$result= $db-sql_query(SELECT distinct(artist), id FROM
.$prefix._lyrics order by artist asc);
if ($db-sql_numrows($result)) 
 while($row = $db-sql_fetchrow($result)) 
 extract($row);
 $content .=option value='modules.php
?name=$module_nameamp;file=artistamp;c_id=$id'$artist/option;
   


$content .=/select
/form;

that code is fine except it gives me duplicate artist, so I want get rid off
that duplicate. any help


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Minor Change

2005-12-12 Thread Shahmat Dahlan

did it say which line does the error

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result 
resource in

is referring to. if it is referring to the line which contains the 
function call mysql_query (),
dpirago is right, there could be some mistake in the sql statement. 
running it through the mysql client would definitely verify whether your 
query is correct or not.


[EMAIL PROTECTED] wrote:


Ken:

Echo out the query. Check it. Run it from the MySQL client.

What does the error message say? Does the table 109fh6 actually exist in
the database?

David

#  Ken responded:
#
# After adding echo mysql_error(); I get the same result.  I tried changing

# the query to include 109fh7 (a table which doesn't exist) and got the
same
# result as with 109fh6.  Changing to 109fh5 does pull up that table.  The

# line to which the error message refers is while ($row = mysql_fetch_assoc

# ($data_set))  That is what always come up when there is an error in the
# query.

**
On Mon, 12 Dec 2005 14:13:10 -0500, Micah Stevens
[EMAIL PROTECTED] wrote:

 


You're getting an error, after the query, put:

echo mysql_error();

to find out what's happening.

On Monday 12 December 2005 11:05 am, [EMAIL PROTECTED] wrote:
   


I made tiny changes to my php file and sql table and the table won't
come
up.  I updated the table name (and php file name) from 109fh5 to 109fh6.
In the table, I changed 6 cells, leaving a couple blank.  Then I changed
only the digit 5 to make it a 6 (109fh6) in the following:

$get_data_query = select rep, party, state, cd, minority, afr_am,
asian,
am_indian, hispanic, med_hsehold_income, poverty from 109fh6 order by
$sort_field $sort_order;

Now I get Warning: mysql_fetch_assoc(): supplied argument is not a
valid
MySQL result resource in etc.

I've done this many times without a problem (this is the 6th time in
this
sequence).  What could be wrong after such a minor change?

Ken
 



 



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php