[ale] [OT] need help with 2php SOLUTION

George Carless kafka at antichri.st
Fri Apr 11 09:11:53 EDT 2003


I'm really not sure what you're referring to, here.. there's no reason to
re-query a database for data if you already know what the data has been
set to.  Perhaps posting some actual (rather than psuedo) code would help
explicate the situation?

I didn't quite understand Brian's example, either (and I do this stuff for
a living) .. Brian, did you mean something like:

if (myfunction($param)) {
	echo "Sendemail";
}


?  Or am I missing something?  Your example
wouldn't seem to parse, from where I'm sitting.  But the general notion of
checking for the return value is a sound one.

Cheers,
--George

On Fri, 11 Apr 2003, ChangingLINKS.com wrote:

> Man, you can't "be" talkin' to a script-kiddie like that. :) That stuff was
> over my head. I just spent 5 minutes trying to log into my ftp server with
> incorrect login errors *because my caps lock was pressed down. . . .*
>
> again.
>
> Anyway, the solution to the problem was much more simple than the appreciated
> recommendations.
>
> Lesson learned:
> If you pull a query from a database and then alter the data with a function,
> you must query the database again instead of using a variable that was set by
> the original query.
>
> wrong:
>  query
>  set variables A-E
>  function
>  echo variable C (this will reflect the A-E state of the database)
>
> right:
> query
> set variables A-E
> function
> query (even if this is in the function is seems to be essential)
> set variable C
> echo variable C
>
> One day I will buy a book about PHP and read instead of coding by trial and
> error. :) Thanks for the help!!
>
> --
> Wishing you Happiness, Joy and Laughter,
> Drew Brown
> http://www.ChangingLINKS.com
>
>
> On Thu April 10 2003 13:33, Brian wrote:
> > How about having the function return a boolean and do
> > this instead:
> >  if (function($sendemail($param)) {
> >      echo "Sendemail";
> >  }
> >
> > Otherwise, you can set $sendmail as a global variable
> > and have your function return a the new $sendmail
> > value. You can also pass $sendmail using the pass by
> > reference operator "&". This way, the function will
> > affect the variable $sendmail upon return.
> >
> > > <?php
> > > connect to database
> > > select a record
> > > set variable $res that counts number of rows
> > > 	if( mysql_num_rows( $res ) > 0 )
> > > 	{
> > > 	$set variables for information in columns
> > > 	include ("file with function that alters records");
> > > 	call the function
> > > 		the function sets a variable $sendemail "yes" or
> > > "no"
> > > 	{
> > > 	if( $sendemail == "yes" )
> > > 	{
> > > 	echo "$sendemail";
> > > 	}
> > >   }
> > > ?>
> > >
> > > The problem is that no matter what I do in the
> > > function (which works) the
> > > calling script does NOT recognize the results of the
> > > function. The calling
> > > script can only see the state the database was in
> > > before calling the
> > > function.
> > >
> > > Why?
> > >
> > > Can't a function in another file set a variable that
> > > is recognized by the
> > > calling script? If not, how come the calling script
> > > does not recognize the
> > > update to the database either?
> > >
> > > Can someone help me write the 2 *working* lines that
> > > will recognize the work
> > > of the function?
> > > (I tried removing the { before the second if and the
> > > } after the last
> > > $sendemail)
> > >
> > > --
> > > Wishing you Happiness, Joy and Laughter,
> > > Drew Brown
> > > http://www.ChangingLINKS.com
> > > _______________________________________________
> > > Ale mailing list
> > > Ale at ale.org
> > > http://www.ale.org/mailman/listinfo/ale
> >
> > __________________________________________________
> > Do you Yahoo!?
> > Yahoo! Tax Center - File online, calculators, forms, and more
> > http://tax.yahoo.com
> > _______________________________________________
> > Ale mailing list
> > Ale at ale.org
> > http://www.ale.org/mailman/listinfo/ale
>
>
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://www.ale.org/mailman/listinfo/ale
>

_______________________________________________
Ale mailing list
Ale at ale.org
http://www.ale.org/mailman/listinfo/ale





More information about the Ale mailing list