Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Form Objects: How Refer To Them?


I have a form populated from the DB. The form additionally has input fields and a submit button.

How do I refer to the objects of the form, e.g. price, that are not the input or the submit? I want to put them into a SESSION variable to populate the cart.

I have tried using "object" notation, but I can't seem to refer to the object items using POST Code:




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
PHPClass Form Objects?
Are there any PHPClass scripts that provide us with a different look &
feel for web page controls such as buttons, text boxes, dropdown
lists, etc.?

Passing Objects Form One Page To Another
Is it possible to transfer objects derived from a class form one page to
another?

I made 2 testscripts:

person.php
-------------------------------------
<?php

class person {

private $_name;

public function setName($name) {

$this->_name = $name;

}

public function getName() {

return $this->_name;

}

}

$p = new person();

$p->setName("Jim");

$safep = urlencode(serialize($p));

header("Location:person2.php?data=".$safep);

exit;

?>

person2.php
---------------------------------
<?php

class person {

private $_name;

public function setName($name) {

$this->_name = $name;

}

public function getName() {

return $this->_name;

}

}

$x = unserialize(urldecode($_GET['data']));

echo $x->getName();

?>

But this does not work for me....

Displaying Variables In Form Objects
I'm trying to display information within a lookup box and a text area box. Here's the code for the form objects:

<TEXTAREA NAME="BodyText" CLASS="InputTxtBoxes" MAXLENGTH="10000" COLS="100" ROWS="20" VALUE="<?php echo $BodyText ?>"></TEXTAREA>

<SELECT NAME="AuthorName" CLASS="InputTxtBoxes"><OPTION VALUE="<?php echo $AuthorName ?>"></OPTION>

When I print these variables out they do contain the correct values, but when I try and display them within these form objects they don't work at all. The BodyText is stored in a blob in the database and usually contains relatively large amounts of data (300 - 500 words). Any ideas?

Ccbill (generate The Refer)
I am creating a site, in where it exists to banner that must have the following Link http://refer.ccbill.com/cgi-bin/cli...ww.domain.com/,

but the PA=YYYYYY must be generated by the url of the page .

http://sub.domain.com/index.php?id=YYYYYY or,

http://sub.domain.com/index.php?ccbill=YYYYYY

i do need a database constructed ?
how do i generate the refer on the banner when i type the ccbill on the url on the navigator ?

Problems With Refer Script
I've been trying to setup Dean Allen's excellent "Refer" script.

The instructions say to add this code to the bottom of whatever web pages
you want the refer script to track (after the closing </html> tag):

<?php include '<?php echo dirname($_SERVER['SCRIPT_FILENAME']) ?>/refer.php'
?>

Doing so results in the following error on any pages that have the
aforementioned code:

Parse error: parse error in /home/username/public_html/page.php on line 63

The offending line is always the line with the aforementioned PHP code. Does
anyone have any idea what might be causing this not to work? I installed the
refer script into the /refer directory in the web root of my server.

Using Database Objects Within Other Objects. Inefficient?
I've defined a Database class with methods to call mysql_query(), etc. The connect() method makes a persistent connection. I've also defined a Member class to hold functions and data for users. PHP Code:

Refer To A File Outside The Website Tree For Downloading Purposes
I'm using Linux Redhat 8.0 (LAMP).
I have a file tx.zip , that is placed in /tmp.
Now I want people to be able to download this file without copying it to
the website tree
Can I make a reference like http://www.website.com/../../../tmp/tx.zip
if the root of my website is /var/www/html/Vwebsite ?
Due to restrictions, I cannot copy the file to /var/www/html/Vwebsite

Please Explain Or Refer: $string = Isset($xyz) ? $xyz : "something Else";
"$string = isset($xyz) ? $xyz : "something else";"

inference) what it does, but have not found any documentation on this
type of syntax.


Any one have links to this shortuct(?) syntax and other types of
syntax?

How Can I Refer From One Variable To Hidden Variable?
I have started my php source code shown below

---------------------------------------------------------
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1"))
{....

How To Refer From One Variable To Hidden Variable?
I have started with my php source code shown below, and how can I
refer from one var to hidden var?

----------------------------------------------------------------------------
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1"))
{
$insertSQL = sprintf("INSERT INTO users (UserID, UserName, Password)
VALUES (%s, %s, %s)",
GetSQLValueString($_POST['UserID'], "int"),
GetSQLValueString($_POST['UserName'], "text"),
GetSQLValueString($_POST['Password'], "text"));

mysql_select_db($database_SHHConnection, $SHHConnection);
$Result1 = mysql_query($insertSQL, $SHHConnection) or
die(mysql_error());
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1"))
{
$insertSQL = sprintf("INSERT INTO holidaymaker (HMID, Name, Status)
VALUES (%s, %s, %s)",

GetSQLValueString($_POST['HMID'], "int"),
GetSQLValueString($_POST['Name'], "text"),
GetSQLValueString($_POST['Status'], "text"));

mysql_select_db($database_SHHConnection, $SHHConnection);
$Result1 = mysql_query($insertSQL, $SHHConnection) or
die(mysql_error());
}

<input type="hidden" name="UserID" value="">
<input type="hidden" name="HMID" value= "">

----------------------------------------------------------------------------

The "UserID" is generated by MySql with auto_increment.[color=blue]
>UserID int(4) auto_increment primary key,[/color]

Assume that I want to add new user and the value for UserID is 5
(after auto increment). Then, I want HMID refer to UserID, the value
of HMID is also 5,
thats mean HMID = UserID, how can I do that? What is the command?

COM Objects
I'm trying to use MSCOMM32.OCX, but I got an error "Fatal error:
Uncaught exception 'com_exception' wih message 'Failed to create COM
object 'MSComm32.OCX' : Incorrect syntax'

The OCX is present on the system and I could succesfully use it
through visual basic.

PHP Objects
How PHP objects are passed from one page to other.

How Can Two Objects
Problem: pointers (like in C and C++) do not exist in PHP. How can you create two objects which point to eachother? I tried using references, but it seemed not to work. Does anybody know a solution?

Php 5 Objects
I created a php class in charge of doing mysql queries and when this query is called it returns an object of the type "myddl_result", this second object is passed the resource of type mysql_result and if i debug the whole thing i seems allright until the __construct is complete, after that, the __destruct is called for i don't know which reason and the rest is executed normally.

At that point my resource is of type unknown and can't be used anymore... I really need help on that please... i don't understand whats happening even after reading the php website 2x about php 5 objects. PHP Code:

Objects In PHP
Im using objects in PHP for the first time and have a question about
the following script.

$new_grad = new graduate();
$new_grad->set_fn($_SESSION['first_name']);
$new_grad->set_sn($_SESSION['surname']);
$new_grad->set_username($_SESSION['username']);
$new_grad->set_password($_SESSION['password']);
//etc

The sript is used to set up user accounts when they sign up for my
system.
HOWEVER I am concerned about the following scenario. Say if two or
more users are setting up accounts at roughly the same time.
The first person presses 'submit' so

$new_grad = new graduate();

Php And C++ Objects
i wanted to know whether it is possible to instantiate c++ class
objects and use them in php code ? can anyone pleez point out to some
docs on the net which refers to this particular problem ?


Accessing COM Objects
I am trying to access another windows application using php/COM, and it works great for single string values, but when retrieving a list of "Devices", it returns an object, and I am not sure how to deal with this in php. In ASP, this is how you would access the data: Code

Referencing Objects?
Fairly new to OOP and PHP5.

My question;

Maybe I am not thinking about this the right way? How do I reference a
variable or object(?) from one function to another in a class? Or how
do I pass the variable from one function or method to another? Am I
doing this right in the example below? How would I pass a variable from
one function to another?

Example .....

Recursivity With Objects
I am trying to do a script that is must print a tree of object (my
objects are some comments).

For more details, a "comment" is an object which can be at the top of
the tree (father), or which can be an answer to another comment
(children). There is no limit in father-children relation (a father can
have children, which can have children, which ...).

I have made 2 object, the comment and a comment contener (just an
array). Un comment is simply composed with a texte and an id.

Here is the code and my test failure....

How To Get The Names Of All Sub Objects?
My example:

$person->telnumber->value
$person->faxnumber->value
$person->???

The names of the objects "telnumber" and "faxnumber" (and further
possible subobjects) are not known for me.

How can I get the names of all subobjects of an object?

Extract() And Objects
Is it possible to use extract on an array of objects so that the objects
are available in the local variable space?

Php Using Javascript Objects
I want to initialize a TEXTAREA with text depending on the values
already selected in other areas - input type=TEXT or SELECT.

How can I set a PHP variable with a value retrieving those HTML object
values?

Array_keys With Objects
I have a gallery object which contains an array of image objects. I
would like the image objects to be able to return their adjacent
siblings in the array so that, for example,
$gallery->images[3]->nextImage() would return $gallery->images[4]. The
images each contain a reference to their parent (i.e. the gallery
object) so I tried using array_keys(). This is a method of the image class:

function nextImage() {
$pos = array_keys($this->parent->images, $this);
return $this->parent->images[$pos[0]+1];
}

The array_keys call *should* find the current object ($this) in the
array and return an array containing a single value which is the index
of the current image in the images. But instead I get "Fatal error:
Nesting level too deep - recursive dependency?"

I suppose this has something to do with the cyclic references. Can
anyone suggest a way around this or any other way for an image to access
it's siblings?

NEW: XML Application Objects
I've just released the first distribution for an open-source project
called XML Application Objects (XAO). It's the result of working with
XML/XSLT in PHP for a couple of years now. Although this is an alpha
release, the concept itself has gone through a lot of refinement and is
now ready for prime time.

The publication of the project itself was partially motivated by the
discussions that took place in this thread (A Complete List of PHP
Template Engines?) which basically sees me arguing for the usage of
standards (XSLT) rather than having to learn a proprietary new
templating system every time you work on someone elses PHP app.

This project is the result of much blood, sweat, and tears so I hope
someone out there finds it useful. I have made documentation a paramount
considderation for the XAO API because I'm keen for it to be another PHP
success story. The website has a tonne of information so I'm not gonna
try and promote XAO in this message.

Sessions And Objects
I am using sessions to pass the main object from one page to another in a shopping cart script. The main object is $cart PHP Code:

Global Objects?
how to declare an object globally? So I can use it inside other objects?

Refactor Objects
Do we know anyone else who writes PHP code? There is too much work to
do, especially if Costin and I are going to join our software
together.

The easiest way for us to join our software together is through high
level wrapper classes that take other classes for arguments. Costin
and I could move toward joining the software one package at a time.

I've currently got a big SQL class and a big Form class. Both need to
be refactored into smaller objects. Doing so would allow more code
reuse and also make things more modular, flexible, and stable. The
uppermost class could be preserved as a command class. We could follow
the Command Design Pattern, and then Costin and I could use just those
commands, which would have differnt meanings in our code, depending
what object we give the command class.

Forms, database connectivity, etc, one slow step at a time we could
join our code.

I think Costin has a security class that could be refactored and used
for both pieces of software. Again, the right way to do it is to turn
the top level class a wrapper for lowever level commands.

I'd also like to make a separate piece of software that gets info from
the data store and returns it as a 2 dimensional array as a SOAP XML
stream. Costin and I could both come to rely on it, and our own
software wouldn't have to worry about it. The nice thing is the data
fetching software would then be truly agnostic about where the data
was, given the right module it would fetch it out of anywhere -
database, flat files, hash tables, multiple XML files.

But I need help. I need some other person who knows a little PHP and
has some time and feels like helping out. Someone who wouldn't mind
refactoring the classes. If we could find such a person, they could
refactor my code and Costins and in the process intergrate Costin's
code and mine.

Objects And Queries
I have tried to join 4 tables with a SQL line and fetch the data as a object while($edit = mysql_fetch_object($result)) My problem is this, I need to lable a object somthing like this $edit->products.id but it doesn't seem to work very well the printed result is .id any suggestions?

Freeing Objects
Let's say that I've the following code (pseudo code cause this is a
question about how php gc works)

file class.php
------------------
class ClassX {
//var $F_strDB;
others vars here

function DoWathEverDBJob(){
connectToDB (using class variables as $F_strDB)
queryDB
process results
(# 1)
return (true-false, not an array nor a result set)
}

} //class

file test.php
------------------
$classX = new ClassX;
$classX ->DoWathEverDBJob();
(# 2)

Questions

-Should I have to call mysql_free_result in (# 1)

-Should I have to "destroy" $classX in any way in (# 2)

I used to think that objects and queys would be destroyed
automatically, but i'm not sure right now...

Sessions And Objects
I'm currently building an object-oriented shopping cart with PHP 4.3.2 and
MySQL 4.0.14.

I am looking at storing a Cart object within a PHP session, however I am not
completely sure on the best way to achieve this. I have read up and there
seems to be varying advice. Should I need to serialise and unserialise the
object or is this automatic and should I be using session_register()? For
reference, register_globals is off.

Arrays Of Objects
I'm having considerable trouble finding the proper syntax for accessing
a specific element from an object which is in an array. Here is my
pertinent code snippet:

$courses = array(); // define empty array
while(($row = mysql_fetch_object($result))) {
array_push($courses,$row); // push row object onto the array
}
echo "<p>$courses[0]->name</p>
"; // access first object's name

This does not give me the string I want, which is name of the first
course in the array. I verified $courses[0] is an object. One of the
members of the object is 'name'. How do I access the name of the first
course?

I tried:
$courses[0]->name
${courses[0]}->name
$courses[0]['name']
${courses[0]->name}

Create Php Objects From Xml
What i want to do
is create objects from an XML file.
basically my tags are all object elements or attribute values ie each
indent is a new object. the classes for these objects are already
written, just the objects need to be created
eg

<object1>
<value1>23</value1>
<value2>hello</value1>
<object2>
<value3>test1</value3>
<value4>23</value4>
<object3>
<value1>100</value1>
<object3>
</object2>
<object2>
<value3>test3</value3>
<value5>50</value5>
</object2>
</object1>

i have classes for object1,2,3 that have definitions for the various
types that they will have.

what this should return (create) is an object of type object1. in this
there is an array of 2 objects of type object2 along with attributes
of type value1 and value2 with their values.

the first instance of object2 also has a instance of object3 which
has an attribute of type value 1 which equals 23

i have looked at all the exparsing, but it is more for viewing, and i
cant get them adaptd

basically just need something that can break the file down into its
indenting. there are only 3 objects deep in the xml before we reach
nodes with no children.

Adding Objects
I would like to know how i can add the following function calls together to produce one.

      $encounterone=&$lab_obj->searchEncounterLabResults($keyword,$pagen->MaxCount(),$pgx,$oitem,$odir);
      $encountertwo=&$labs_obj->searchEncounterLabResults2($keyword,$pagen->MaxCount(),$pgx,$oitem,$odir);

How can I add these two to get one output.-- $encounter

which i can use here

while($zeile=$encounter->FetchRow()){

display script
}

Comparing Objects
I've got an array of objects that are instantiated based on an ID, but it's possible that multiple objects of the same ID may be added to an array.  I've tried using array_unique to get rid of duplicates, but if the object contains a null data field, it throws some error messages.

How do I get PHP to compare objects by a certain field rather than every variable (null or set) declared in an object?

Objects - Inheritance - OVERLOAD!!!!!!
Does anyone know offhand if it is possible to call the parent class' overloaded function from the child....

....i.e. if I have a class called A with a member function xyz(), and then define a class B which inherits from A... and redefine the function xyz() in B.... then is it possible for B->xyz() to call A->xyz() from within itself?

Why? Well I want to 'add' to the funcionality of a base class. the base class returns a string, and my child class wants to take the parent string and add bits to it.

Is it just a case of calling xyz() from B ? Won't that just cause reccursion on itself? I need something like baseclass->xyz().

Passing Objects Between Pages
I'm using an object to cart stuff around with me on several html pages, or at least i'm trying to. It must be simple but I can't for the life of me work out how to to pass it round.

I've tried adding it to a href address like a standard variable, but then what does it equal?

Insert Objects Into MySQL ?
I'd like to know if there is a way to insert any object into a mysql-database.PHP Code:

Accessing Objects In Arrays
Is it possible to access the properties of an object when it is stored inside an array?

sort of like this...
echo array[object->property]...

Objects, Arrays, And Loops
I'm working on an auto-schedular for my college's Music Festivals. I just started on this tonight. I'm starting by reading all the information into variables. For starters, I have a School class. The script should read data from the database into School objects for later use. I've never used objects in PHP before, but I've used them in several other languages. I read data from the database into the School objects using a loop, with a loop invariant
called $schoolCount. I created a print statement so that I could see
if the data was being correctly assigned to the School objects, but I
think it's printing the value of the loop invariant instead of the
school name like I want. I'm not sure why. Here's my code:

Problem With Array Of Objects
I have a small problem with array and objects:

$a = new A();
$b = new A();
$c = new A();
$d = new A();
$e = new A();

$ar = array($a, $c, $d);

There is a method inside A, which would need the information, that is
that instance ($this) of A a member of array $ar.

I thought, that this could have been tested easily with

if (in_array($this, $ar)) ...

But it is not working.

Is there any easy solution for this?

Classes And Objects - Please Explain
PHP is my first serious programming language (have some exp w/
javascript), so this notion of classes and objects confuses me. What's
a good way for me to understand this?

Multiple Mysql Objects
I have a system which needs to connect to two separate databases. I've created a class to handle my database connections but one thing i've ran into is that calling a second instance of a class will overwrite my previous database connection. Example.

My 2 databases have tables titled orders. Database A has 20 orders and Database B has 40. I call my mysql objects.

$mysqlObjA = new mysql($sqlhost,$sqluser,$sqlpass,$dbA);
$mysqlObjB = new mysql($sqlhostB,$sqluserB,$sqlpassB,$dbB);

then i execute my queries. Code:

Confusion About Classes And Objects
Using PHP 4.4.4, I have a class defined like so

class CUserItem {
var $m_id;
var $m_children_arr;
function CUserTOCItem($p_id)
{
$this->m_id = $p_id;
$this->m_children_arr = array();
} // CUserItem
function addChild($p_child) {
array_push($this->m_children_arr, $p_child);
} // addChild
function numChildren() {
return count($this->m_children_arr);
} // numChildren
} // CUserItem

then in a separate bit of code, I have an associative array of
objects, with the key being the id and the value being the object.
Unfortunately, when I try and manipulate the objects in the array, it
doesn't take ...

$item = new CUserItem(1);
$item2 = new CUserItem(2);
$toc_items_arr[1] = $item;
$item->addChild($item2);
print $toc_items_arr[1]-

Quote:

Sorting Array Of Objects?
I'm reading an XML file using SimpleXML and xpath into an array. What I'd like to do is sort the array based on a specific element's value. For instance, an XML that has some elements like:

<CUST>
<NAME>ABC Co.</NAME>
<LVL>A1</LVL>
<STATE>CA</STATE>
</CUST>
<CUST>
<NAME>ACME</NAME>
<LVL>A2</LVL>
<STATE>CA</STATE>
</CUST>

is read into an array. Because I'm using SimpleXML, the array elements are each SimpleXML objects. I want to then sort the array based on the value of the LVL element (i.e. A1's, then A2's, etc.). Every item in the array will contain this element. Is this possible?

Array Of Objects Problem
I'm having problems calling methods inside an array of objects. It
seems that I can't understand very well how "&" works

The code which follows, prints out

ClsSet Constructor
El nombre del objeto es:
El nombre del objeto es:
El nombre del objeto es:

whereas I expected

ClsSet Constructor
El nombre del objeto es: cls1
El nombre del objeto es: cls2
El nombre del objeto es: cls3

Where i'm wrong?

class ClsX{
var $F_name;

function ClsX($name){
$this->Fname = $name;
}
function GetName(){
return $this->F_name;
}
}//class

class ClsSet{
//comentarios de clase;
var $F_array_of_obj = array();

function ClsSet(){
echo "ClsSet Constructor<br>";
}
function AddObj(&$obj){
$this->F_array_of_obj[] =& $obj;
}

function Names(&$obj){
//print_r($this->F_array_of_obj);
for ($i = 0; $i <= (count($this->F_array_of_obj)-1); $i++){
//print_r($object);
$object =& $this->F_array_of_obj[$i]; //I've tryied with and
without &
echo "El nombre del objeto es: ".$object->GetName().'<br>' //It
actually doesn't call GetName()
}
}

Question About Php Domelement Objects
When I do a print_r of a domelement object I get something like this:

domelement Object
(
[type] => 1
[tagname] => category
[0] => 6
[1] => 1007543104
)

What are those "0" and "1" internal variables? I can not seem to find any description
of them anywhere. What do they represent? The "0" one seems to stay constant with a
constant xml source. But the "1" one is always different though still unique. Are
these variables a php thing only? Or part of the dom specification that I missed?

Also how do I access them? I can do a "$node->tagname" or "$node->type" just fine to
get access to those internal object variables. But php does not like "$node->0" at all.
What's the problem? Some kinda of variable scoping or something?

Lastly, I don't suppose there is any way to search by these "0" variables with an
xpath_eval statement?

The problem is this: I will be receiving an xml file with all these nested "category"
elements. They only have "name" attributes, which unfortunately, I can not be guaranteed
will be unique. But I still need some unique way to identify them. Short of adding
attributes to each "category" element, I was hoping to use this "0" internal object
variable, or perhaps, the position() function from xpath. But I have no idea how to
determine an elements position when all I have is the domelement object.

Sort An Array Of Objects
I would like to sort an array of objects by a variable of an object variable. I have an array of objects (obj_array). One of the variables of (obj_a) is an object (obj_b). I want to sort by a variable of (obj_b). PHP Code:

Standard Interfaces And Objects? (Where Are They?)
I was wondering if there is a list some place of the standard interfaces
that are internal to PHP.

Specifically, I was looking for the docs on Iterators.

Is there a URL (or good search terms) one can use to find a list
of them?



Log, Logging, Objects And Arrays ?
On one of the Dev newsgroups mailing.? I had seen some comments,
regarding the inability (currently) of PHP to write to a string, as
opposed to direct output from Function like
print_r()
var_dump()

I'm a bit of a newbie, PHP serialization, but recognize Java has
Object.toString method. Anything similar, here in PHP ??

I'm looking to build an complete Enterprise Logging System, to use in
debugging, just in-case - haha - I made a typo, during these last 2
months of coding. (I don't expect anything wrong.)
its a joke ....



Copyright © 2005-08 www.BigResource.com, All rights reserved