oop vs function
Posted: Thu May 17, 2007 1:53 pm
feyd | Please use
---------------------------------
2- insertdata.php
------------------------------------------
3- index.php
---------------------------
i have 2 question please :
1- is it a good way ?
2- how could i use object oriented instead of functions ( i read object oriented but i want an example ) or any helpfull thing ?
thanks alot and i wait answer
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
hi all,
if you please help me
i use functions to deal with mysql and every file contain one function
when i want to do function i recall it from its file like next :
---------
1- config.phpCode: Select all
<?
$dbname='any';
$dbhost='localhost';
$dbuser='any';
$dbpw='any';
?>2- insertdata.php
Code: Select all
<?
include('config.php');
?>
<?
function tellusss(){
global $ipt,$datetimet,$dbhost,$dbuser,$dbpw,$dbname,$namet,$emailt,$subjectt,$messaget;
$link=mysql_connect($dbhost, $dbuser, $dbpw) or die(mysql_error());
mysql_select_db($dbname) or die(mysql_error());
$result = mysql_query("INSERT INTO tellus (ipt,datetimet,namet,emailt,subjectt,messaget)
VALUES ('$ipt','$datetimet','$namet','$emailt','$subjectt','$messaget')",$link);
if (!$result) {
die('Invalid query: ' . mysql_error());
}
}
?>3- index.php
Code: Select all
<?
include('config.php');
include('insertdata.php');
?>
<?
tellusss();
?>i have 2 question please :
1- is it a good way ?
2- how could i use object oriented instead of functions ( i read object oriented but i want an example ) or any helpfull thing ?
thanks alot and i wait answer
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
[quote="[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1"][b]3.[/b] Do not make multiple, identical posts. This is viewed as spam and will be deleted.[/quote]