[SOLVED] val and string

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
stevestark5000
Forum Commoner
Posts: 61
Joined: Thu Jan 27, 2011 12:08 am

[SOLVED] val and string

Post by stevestark5000 »

echo val 'archive_days'; outputs a string instead if a val. how to output a val instead?
Last edited by stevestark5000 on Mon Mar 07, 2011 11:33 pm, edited 1 time in total.
stevestark5000
Forum Commoner
Posts: 61
Joined: Thu Jan 27, 2011 12:08 am

Re: val and string

Post by stevestark5000 »

anyone?
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: val and string

Post by califdon »

It's not clear what you are asking. "val" doesn't mean anything to me. Are you trying to cast a string to be a value?? In the first place, that doesn't make sense, and in the second place, you can't do a cast as part of the echo command. What is it that you want to do?
stevestark5000
Forum Commoner
Posts: 61
Joined: Thu Jan 27, 2011 12:08 am

Re: val and string

Post by stevestark5000 »

Code: Select all

if($_SESSION['SES_ART_master']->val['archive_days']>0) 
  $article_tags['HISTORYLINK'] = '<a href="index.php?module=article&viewhistory='. $this->id.'" target="_blank">' . $_SESSION['translate']->it('View Revision History').'</a>';
in the above code, if val > 0 then create the link. I am asking how to determine what archive_days value is. i am trying to create the link if archive_days is greater than 0 but it is not working.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: val and string

Post by califdon »

val is apparently an array and 'archive_days' is an index into that array. I recommend that you determine where that array is created in your script. You might start by just echoing the value, like this:

Code: Select all

echo "The value of archive days is: ".val['archive_days'];
just before that if statement.
stevestark5000
Forum Commoner
Posts: 61
Joined: Thu Jan 27, 2011 12:08 am

Re: val and string

Post by stevestark5000 »

i got an error when i pasted the code in.
Parse error: syntax error, unexpected '[', expecting ',' or ';'

and when i paste below the code i get this...
Parse error: syntax error, unexpected T_STRING
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: val and string

Post by califdon »

My bad. If your "val" is actually an array, there should have been a $ preceding it, thus:

Code: Select all

echo "The value of archive days is: ".$val['archive_days'];
See, that's the problem, I'm having to guess at what's in your code. In any case, it has to be defined earlier in your code, so you should begin by determining what this "val" IS. Where is it defined??
stevestark5000
Forum Commoner
Posts: 61
Joined: Thu Jan 27, 2011 12:08 am

Re: val and string

Post by stevestark5000 »

$val['archive_days']; did not output anything yet it is defined in the mysql database as 7. this is strange. I cant find the val function in the module and searching over 3000 files would take too long to find it. is there a quick way to find it?
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: val and string

Post by califdon »

stevestark5000 wrote:$val['archive_days']; did not output anything yet it is defined in the mysql database as 7. this is strange. I cant find the val function in the module and searching over 3000 files would take too long to find it. is there a quick way to find it?
$val['archive_days'] can't possibly be defined in your database; it is not a value, nor is it a function, it is an Array. Somewhere in your code there should be a line that declares it and assigns a value to it, perhaps something like:
$val=Array();
$val]'archive_days']=14;

I think we're not going to make much progress here. Your questions indicate that you have a lot to learn about PHP before you can describe what your script is doing. I would like to help you, but we are just not communicating.
stevestark5000
Forum Commoner
Posts: 61
Joined: Thu Jan 27, 2011 12:08 am

Re: val and string

Post by stevestark5000 »

i am sorry, i meant to say that archive_days is defined in the database as 7. I solved it by finding it in the database. your right, i need to learn a lot first. lets forget this topic and i will study more. thank you for your help in this topic.
Post Reply