Page 1 of 1

Function Problem

Posted: Mon Sep 04, 2006 12:18 am
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]

Posted: Mon Sep 04, 2006 4:56 am
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}')";

Posted: Mon Sep 04, 2006 5:52 am
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 ;)

Posted: Mon Sep 04, 2006 8:32 am
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"
}

Posted: Mon Sep 04, 2006 11:28 am
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)