How to declare these functions?

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
User avatar
Lucnet
Forum Commoner
Posts: 61
Joined: Sat Jun 26, 2004 5:28 pm
Location: Alabama
Contact:

How to declare these functions?

Post by Lucnet »

I am wanting to add some functions like $url_maindir, $url_dir, $COMPANY_email and $COMPANY_name.

Example of my config file below, the info in general information is what I want you to look at. The rest I am going to try to get to work later:

Code: Select all

<?
//                               *HOST*   *link_display* *Password*                        *Database*
function db() {mysql_pconnect("localhost","lsscript","tv781212");mysql_selectdb("lsscript_lstestimonials");
}

function db_close() {
	mysql_close();
}
/*
        //Bellow will be used for LS Testimonials Version 2.0
		//-----------------------
        // Database config
        //-----------------------

        // The server your databse is on. This is usually localhost
        $DB_host = "localhost";

        // The username used to access your database
        $DB_user = "";

        // The password used for this username
        $DB_pass = "";

        // The name of the database LS Testimonials is installed on
        $DB_name = "";

        // If you want to add a prefix to the table names. Otherwise
        // leave blank
        $DB_prefix = "lst_";

        // If your database runs under a persistant connection.
        // Note leave this as 0 unless you know what you are doing.
        $DB_pconnect = 0;
*/


        //----------------------
        // General config
        //----------------------

        // The full URL to the directory LS Testimonials is in.
        // Make sure you do not include a trailing slash '/'
        
        $URL_maindir = "//www.lsscripts.com/lst";

        // The directory that the files are located in. Make sure
        // you include a / at the beginning and end of the
        // directory name. If it is in a sub domain just use one /
        $URL_dir = "/lst/";

        // This path is the full server path to your LS Testimonials
        // directory (excluding the trailing slash '/'). If you are using
        // a *nix server you can use $_SERVER["DOCUMENT_ROOT"] to get to
        // your web directory but Windows does not seem to recognise this
        // function.
        $LST_path = $_SERVER["DOCUMENT_ROOT"]."/lst";



        // The name of your company. This will appear in the
        // title of any visable pages.
        $COMPANY_name = "LS Testimonials";

        // The admin email of your company. This e-mail address
        // will be used in all automatic e-mails that are sent
        // from LS Testimonials
        $COMPANY_email = "admin@example.com";


/*
        // The skin you want to use
        $SKIN_name = "default";

        // The language that will be used for the client side. Use the name
        // of the language file. e.g. if you are using spanishlang.php, in
        // the language setting put spannishlang
        $LANG_setting = "english";
		
		 // To check for updates on the control panel homepage, set to true,
        // otherwise set to false. Setting this to true will enable LS Testimonials
        // to collect information about your website (which will not be distributed
        // to third parties) in order to produce usage statistics etc.
        // None of the information collected will be used in any unlawful ways.
        $lst_update = "true";
*/
?>
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

Code: Select all

function name($paramaters){
   //code here
}
User avatar
Lucnet
Forum Commoner
Posts: 61
Joined: Sat Jun 26, 2004 5:28 pm
Location: Alabama
Contact:

Post by Lucnet »

Ok so lets say I am tring to get the company name to show it a title. The file I want it show on will be located in http://mydomain.com/lst/add.php and the config.php is located in http://mydomain.com/lst/inc/config.php How would I right this in the title of the add.php.

Below is the code for the add.php file:

Code: Select all

<?
include "inc/config.php";
switch ($action) {
	case "store":
		db();
                            $link_display=$HTTP_POST_VARS['link_display'];
		mysql_query("INSERT INTO ls_testimonials SET client_id='$client_id', link_display='$link_display', company='$company', email='$email', testimonials='$testimonials'");
		db_close();
		$pagecontent.="<HTML><BODY><b>Thanks for your Testimonial. You will receive an email once it is approved. It will be viewable at
		<br><a href='../testimonials/index.php'>LS Testimonial Viewer</a> once you receive the email.</b></BODY></HTML>";
	break;
	default:
	break;
}
$pagecontent.="<table width=760 border=0 cellspacing=0 cellpadding=0>
  <tr>
    <td align=center>
<table width=500 border=1 cellpadding=2 cellspacing=3 bordercolor=#000000 bgcolor=#CCCCCC>
  <tr bordercolor=#CCCCCC> 
    <td width=27%><font size=2><strong>Client ID# :</strong></font></td>
    <td width=73%><form method=post><input name=client_id> (only numbers)</td>
  </tr>
  <tr bordercolor=#CCCCCC> 
    <td><font size=2><strong>Displayed Link :</strong></font></td>
    <td> <input name=link_display> (displayed over website link)</td>
  </tr>
  <tr bordercolor=#CCCCCC> 
    <td><font size=2><strong>Website :</strong></font></td>
    <td> <input name=company value=http://> (company website)</td>
  </tr>
  <tr bordercolor=#CCCCCC> 
    <td><font size=2><strong>Email :</strong></font></td>
    <td> <input name=email> (must be valid e-mail)</td>
  </tr>
  <tr bordercolor=#CCCCCC> 
    <td><font size=2><strong>Testimonial :</strong></font></td>
    <td> <textarea name=testimonials rows=7 cols=40></textarea></td>
  </tr>
  <tr bordercolor=#CCCCCC>
    <td>&nbsp;</td>
    <td><input type=hidden name=action value=store>
  <input type=submit value='Submit'></td>
  </tr>
</table>
</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><!-- DO NOT REMOVE THIS CODE BELOW -->
<center>
        <font size=2>Powered by: <a href=http://www.lsscripts.com>LS Testimonials</a></font>
</center>
<!-- COPYRIGHT CODES END --></td>
  </tr>
</table>";
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>{.$COMPANY_name.}</title><br><br>
<br><br>
<?=$pagecontent;?>
<br><br><br><br>	
</BODY>
</HTML>
User avatar
mikusan
Forum Contributor
Posts: 247
Joined: Thu May 01, 2003 1:48 pm

Post by mikusan »

Code: Select all

&lt;title&gt;&#123;.$COMPANY_name.&#125;&lt;/title&gt;&lt;br&gt;&lt;br&gt;
to this:

Code: Select all

<title><?php echo $COMPANY_name ?> </title><br><br>
User avatar
mikusan
Forum Contributor
Posts: 247
Joined: Thu May 01, 2003 1:48 pm

Post by mikusan »

Lucnet.... You honestly need to look take a look at the manual and understand how PHP works. You are trying to edit someone else's code it seems but not understanding what it is doing.

I don't mind answering your questions. But if you learn the basics you will not need to show 100 lines of code... and there will not be multiple syntax problems...

Read up on standard usage, how to include files, functions and variables. And good form... then tackle harder stuff...

It's a corny suggestion i know, but you need to take the time and get it first.
Post Reply