Connecting Tech Pros Worldwide Help | Site Map

call function in different php files

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 17th, 2005, 01:37 AM
Krista
Guest
 
Posts: n/a
Default call function in different php files

Hi, I wrote a php project 2 years ago. I am totally lost right now.
what is differnt between $userName, $_GET['userName'] and
$_REQUEST['userName']? In my past project, I remember i can use
$userName as a variable, but i dont know why I cannot use it again
because of using different version of php and apache? What is
different between "printf", "print" and "echo"? Can you guys help me
fix my a little project too? Thanks

Two files
testing1.php
<?php

require ('testing.php');

if(!$_REQUEST['submit1'])
{

MainFrame();
}
else if ($submit1 == "Receiving")
{
print $_REQUEST['username'];
}
else

print $_REQUEST['sumbit1'];

?>

testing.php
<?php

function MainFrame()
{
print ("<form action = "testing1.php" method="POST">
<input type ="text" name="username"><br>
<input type ="submit" name="submit1" value="Receiving">
<input type ="submit" name="submit1" value="Invenory">
<input type ="submit" name="submit1" value="Assembly">
<input type ="submit" name="submit1" value="Tracking">
<input type ="submit" name="submit1" value="Reports">
<input type ="submit" name="submit1" value="Setup">
</form>
")

?>

I get these errors:

Parse error: parse error, unexpected T_STRING in c:\program
files\easyphp1-7\www\testing.php on line 5

Notice: Undefined index: submit1 in c:\program
files\easyphp1-7\www\testing1.php on line 6

Fatal error: Call to undefined function: mainframe() in c:\program
files\easyphp1-7\www\testing1.php on line 9

Thanks,
Krista

  #2  
Old July 17th, 2005, 01:37 AM
websafe
Guest
 
Posts: n/a
Default Re: call function in different php files

"Perhaps the most controversial change in PHP is when the default value for
the
PHP directive register_globals went from ON to OFF in PHP 4.2.0. "

http://pl2.php.net/register_globals

IMHO U have 2 ways

1. Use $_GET, $_POST, $_SERVER
or
2. Set the register_globals=on in php.ini

:) i hope this helps you out :)


  #3  
Old July 17th, 2005, 01:37 AM
Paul 'piz' Wellner Bou
Guest
 
Posts: n/a
Default Re: call function in different php files

Hi Krista,
[color=blue]
> what is differnt between $userName, $_GET['userName'] and
> $_REQUEST['userName']?[/color]

The GET-Variables are submitted like this:
http://domain.tld/file.php?variable=value

So $_GET['variable'] contains "value".
[color=blue]
> In my past project, I remember i can use
> $userName as a variable, but i dont know why I cannot use it again
> because of using different version of php and apache?[/color]

If the option of register_globals is switched on in the php.ini you can
use $variable instead of $_GET['variable'], too.
If it is switched off, like the default setting in the newer php
versions, you can't.
[color=blue]
> What is different between "printf", "print" and "echo"?[/color]

Difference between echo and print:
http://www.faqts.com/knowledge_base/...l/aid/1/fid/40

printf is to print a formatted string.
http://de2.php.net/manual/en/function.printf.php

Saludo
Paul.
  #4  
Old July 17th, 2005, 01:37 AM
Keith Bowes
Guest
 
Posts: n/a
Default Re: call function in different php files

Krista wrote:[color=blue]
> What is
> different between "printf", "print" and "echo"?[/color]

printf is formatted print, as:
printf("Error %s occurred on line %d", $error_desc, $error_line);

print and echo are close to the same thing. IIRC, print returns but
echo doesn't.

  #5  
Old July 17th, 2005, 01:40 AM
Krista
Guest
 
Posts: n/a
Default Re: call function in different php files

Keith Bowes <do.not@spam.me> wrote in message news:<dLnCb.60$Sd4.39@fe10.private.usenetserver.co m>...[color=blue]
> Krista wrote:[color=green]
> > What is
> > different between "printf", "print" and "echo"?[/color]
>
> printf is formatted print, as:
> printf("Error %s occurred on line %d", $error_desc, $error_line);
>
> print and echo are close to the same thing. IIRC, print returns but
> echo doesn't.[/color]

Hi,
I still get a problem if i set global_register to on. I cannot pass
the value to the different php files. The example as following:

Testing.php
<?php

function abc()
{
print("<form action = "testing1.php" method="GET">
<input type ="text" name="username"><br>
<input type ="submit" name="submit1" value="Receiving">
<input type ="submit" name="submit1" value="Inventory">
</form>
}
?>
Testing1.php
<?php

require ("testing.php");

if(!$sumbit1)
{
abc();
}
else if ($submit1 == "Receiving")
{
print "Receiving";
}
else if ($submit1 == "Inventory")
{
print "Inventory";
}
else
{
print "Thank";
}
?>
Then i am tring to run it in IE: http://localhost/testing1.php
but the result is nothing on the IE.
Therefore, what is the problem in my problem or my config has a
problem?
Thanks,
Krista
  #6  
Old July 17th, 2005, 01:40 AM
Pedro Graca
Guest
 
Posts: n/a
Default Re: call function in different php files

Krista wrote:[color=blue]
> Testing1.php
><?php
>
> require ("testing.php");
>
> if(!$sumbit1)[/color]
_____ $submit1 ___

Perhaps this is better? :-)


put
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
?>

at the very beginning of the scripts you're writing/debugging so that
php itself will tell you about some mistakes (with its notices and
warnings).


Happy Coding
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
  #7  
Old July 17th, 2005, 01:40 AM
Krista
Guest
 
Posts: n/a
Default Re: call function in different php files

Keith Bowes <do.not@spam.me> wrote in message news:<dLnCb.60$Sd4.39@fe10.private.usenetserver.co m>...[color=blue]
> Krista wrote:[color=green]
> > What is
> > different between "printf", "print" and "echo"?[/color]
>
> printf is formatted print, as:
> printf("Error %s occurred on line %d", $error_desc, $error_line);
>
> print and echo are close to the same thing. IIRC, print returns but
> echo doesn't.[/color]

Hi,
Even though I changed the global_register to on in php.int . I still
cannot use $username. Anybody can help?

Thanks,
Krista
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.