Jump to content

[SOLVED] functions.. frustrating


spfoonnewb

Recommended Posts

I created a function that does a lot, and I need the value of it to be inserted into a mysql database..

 

If I call the function the normal way..

 

echo function_name();

 

It returns the value that I want.

 

 

It wont let me save that value as a variable such as..

 

$var = function_name();

 

If I put the function in the mysql insert statement the output is blank.

 

VALUE('".function_name()."')

What do I do!?

 

The end result of a function has to run a for each that looks like:

 

foreach ($str as $strval) {
	echo $strval;
}

 

So I cant save the stuff the function does as variable either.

Link to comment
https://forums.phpfreaks.com/topic/44087-solved-functions-frustrating/
Share on other sites

sorry didn't see your last post...

 

try something like this:

<?php

$variable = myfunction();

for($i=0, $i<=count($variable), $i++){
echo $variable[$i]."<br />";
}

function myfunction(){
foreach ($str as $strval) {
	$something[] = $strval;
}

return $something;
}

?>

 

*untested

Ok, now that works.. but I need a way to get it to save into the database

 

The following returns the value I need.. but I can't get it in mysql

 

$variable = myfunction();

for ($i=0; $i<=count($variable); $i++) {
echo $variable[$i];
}

 

Heres a non-working way of what I mean..

 

$variable = myfunction();
$test = for ($i=0; $i<=count($variable); $i++) { echo $variable[$i]; }

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.