Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 03-06-2003, 10:41 PM   #1 (permalink)
bdl
Senior Contributor
 
Join Date: May 2002
Location: vta.ca.usa
Posts: 555
bdl is on a distinguished road
Custom function

Hokay. Now I'm trying to return a value from a custom function, the modified date from the mysql database, formatted properly. This works perfectly if it's actually embedded into the script, doesnt work at all as a seperate included function.

PHP Code:
function getModDate($db_table) {
// modified date string
    
global $mod_date;
    
$mod_result mysql_query("SELECT DATE_FORMAT(DATE_SUB(modified, INTERVAL 3 HOUR),
                '%c/%d/%y @ %r') FROM $db_table ORDER BY modified DESC LIMIT 1"
);
    
$row mysql_fetch_array($mod_resultMYSQL_NUM);
    
$mod_date $row['0'];
    return 
$mod_date;

Since the value of $mod_date is changed into a string on the last line, why wouldn't it just return that value?
bdl is offline   Reply With Quote
Old 03-07-2003, 06:40 AM   #2 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,475
sde is on a distinguished road
is it just not returning anything? erorrs?

this may be a long shot, .. but you don't need single quotes around a parameter of an array if it is a number:

$mod_date = $row[0];

quotes might be forcing it to think '0' is a string in the results and not a number .. try taking those out.

just a thought.
sde is offline   Reply With Quote
Old 03-07-2003, 11:32 AM   #3 (permalink)
bdl
Senior Contributor
 
Join Date: May 2002
Location: vta.ca.usa
Posts: 555
bdl is on a distinguished road
I figured it out... I was relying solely on the 'return $mod_date' to return the value of the string, and forgot completely to put the variable in my other script, like so:

PHP Code:
$mod_date getModDate($db_table); 

I was just calling the function, like 'getModDate($db_table)'. Doh!

Thanks, though!!
:o
bdl is offline   Reply With Quote
Old 03-07-2003, 05:53 PM   #4 (permalink)
bdl
Senior Contributor
 
Join Date: May 2002
Location: vta.ca.usa
Posts: 555
bdl is on a distinguished road
BTW, here's the updated function, cleaned it up a bit..
PHP Code:
function getModDate($db_table) {
    
/*
    modified date string - grabs the 'modified' column from the table
    and returns the last entry's modified date, in PST
    */
    
    
$mod_result mysql_query("SELECT DATE_FORMAT(DATE_SUB(modified,
                  INTERVAL 3 HOUR), '%c/%d/%y @ %r') FROM $db_table
                  ORDER BY modified DESC LIMIT 1"
);
    
$row mysql_fetch_array($mod_resultMYSQL_NUM);
    return 
$row[0];
    

bdl is offline   Reply With Quote
Reply

Bookmarks

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom Component Phatslugga Java 4 04-13-2003 10:46 PM
pass filename to function Blaqb0x Standard C, C++ 1 09-02-2002 10:12 PM
trouble calling auxiliary function in a class brtklt Standard C, C++ 0 07-18-2002 05:22 PM


All times are GMT -8. The time now is 11:23 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting