Function Problem

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
Mastermind
Forum Commoner
Posts: 36
Joined: Thu Mar 10, 2005 2:38 am
Location: CDO,Philippines
Contact:

Function Problem

Post by Mastermind »

twigletmac | 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]


Dear Friends :

I have a problem i want to create a function automatically add, save ,edit, delete, and to view in mysql database but the problem is there is no result i found in my program 

Here is my code:

Code: Select all

<?php
class person(){
var $Index,$Username,$Password,$Administrator,$Type of Person,$FirstName,$tussenvoegsel,$Lastname,$Private address,$Postal Code,$City,$Phone private,$Mobile,$Company Name,$Company address,$Postal code company,$City company,$keywords,$Picture;
function getAllPersons(){
//returns an array with all persons records that we have 
}
function getSelectedPersons($field,$value){
}
function updatePerson(){

$query="UPDATE personstable fields(name, password) values(this->name, this-.password)";
execute_query($query);
}
function saveNewPerson(){

}
}
class meeting(){
var $index,$title,$date,$typeofmeeting,$Location short,$Speaker,$Introduction,$SpeakerBio,$Agenda,$Venue,$Confirmationtext;
function getAllMeetings(){
}
function getSelectedMeetings($fields,$value){
}
function updateMeeting($key){
}
function SaveNewMeetings(){
}
function registerforMeeting(){
}
function SendNewMeeting($E-mailAddress){
}
function sendReminderEmail($person){
}
}
class attendance(){
var $Index,$Name,$Members,$Member Number,$Phone,$Phone Mobile,$E-mail Address;
function register($person){
}
function getRegistration($meetingkey){
}
function getNonRegistered(){
}
}//end class registrationForMeeting


?>

can you help me if theres something wrong in my code.

Thank you.

twigletmac | 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]
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

$query="UPDATE personstable fields(name, password) values(this->name, this-.password)";
should be

Code: Select all

$query="UPDATE personstable fields(name, password) values('{$this->name}', '{$this->password}')";
User avatar
Mordred
DevNet Resident
Posts: 1579
Joined: Sun Sep 03, 2006 5:19 am
Location: Sofia, Bulgaria

Post by Mordred »

... not to mention that variables like

Code: Select all

$Type of Person
are not valid in php, even the forum highlighting should help you here.

Proper syntax is essential both in PHP and English, there is error_reporting(E_ALL) for the first and punctuation for the second ;)

Reading a bit of (My)SQL will help too - UPDATE with no WHERE clause usually leads to sharp heart pains and cold fingers ;)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Mordred wrote:... not to mention that variables like

Code: Select all

$Type of Person
are not valid in php, even the forum highlighting should help you here.

Proper syntax is essential both in PHP and English, there is error_reporting(E_ALL) for the first and punctuation for the second ;)

Reading a bit of (My)SQL will help too - UPDATE with no WHERE clause usually leads to sharp heart pains and cold fingers ;)
Surprise! It's possible, using variable variables.

Code: Select all

[feyd@home]>php -r "$vars = get_defined_vars(); $varname = 'I\'m a var'; $$varname = '2'; ${'I\'m another var'} = 'hi'; $vars2 = get_defined_vars(); $diff = array_diff($vars2, $vars); var_dump($diff);"
array(3) {
  ["varname"]=>
  string(9) "I'm a var"
  ["I'm a var"]=>
  string(1) "2"
  ["I'm another var"]=>
  string(2) "hi"
}
User avatar
Mordred
DevNet Resident
Posts: 1579
Joined: Sun Sep 03, 2006 5:19 am
Location: Sofia, Bulgaria

Post by Mordred »

Hehe, that's cool, although I think it's still better to use $TypeOfPerson instead of ${'Type of Person'} :)
It's funny how many syntax tricks like this exist in PHP ;)

Code: Select all

$ångström = 4; echo $ångström;
(this is Angstrom, with proper Norwegian diacritics but is not rendered well in this encoding)
Post Reply