Jump to content

Pulling Array Data from an Object Method - roadblock


fedoracore
 Share

Recommended Posts

g'day, mate!please take a look at this code to see if you can determine what might be causing this: near the bottom, you'll see the calarray property i'm trying to get out of there via (declaring?) putting it at the top (sorry-- i'ven't got the jargon just yet...). it will print just fine from inside of the function, and everything else is working right-- but when i try to call the data from an object context, it's just not there. at first i thougth i was doing the ol' trying to print an array from the mysql Resource ID... but that wasn't it either (i don't think). have a look:

<?php class viewRecord {	var $rows;				  var $calarray;	var $calarrayraw; function queryData($table, $mastid) {		global $table;	global $mastid;	global $calarray; // just trying stuff here w/ this global..	require_once 'db_connect.class.php'; /** i also could NOT get the values to come through when including * this database link definition * so i've just stuck the 'real data' here, as you can see*/	$dblink = mysql_connect("localhost", "blah", "blahblah");	mysql_select_db("blahbleeblah", $dblink);			// BASIC QUERY HERE	$queryup = "SELECT * FROM $table WHERE $table.master_id=$mastid;";	// DO THE BASIC QUERY --THE VAR from which to FETCHARRAY	$queresult = mysql_query($queryup) or die(mysql_error());	$rawarry = mysql_fetch_array($queresult, MYSQL_NUM);/** VERIFY THERE IS DATA */	$rows = mysql_num_rows($queresult);		// GET THE SPECIFIC 'HUMAN DATE' AND THAT IS ALL WE DO HERE	$calendardata = "SELECT DATE_FORMAT(calendar, '%M-%d-%Y') AS fd FROM $table WHERE $table.master_id=$mastid;";	// DO HUMAN DATE QUERY	$querycal = mysql_query($calendardata) or die(mysql_error());		/* this little chunk here is the culpret -- and has taken many forms* this just happens to be one which might make more sense to you... maybe;)*/	$calarrayraw = mysql_fetch_array($querycal, MYSQL_ASSOC);	print_r($calarrayraw);	$calarray = $calarrayraw['fd'];/* see whats going on? trying to grab that formatted date stuff. * the print_r's output is: * Array ( [fd] => November-22-2006 )*/		return $rawarry;}}	   ?>

i appreciate any advice you have-- on any of it-- technique, solve this puzzle, tell me i need a haircut... whatever. also, that db_link.inc.php thing up there-- all i kept getting was "apache@localhost ... password NO" -- as if it's just defaulting to the Linux user (this is a Fedora system)... i dunno... weird. although, i've probably never tried that particular bit (a db link include).the main problem is the DATE DATA of course. the queryData() function itself (sans 'human date') works beautifully (i think!), so i'm glad of that.thank you!!!

Link to comment
Share on other sites

i haven't "tried it" yet, but i think i see where at least one of the problems is coming from...instead of using $this->calarray , i've used just $calarray, which in my inexperience, i believe, pretty much negates the whole point of the "object"... so... i gotta fix that for starters...

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...