General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old November 28th, 2002, 09:50 PM
Attila Attila is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 67 Attila User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Functions

Hello I know how to make functions in the page I am working in.

What I want to do is make a folder and put all my seperate functions in their own file inside the functions folder.

Ex
Directory structure
index.php
functions/all my function files

I have a function call inside index.php that needs to connect to a function inside my functions folder.

how do I call it?
__________________
Thanks,
Attila
http://www.glorynaspiration.com
http://www.abitofthings.com

Reply With Quote
  #2  
Old November 28th, 2002, 10:17 PM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
include("functions/functionfile.php");

functionname();

Reply With Quote
  #3  
Old November 28th, 2002, 11:00 PM
Attila Attila is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 67 Attila User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Thank you I was very close....That worked.

What about this now.
PHP Code:
echo "|";
echo 
"<a href=/index.php>$name</a> ";
echo 
"|"


This should create a link to $name.

Although what is in blue below is what I get as a link.

|$name|

Why do I get both the | stuck inside the link?

Reply With Quote
  #4  
Old November 29th, 2002, 12:07 AM
Joe4JC Joe4JC is offline
The name's Joe. Yours?
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Location: Lurking in the shadows...
Posts: 147 Joe4JC User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
PHP Code:
echo '|<a href="/index.php">'.$name.'</a>|'
__________________
Check out 4Life today!

Reply With Quote
  #5  
Old November 29th, 2002, 05:14 PM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
is that code inside of a function?

Reply With Quote
  #6  
Old November 30th, 2002, 01:18 AM
Spathe Spathe is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 7 Spathe User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Did you forget to close previous open link tag in your page ?

Reply With Quote
  #7  
Old November 30th, 2002, 02:47 AM
Attila Attila is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 67 Attila User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Nope still no luck with that part about the | being part of the link. I even coppied your code. looks as though it is bleeding over. It is realy weird. I am using Dreamweaver MX.

Now I need some more help please.

I am curently working on a portal system....Nothing too fancy just something to tinker with. If I was to give this to someone to install on their website I would need a setup script. So that is what I have created. On my first page I get all the basic information from the person setting up the portal..Then it calls this page to do all the work.

I am trying to write the information to a config_file inside my directory tree so I can refer to it later if needed. I will need it all the connection data.

I know this code is very rough and needs alot of work. Any help would be appreciated but what I am having problems doing is writing the data to the config file so I can grab it later.

PHP Code:
<?

    
global $board_url
    global 
$sql_host;
    global 
$sql_database;
    global 
$sql_user;
    global 
$sql_pass;
    global 
$adminname;
    global 
$adminpassword;
    global 
$adminpassword2;
    global 
$email;
    global 
$HTTP_POST_VARS;
    
    
// Check for blank info in the entries.
    
$root "./";


        if (
$board_url == "")
            {
                echo 
"You did not enter all the required information all fields must be filled in.";
                exit;
            }
        if (
$sql_host == "")
            {
                echo 
"You did not enter all the required information all fields must be filled in.";
                exit;
            }
        if (
$sql_database == "")
            {
                echo 
"You did not enter all the required information all fields must be filled in.";
                exit;
            }
        if (
$sql_user == "")
            {
                echo 
"You did not enter all the required information all fields must be filled in.";
                exit;
            }
        if (
$sql_pass == "")
            {
                echo 
"You did not enter all the required information all fields must be filled in.";
                exit;
            }
        if (
$adminname == "")
            {
                echo 
"You did not enter all the required information all fields must be filled in.";
                exit;
            }
        if (
$adminpassword == "")
            {
                echo 
"You did not enter all the required information all fields must be filled in.";
                exit;
            }
        if (
$adminpassword2 == "")
            {
                echo 
"You did not enter all the required information all fields must be filled in.";
                exit;
            }
        if (
$email == "")
            {
                echo 
"You did not enter all the required information all fields must be filled in.";
                exit;
            }
        
    
//You get to here all the information was entered.  Entered correctly is a differnt story.
    
    //Do the passwords match for the admin?
    
    
if ($adminpassword != $adminpassword2)
    {
        echo 
"Your admin passwords did not match.";
        exit;
    }
    
    
//Did they enter the correct database information?  Test the connection
    
    
if ( ! $dbconnect mysql_connect($sql_host$sql_user,$sql_pass))
    {
        echo (
"Could not create a mySQL connection, please check the SQL values entered");
        exit;
    }
    
        
    if ( ! 
mysql_select_db($sql_database$dbconnect))
    {
        echo (
"mySQL could not locate a database called '$sql_database' ' please check the name you entered and try again.");
        exit;
    }
    
    
//Check to see if they uploaded cong_global.php
    
$isfilethere $root."conf_global.php";
    
    if ( ! 
file_exists($isfilethere) )
    {
        echo (
"Could not locate '$isfilethere'. Did you upload the file?");
    }
    

    include(
$isfilethere);
    
    
    
    
//Can I write the data to the conf_global.php
$thisdata "\n    
\$ban_ip                    =    '';\n
\$ban_email                =    '';\n
\$ban_names                =    '';\n
\$Squad_start            =    time();\n
\$admin_group            =    '4';\n
\$auth_group                =    '1';\n
\$member_group            =    '3';\n
\$guest_group            =    '2';\n
\$squadname                =    'Squad Portal';\n
\$squad_desc                =    'Squad Portal System';\n
\$squad_url                =    '';\n
\$clock_long                =    'M j Y, h:i A';\n
\$clock_short            =    'jS F Y - h:i A';\n
\$clock_joined            =    'j-F y';\n
\$email_header            =    'This email generated via Squad Portal';\n
\$show_active            =    '1';\n
\$sql_driver                =    'mySQL';\n
\$sql_host                =    .$sql_host;\n
\$sql_database            =    .$sql_database;\n
\$sql_pass                =    .$sql_pass;\n
\$sql_user                =    .$sql_user;\n
\$home_name                =    .$board_url;\n
\$home_url                =    .$board_url;\n
\$html_dir                =    .$root;\n
\$base_dir                =    .$root;\n
\$html_url                =    .$board_url;\n
\$upload_dir                =    .$root.\"uploads\";\n
\$upload_url                =    .$board_url.\"/uploads\";\n
$session_expiration        =    '3600';\n
?>"
;


//create conf_global.php
if ( $pleasework fopen$isfilethere"a+" ) )
    {
         
fwrite($pleasework$thisdata);
         
fclose($pleasework);
     }
     else
     {
         echo (
"Could not write to 'conf_global.php'");
     }
echo 
"Just wrote to the database";
?>

Reply With Quote
  #8  
Old November 30th, 2002, 03:04 AM
Spathe Spathe is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 7 Spathe User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Look my comments...
Quote:
Originally posted by Attila
PHP Code:
<?
    
//Check to see if they uploaded cong_global.php
    
$isfilethere $root."conf_global.php";
    
    if ( ! 
file_exists($isfilethere) )
    {
        echo (
"Could not locate '$isfilethere'. Did you upload the file?");
    }
    
        
// Why did you include $isfilethere ? This file is suppose to be incomplete...
    
include($isfilethere);
    
    
    
    
//Can I write the data to the conf_global.php
$thisdata "
\$ban_ip                    =    '';
\$ban_email                =    '';
\$ban_names                =    '';
\$Squad_start            =    "
.time()."; // Here
\$admin_group            =    '4';
\$auth_group                =    '1';
\$member_group            =    '3';
\$guest_group            =    '2';
\$squadname                =    'Squad Portal';
\$squad_desc                =    'Squad Portal System';
\$squad_url                =    '';
\$clock_long                =    'M j Y, h:i A';
\$clock_short            =    'jS F Y - h:i A';
\$clock_joined            =    'j-F y';
\$email_header            =    'This email generated via Squad Portal';
\$show_active            =    '1';
\$sql_driver                =    'mySQL';
\$sql_host                =    .$sql_host;
\$sql_database            =    .$sql_database;
\$sql_pass                =    .$sql_pass;
\$sql_user                =    .$sql_user;
\$home_name                =    .$board_url;
\$home_url                =    .$board_url;
\$html_dir                =    .$root;
\$base_dir                =    .$root;
\$html_url                =    .$board_url;
\$upload_dir                =    .$root.\"uploads\";
\$upload_url                =    .$board_url.\"/uploads\";
\$session_expiration        =    '3600'; // The anti-slashe
?>"
;


//create conf_global.php
if ( $pleasework fputS$isfilethere"a+" ) ) // fWrite is for write binairy file (little detail)
    
{
         
fwrite($pleasework$thisdata);
         
fclose($pleasework);
     }
     else
     {
         echo (
"Could not write to 'conf_global.php'");
     }
echo 
"Just wrote to the database";
?>

Last edited by Spathe : November 30th, 2002 at 03:11 AM.

Reply With Quote
  #9  
Old November 30th, 2002, 05:05 AM
Lindset Lindset is offline
weirdomoderator
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Location: Alta, Norway
Posts: 370 Lindset User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to Lindset Send a message via AIM to Lindset
fputs and fwrite are identical.. fputs is just an alias for fwrite
__________________
Best Regards,
Håvard Lindset

Reply With Quote
  #10  
Old November 30th, 2002, 10:27 AM
Spathe Spathe is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 7 Spathe User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally posted by Lindset
fputs and fwrite are identical.. fputs is just an alias for fwrite


Are you sure ?

Pick up the doc :

int fwrite ( int fp, string string [, int length])
...
Note: On systems which differentiate between binary and text files (i.e. Windows) the file must be opened with 'b' included in fopen() mode parameter.

Oh, nice thing to do

Reply With Quote
  #11  
Old November 30th, 2002, 10:48 AM
Lindset Lindset is offline
weirdomoderator
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Location: Alta, Norway
Posts: 370 Lindset User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to Lindset Send a message via AIM to Lindset
Quote:
Originally posted by Spathe


Are you sure ?

Pick up the doc :

int fwrite ( int fp, string string [, int length])
...
Note: On systems which differentiate between binary and text files (i.e. Windows) the file must be opened with 'b' included in fopen() mode parameter.

Oh, nice thing to do


That doesn't disprove that fputs and fwrite is identical. I can use the manual too:
Quote:
fputs() is an alias to fwrite(), and is identical in every way. Note that the length parameter is optional and if not specified the entire string will be written.

Reply With Quote
  #12  
Old November 30th, 2002, 04:17 PM
Spathe Spathe is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 7 Spathe User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Ok ok, but for Attila, he should open his file in binary mode for precaution and he shouldn't include his file first.

Reply With Quote
  #13  
Old November 30th, 2002, 05:27 PM
Attila Attila is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 67