PHP - Where Do I Find The Class Objects That Can Be Used With An Update Command?
I am a bit rusty with mySQL and I tried to borrow some other query code and modify it into an update command...apparently I am trying to use an invalid property in my error checking.
Basically I just want to check and see if there were NO rows updated so I can let the user no that nothing was changed. There are probably easier ways to do this? The page where I set the variable values is based on a form post. I am not sure how to write my validation tests. Right now it is running the update successfully but it is reporting back an error based on hitting the "else if" test where I am trying to see if no rows were updated. The error message is: Quote Encountered error: 8 in /home/omgma/public_html/member_community/mbr_profiles/mbr_profile_updt_post.php, line 85: Trying to get property of non-object No fields were updated! Error: 0 Code: [Select] //create a SQL statement $updt_cmd = "UPDATE users t1, directory t2 " ."SET t1.email = '$email', " ."t2.first_name='$first_name', " ."t2.last_name='$last_name', " ."t2.suffix='$suffix', " ."t2.website_url='$website_url' " ."WHERE t1.username ='$username' AND t2.directory_id = t1.directory_id"; $conn = db_connect(); $result = $conn->query($updt_cmd); if (!$result) {//could not execute query throw new Exception('<h2>Could not execute member profile update!</h2><p>Error: ' .mysqli_errno($conn) .mysqli_error($conn) .'</p>' ); } else if ($result->num_rows==0) {// no rows so nothing was updated. throw new Exception('<h2>No fields were updated! </h2><p>Error: ' .mysqli_errno($conn) .mysqli_error($conn) .'</p>' ); } else { $mbr_profile = $result->fetch_object(); print_r($mbr_profile); return $mbr_profile; } Am I using the right functions here to do this and if so where can I find the class properties to use to test if nothing was updated? Thanks Similar TutorialsThis is probably an easy one, but I can't figure it out and it's pretty much not searchable. on a linux-machine i have installed filezilla the filezilla runs pretty well and all is ok. now i need to have the passwd that i have stored years ago. The passprhase is stored in a plain in a file called sitemanager.xmlfile I want to find that file and open it with a terminal command. find . -name *.sitemanagerwell i thought that this will return the file I'm looking for. Now how do I open it automatically, without typing the name? find . -name *sitemanager.xm | openThis doesn't work. It says it doesn't found the open command. question: why it does not work on opensuse? should i use any other command - eg the following: find . -name *xyz | xargs openor find . -name *sitemanager.xml | xargs openor find . -name *.xyz -exec open {} \;and find . -name *.xyz -exec open {} \; .any and all help will be greatly appreciate again: what is wanted and needet is to find out the passphrase in the filezilla-configuration Hi all, I need to create a button my page that when clicked will update my mysql table. I also need a command that will find 3 'x' values and update them accordingly, It needs to update the theme column in my model pictures table, Would something similiar like this work? Code: [Select] UPDATE theme SET name = '5' WHERE name = '1 or 2 or 4';[code] Does this make sense? Hello people, At the moment I am really desperate. I've done this script over 20 times now, always with the same script but all of a suddon, it doesn't work anymore. heres the problem: I made a very simple "patient database" for a doctor. Where he can upload patients, alter and delete them. The script to add the patients works fine. now im trying to make a script where he can alter the variables agian, using the UPDATE command. but instead of updating the variables it cleares all the date in the row. can someone help me? here s the entire code: Code: [Select] <?PHP include'connect.php'; ?> <?PHP $SQL = mysql_query("SELECT * FROM leys_patienten WHERE patientid='".$_REQUEST['patientid']."'"); while ($row = mysql_fetch_array($SQL)) { ?> <?PHP if ($_POST[submit]) { if (!$_POST[volgnummer]) { echo "<font size=\"2\" color=\"#990000\"><b>--> Vul een volgnummer in a.u.b. <--</b></font>"; } elseif (!$_POST[naam]) { echo "<font size=\"2\" color=\"#990000\"><b>--> Vul een naam in a.u.b. <--</b></font>"; } elseif (!$_POST[voornaam]) { echo "<font size=\"2\" color=\"#990000\"><b>--> Vul een voornaam in a.u.b.! <--</b></font>"; } else { mysql_query("UPDATE leys_patienten SET volgnummer='$volgnummer',naam='$naam',voornaam='$voornaam',adres='$adres',postcode='$postcode',plaats='$plaats',telefoon='$telefoon',email='$email',geboortedatum='$geboortedatum',geboorteplaats='$geboorteplaats',opmerkingen='$opmerkingen' WHERE patientid='".$_REQUEST['patientid']."'") or die(mysql_error()); echo "Het patientendossier is succesvol gewijzigd, let op doorschakeling.";?> <meta http-equiv="Refresh" content="1; url=patient.php?patientid=<?PHP echo $row['patientid']?>" /> <? } } ?></p> <form action="<?$PHP_SELF?>" method="post" name="post" id="post"> <table width="805" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td class="table_forms">Volgnummer*</td> <td class="table_forms"><label><input name="volgnummer" type="text" id="volgnummer" value="<?PHP echo $row['volgnummer']?>" size="40" /></label></td> </tr> <tr> <td width="146" class="table_forms">Naam*</td> <td width="659" class="table_forms"><label><input name="naam" type="text" id="naam" value="<?PHP echo $row['naam']?>" size="40" /></label></td> </tr> <tr> <td class="table_forms">Voornaam*</td> <td class="table_forms"><font color="#FFFFFF" size="2"> <label><input name="voornaam" type="text" id="voornaam" value="<?PHP echo $row['voornaam']?>" size="40" /></label> </font></td> </tr> <tr> <td class="table_forms">Adres </td> <td><font color="#FFFFFF" size="2"> <label><input name="adres" type="text" id="adres" value="<?PHP echo $row['adres']?>" size="40" /></label> </font></td> </tr> <tr> <td class="table_forms">Postcode</td> <td><font color="#FFFFFF" size="2"> <label><input name="postcode" type="text" id="postcode" value="<?PHP echo $row['postcode']?>" size="6" /></label> </font></td> </tr> <tr> <td class="table_forms">Plaats</td> <td><font color="#FFFFFF" size="2"> <label><input name="plaats" type="text" id="plaats" value="<?PHP echo $row['plaats']?>" size="40" /></label> </font></td> </tr> <tr> <td class="table_forms">Telefoon</td> <td><font color="#FFFFFF" size="2"> <label><input name="telefoon" type="text" id="telefoon" value="<?PHP echo $row['telefoon']?>" size="40" /></label> </font></td> </tr> <tr> <td class="table_forms">E-mail</td> <td><font color="#FFFFFF" size="2"> <label><input name="email" type="text" id="email" value="<?PHP echo $row['email']?>" size="40" /></label> </font></td> </tr> <tr> <td class="table_forms">Geboortedatum</td> <td><font color="#FFFFFF" size="2"> <label><input name="geboortedatum" type="text" id="geboortedatum" value="<?PHP echo $row['geboortedatum']?>" size="40" /></label> </font></td> </tr> <tr> <td class="table_forms">Geboorteplaats</td> <td><font color="#FFFFFF" size="2"> <label><input name="geboorteplaats" type="text" id="geboorteplaats" value="<?PHP echo $row['geboorteplaats']?>" size="40" /></label> </font></td> </tr> <tr> <td valign="top" class="table_forms">Opmerkingen</td> <td><font color="#FFFFFF" size="2"> <label><textarea name="opmerkingen" cols="40" rows="4" id="opmerkingen"><?PHP echo $row['opmerkingen']?></textarea></label> </font></td> </tr> <tr> <td valign="top" class="table_forms"> </td> <td><span class="body_tekst"> <input type="submit" id="submit" name="submit" value="verstuur" /> </span></td> </tr> </table> <p class="body_tekst"> </p> </form> <? } ?> This is the weirdest thing ever. I've been programming php for years yet I have been pulling my hair out for hours over something that seems so simple! I have a table in my db named last_num_used with 2 fields: id, num which are both type int. It only has one row, so I don't need to use WHERE to update when I execute the command via php: Code: [Select] $sql = "UPDATE last_num SET num='4'"; echo $sql; if (!mysql_query($sql)) {die('Error: ' . mysql_error());}everything works fine and I see the echoed command UPDATE last_num SET num='4' But, when I have a variable $var and try to update it, it will only update properly if $var=1 or $var=2. If $var equals a value greater than 2, then for some reason it updates the column so that num=1. Note the exact problem in example 3 below. Example 1: Code: [Select] $var=1; $sql = "UPDATE last_num SET num='$var'"; echo $sql; if (!mysql_query($sql)) {die('Error: ' . mysql_error());}Result: echoed to screen: UPDATE last_num SET num='1' database updated and num=1 Example 2: Code: [Select] $var=2; $sql = "UPDATE last_num SET num='$var'"; echo $sql; if (!mysql_query($sql)) {die('Error: ' . mysql_error());}Result: echoed to screen: UPDATE last_num SET num='2' database updated and num=2 Example 3: Code: [Select] $var=3; $sql = "UPDATE last_num SET num='$var'"; echo $sql; if (!mysql_query($sql)) {die('Error: ' . mysql_error());}Result: echoed to screen: UPDATE last_num SET num='3' database updated and num=1 I am trying to get a simple thing working. I have a domain with google that I want to change the point to IP when I access a PHP page. I have a DB table with settings that I am using for the username, password, etc. The issue is that the command to change the IP always sends the same IP. No matter what I try. I have tried assigning a fixed entry for the variable $localip, I have set that variable to 0 ahead of the query to get the info from the table. Nothing I do will change the variable in the command. I can manually put the command in a browser and it will perform the change. Can anyone comment on what I am missing here?
<?php ini_set("display_errors", 1); ini_set("track_errors", 1); ini_set("html_errors", 1); error_reporting(E_ALL); require('/var/www/html/cqadmin/utils/connect.php'); $sql = "SELECT * FROM `failover` LIMIT 0, 30"; $result = mysqli_query($link,$sql) or die(mysql_error()); $row = mysqli_fetch_array($result); $localip = ($row['localip']); $dnsusername = ($row['dnsusername']); $dnspassword = ($row['dnspassword']); $domain = ($row['failoverurl']); $location = ($row['location']); $dealer = ($row['dealer']); $output = shell_exec("curl -s https://$dnsusername:$dnspassword@domains.google.com/nic/update?hostname=$domain&myip=$localip"); mysqli_close($link); ?> I get no errors on the page and if I echo $output I get a nochng message back from Google
Thanks for looking!! I think this is what it is called... I having a brain fart... And I don't play with classes that much... Plus I have been playing with trying to get pdf's to output correctly so my brain is toasty.... I'm trying to parse DICOM (medical file format) files and I have this class and I want to setup an array to pull what fields I want. Code: [Select] <?php require '../dicomparser/nanodicom.php'; $filename = 'B4IBG5A0'; // 5) Load simple and print certain value try { //echo "5) Load simple and print certain value\n"; $dicom = Nanodicom::factory($filename); $dicom->parse(); //echo $dicom->profiler_diff('parse').'<br>'; echo 'Patient Name: '.$dicom->value(0x0010, 0x0010).'<br>'; echo 'Operators Name: '.$dicom->value(0x0010, 0x0040).'<br>'; echo 'Patient ID: '.$dicom->value(0x0010,0x0020).'<br>'; unset($dicom); } catch (Nanodicom_Exception $e) { echo 'File failed. '.$e->getMessage()."\n"; } //} ?> So what I want to do is have the array contain 'Patient Name' => '(0x0010, 0x0010)' etc... And have it something like this so I don't have to echo all the lines I want. Code: [Select] foreach ($array as $key => $value) { echo $key': '.$dicom->value.$value.'<br>'; } I can't get it to work... I remember figuring it out once before but that was over a year ago... And I don't have the code I wrote. I know it's something simple stupid. like $$ or [] i'm not getting the combination right. Thanks in advance... I can post some code once I am back at my laptop but for now thinking about this is keeping me awake in bed and all I have handy is my phone. Anyway, I am new to OOPHP. I have a class that I created. I have two objects/instances of it, each using some of the same and some different methods within the class. When I run the page either of the instances works great alone but I get the white screen of death when I try to use both instances at the same time. Any ideas or places I should start? Well in my script exist certain objects being used everywhere, in main script files and class library files. A good example is this Page class: Code: [Select] <?php class Page{ public $type; public $name; private $title = ""; private $content = ""; private $date = ""; private $links; private $sidebar; private $ads; public function __construct($page = ""){ // Constructor method of page class } public function gettitle(){ if(empty($this->title)) throw new Exception('The page has no title.'); return $this->title; } public function settitle($title){ $title = secure($title); if(empty($title)) throw new Exception('Cannot set title for this page.'); else $this->title = $title; } public function getcontent(){ if(empty($this->title)) throw new Exception('The page has no content.'); return $this->content; } public function addcontent($content, $overwrite = FALSE){ $content = secure($content); if(empty($this->content) or $overwrite == TRUE) $this->content = $content; else $this->content .= $content; } public function getlinks(){ // the method that grabs user links } public function getsidebar(){ // the method that loads sidebar } public function getads(){ // the method that shows ads } public function display(){ // the method that format pages and brings everything together } } ?> Now lets say I have other classes such as User, Message and Item, a page object will need to be used inside some of their methods so that the page title/content can be modified when necessary. This seems to be quite problematic to me, since I have to declare this Page object global in every method that uses it. Similar problem occurs with my database object, and its even more annoying since almost half of my class methods need to use database queries and commands. So I was wondering... Is there a better way for me to handle these system objects such as Page and Database rather than having to declare them as global inside every single method that deals with them? Please help... Hello! I am executing an external command from a PHP script, using the exec function. Since this program can take more than 1-2 minutes to run, I thought I should use a "Loading page...please wait". What I need is to be able to get the process id from the external program that is being run and, when this finishes, I'll start outputting the results. Is there a way to do this? Hello all!
I have this array of objects:
Array ( [0] => stdClass Object ( [first_name] => test [last_name] => test [title] => test [id] => 34 [type] => 4 [manager] => 4 [email] => p@yahoo.com [date] => 2014-09-21 07:23:12 [status] => 2 [approval_date] => 2014-09-21 07:31:10 [assessment_id] => 1 [supervisor_approval] => 1 [manager_approval_date] => 2014-09-21 07:31:27 [mainmanger] => 3 ) [1] => stdClass Object ( [first_name] => test [last_name] => test [title] => test [id] => 34 [type] => 4 [manager] => 4 [email] => p@yahoo.com [date] => 2014-09-20 07:39:55 [status] => 2 [approval_date] => 2014-09-20 07:40:41 [assessment_id] => 3 [supervisor_approval] => 1 [manager_approval_date] => 2014-09-20 07:41:07 [mainmanger] => 3 ) [2] => stdClass Object ( [first_name] => jimmy john john [last_name] => john [title] => Lorad and Master [id] => 32 [type] => 4 [manager] => 3 [email] => j@j.com [date] => 2014-09-21 07:38:50 [status] => 2 [approval_date] => 2014-09-19 07:39:25 [assessment_id] => 2 [supervisor_approval] => 1 [manager_approval_date] => 2014-09-19 07:39:25 [mainmanger] => 0 ) )Where "id" = the user ID. If there are two or more entries for a user, I want to remove all but the most recent by the "approval_date",... So for the above example it would return: Array ( [0] => stdClass Object ( [first_name] => test [last_name] => test [title] => test [id] => 34 [type] => 4 [manager] => 4 [email] => piznac@yahoo.com [date] => 2014-09-21 07:23:12 [status] => 2 [approval_date] => 2014-09-21 07:31:10 [assessment_id] => 1 [supervisor_approval] => 1 [manager_approval_date] => 2014-09-21 07:31:27 [mainmanger] => 3 ) [1] => stdClass Object ( [first_name] => jimmy john john [last_name] => john [title] => Lorad and Master [id] => 32 [type] => 4 [manager] => 3 [email] => j@j.com [date] => 2014-09-21 07:38:50 [status] => 2 [approval_date] => 2014-09-19 07:39:25 [assessment_id] => 2 [supervisor_approval] => 1 [manager_approval_date] => 2014-09-19 07:39:25 [mainmanger] => 0 ) )I'm having a hard time wrapping my head around this concept, so I don't have any example code. And I don't really need or expect someone to code this for me,. just a push in the right direction would be awesome. I was looking over some code that someone else had written when I noticed a line with "$this->entity" in it. "Entity" is recognized as PHP syntax in my text editor but I cannot find any reference to it in any documentation that I've looked through. Where can I find more information about the "entity" class? Thanks in advanced! I have the following three tables (and also delta_point and hist_point which are purposely left out and just mentioned for context). Before going down the Doctrine ORM long curvy road, aggrType was just used to restrict possible values so that I didn't need to use MySQL's ENUM, but now I am thinking there may be value to making it an entity and include some methods (and a second reason because I still can't figure out how to make Doctrine create a FK constraint yet not populate the parent entity with a AggrType object). point -id (int PK) -data -dType /* descriminator. Options are AggregatePoint, DeltaPoint, and HistoricPoint */ aggr_point -id (int PK, FK to point) -aggrType (char FK to aggrType) -data aggrType -type (char PK) /* there are about five types */ I have a service to create a new point based on the provided desired type and user data. I don't like the switch statement to determine which type of point to create, but don't know a better way. Also my entity is responsible to provide the appropriate validation rules for the given point type which might not be considered proper but it seems to work for me. Any constructive criticism is welcomed. <?php namespace NotionCommotion\PointMapper\Api\Point; use NotionCommotion\PointMapper\Domain\Entity\Point; class PointService { public function create(string $type, array $params):integer { $class=[ 'aggr'=>'AggregatePoint', 'delta'=>'DeltaPoint', 'hist'=>'HistoricPoint', ][$type]; //$class='Point\\'.$class; //This doesn't seem to be possible and I needed to use the fully qualifed name without the short cut used namespace. $class='\\Greenbean\Datalogger\Domain\Entity\Point\\'.$class; $point=new $class(); $validator=$this->getValidator($point); $params=$validator->sanitize($params); $validator->validate($params); $point->setAccount($this->account); $point->populate($params, $this->em); //Will be addressed later $this->em->persist($point); $this->em->flush(); $point->setIdPublic($this->em->getRepository(Point\Point::class)->getPublicId($point->getId())); return $point->getIdPublic(); } } Now, this is the part I am struggling with the most. I only have one service to create any type of point, so I do wish to put a bunch of if/thens in it and instead move logic to the individual point type being created. The AggrPoint in question requires a sub-point and I don't think it is appropriate to inject the entity manager into a point entity and as an alternative solution find an existing point which is associated with the account which resides in the new AggrPoint. Maybe not appropriate, but it works. This type of point also has a sub-object AggrType as discussed at the very beginning of this post, so I first attempt to create a new one from scratch, but that doesn't work and I need to set $aggrType with an existing one. As an alternative, I passed the entity the entity manager, but as stated I think this is a bad idea. Any recommendations where to go from here? Thank you namespace NotionCommotion\PointMapper\Domain\Entity\Point; class AggregatePoint extends Point { public function populate(array $params, \Doctrine\ORM\EntityManager $em):\NotionCommotion\PointMapper\Domain\Entity\Entity{ $criteria = \Doctrine\Common\Collections\Criteria::create() ->where(\Doctrine\Common\Collections\Criteria::expr()->eq("id_public", $params['pointId'])); if(!$subpoint = $this->getAccount()->getPoints()->matching($criteria)->current()){ throw new \Exception("Invalid subpoint ID $params[pointId]"); } $this->setSubpoint($subpoint); //This won't work since I must use an existing AggregateType and not create a new one $aggrType=new AggregateType(); $aggrType->setType($params['aggrType']); //This just seems wrong and I shouldn't be passing the entity manager to an entity $aggrType=$em->getRepository(AggregateType::class)->findOneBy(['type'=>$params['aggrType']]); $this->setAggregateType($aggrType); unset($params['pointId'], $params['aggrType']); // parent::populate($params) not shown, but it basically calles appropriate setters based on the property name return parent::populate($params); } public function getValidatorRules():array { return $this->filesToArr(['/point/base.json', '/point/aggr.json']); } }
I have mysqli object in Database class base: [color=]database class:[/color] class Database { private $dbLink = null; public function __construct() { if (is_null($this->dbLink)) { // load db information to connect $init_array = parse_ini_file("../init.ini.inc", true); $this->dbLink = new mysqli($init_array['database']['host'], $init_array['database']['usr'], $init_array['database']['pwd'], $init_array['database']['db']); if (mysqli_connect_errno()) { $this->dbLink = null; } } } public function __destruct() { $this->dbLink->close(); } } Class derived is Articles where I use object dBLink in base (or parent) class and I can't access to mysqli methods (dbLink member of base class): Articles class: require_once ('./includes/db.inc'); class Articles extends Database{ private $id, .... .... $visible = null; public function __construct() { // Set date as 2009-07-08 07:35:00 $this->lastUpdDate = date('Y-m-d H:i:s'); $this->creationDate = date('Y-m-d H:i:s'); } // Setter .... .... // Getter .... .... public function getArticlesByPosition($numArticles) { if ($result = $this->dbLink->query('SELECT * FROM articles ORDER BY position LIMIT '.$numArticles)) { $i = 0; while ($ret = $result->fetch_array(MYSQLI_ASSOC)) { $arts[$i] = $ret; } $result->close(); return $arts; } } } In my front page php I use article class: include_once('./includes/articles.inc'); $articlesObj = new articles(); $articles = $articlesObj->getArticlesByPosition(1); var_dump($articles); [color=]Error that go out is follow[/color] Notice: Undefined property: Articles::$dbLink in articles.inc on line 89 Fatal error: Call to a member function query() on a non-object in articles.inc on line 89 If I remove constructor on derived class Articles result don't change Please help me Can anyone post a generic update function to update mysql table. The manual approach: update $tablename set $column1='a', $column2='b' where $id=$value; Hi i have this simple update form and scrip but somehow it doesnt seem to be update the field on the database can someone help out please. The html form is the second form bellow where the action send to status_update.php HTML FORM Code: [Select] <?php include("../header.html"); ?> <?php include("header_news.html"); extract($_REQUEST,EXTR_SKIP); ?><?php /* print("sfilm_refnum = $sfilm_refnum<BR>"); print("sfilm_addr01 = $sfilm_addr01<BR>"); print("sfilm_postcode = $sfilm_postcode<BR>"); print("Film Client = $fclient<BR>"); */ ?> <form id="search" action="list.php" method="post" name="search"> <table width="780" border="0" cellspacing="0" cellpadding="4" bgcolor="#eeeeee"> <tr> <td align="right" width="140"></td> <td width="320"><span class="hofblack10"> </span> </td> <td align="center" width="100"><input type="hidden" name="lstart" value="<?php print("$lstart"); ?>" /><input type="hidden" name="lend" value="<?php print("$lend"); ?>" /><input type="hidden" name="lamount" value="<?php print("$lamount"); ?>" /></td> <td align="center" width="100"></td> <td align="right"></td> </tr> </table> </form> <table width="780" border="0" cellspacing="0" cellpadding="4" bgcolor="#4050c4"> <tr> <td width="60" class="hofwhite10">action</td> <td width="140"><span class="hofwhite14">DATE</span></td> <td width="80"><span class="hofwhite14">ID</span></td> <td><span class="hofwhite14">News Titile</span></td> <td width="100"><span class="hofwhite14">Status</span></td> </tr> <tr height="0"> <td bgcolor="white" width="60"></td> <td bgcolor="white" width="140" height="0"></td> <td bgcolor="white" width="80" height="0"></td> <td bgcolor="white" height="0"></td> <td bgcolor="white" width="100" height="0"></td> </tr> </table><table width="780" border="0" cellspacing="0" cellpadding="4"><tr> <td width="60"></td> <td width="80"></td> <td><a class="blueullrg" href="add.php">Add News</a></td> <td align="right" width="120"></td> </tr> <tr height="0"> <td width="60" height="0"></td> <td width="80" height="0"></td> <td height="0"></td> <td align="right" width="120" height="0"></td> </tr> </table> <?php //get the DB connection variables include("../../../includes/config.php"); //connect to DB $connection = @mysql_connect($db_address,$db_username,$db_password) or die("Couldn't CONNECT."); $db = @mysql_select_db($db_name, $connection) or die("Couldn't select DATABASE."); $query2="SELECT * FROM news WHERE !(news_status='deleted')"; $result2 = mysql_query($query2) or die("Couldn't execute QUERY - Select NEWS Qty"); $fqty = mysql_num_rows($result2); //SELECT or FIND the same USERNAME $query3="SELECT * FROM news WHERE !(news_status='deleted') ORDER BY news_id DESC"; $result3 = mysql_query($query3) or die("Couldn't execute QUERY - Select NEWS"); while ($row = mysql_fetch_array($result3)) { $news_id = $row['news_id']; $news_title = $row['news_title']; $news_story = $row['news_story']; $news_image = $row['news_image']; $news_image_caption = $row['news_image_caption']; $news_image_link = $row['news_image_link']; $news_date_day = $row['news_date_day']; $news_date_month = $row['news_date_month']; $news_date_year = $row['news_date_year']; $news_status = $row['news_status']; $news_website = $row['news_website']; $news_date_created = $row['news_date_created']; $news_date_modified = $row['news_date_modified']; ?> <table width="780" border="0" cellspacing="0" cellpadding="4" bgcolor="#eeeeee"> <tr> <td width="60"><span class="hofblack10"> <?php if($news_status=="deleted"){ print("<a class='hifblack10'>deleted</span>"); }ELSE{ print("<a class='blueul' href='edit.php?id=$news_id'>edit</a>"); } ?> </span></td> <td width="140"><span class="titlegrey12"> <?php if(!$news_date_day) { echo "00"; } else{ echo $news_date_day; } echo "/"; if(!$news_date_month) { echo "00"; }else{ echo $news_date_month; } echo "/"; if(!$news_date_year) { echo "0000"; }else{ echo $news_date_year; } ?> </span></td> <td width="80"><span class="titlegrey12"><?php print("$news_id"); ?></span> </td> <td><?php if($news_status=="deleted") { print("<class='hofblack10'>$news_title</span>"); }ELSE{ print("<a class='blueul' href='edit.php?id=$news_id'>$news_title</a>"); } ?></td> <td width="100"> <form id="list_update" action="status_update.php" method="post" name="list_update"> <select name="newnstatus" size="1"> <option <?php if($row['news_status'] == "") { print("selected"); } ?> selected="selected" value="">Status...</option> <option <?php if($row['news_status'] == "on") { print("selected"); } ?> value="on">On</option> <option <?php if($row['news_status'] == "off") { print("selected"); } ?> value="off">Off</option> <option <?php if($row['news_status'] == "deleted") { print("selected"); } ?> value="deleted">Delete</option> </select> <input type="hidden" name="nstatus" value="<?php echo $row[news_status]; ?>" /> <input type="hidden" name="id" value="<?php echo $row[news_id]; ?>" /> <input type="submit" name="update" value="update" /> </form> </td> </tr> <tr height="0"> <td bgcolor="white" width="60"></td> <td bgcolor="white" width="140" height="0"></td> <td bgcolor="white" width="80" height="0"></td> <td bgcolor="white" height="0"></td> <td bgcolor="white" width="100" height="0"></td> </tr> </table> <?php } mysql_close($connection);//}?> <table width="780" border="0" cellspacing="0" cellpadding="4"> <tr> <td width="60"></td> <td width="80"></td> <td><a class="blueullrg" href="add.php">Add News</a></td> <td align="right" width="120"></td> </tr> </table><?php // include("list_navigation.html"); ?> <?php include("../footer.html"); ?> </div></body></html> The action script php Code: [Select] <?php /* echo "fstatus: ".$fstatus."<BR>"; echo "id: ".$id."<BR>"; echo "fclient: ".$fclient."<BR>"; echo "newfstatus: ".$newfstatus."<BR>";*/ //set the date of agreement $timestamp = date('l jS \of F Y h:i:s A'); //get the DB connection variables include("../../../includes/config.php"); //connect to DB $connection = @mysql_connect($db_address,$db_username,$db_password) or die("Couldn't CONNECT."); $db = @mysql_select_db($db_name, $connection) or die("Couldn't select FILMS DATABASE."); // All appears well, so enter into database $query= "UPDATE news SET news_status = '$newnstatus' WHERE news_id='$id'"; $result = mysql_query($query) or die("could not execute query - Update FILMS Record to DB"); //setup an email to the Admin @ hof, w/o attachment $emailto="xx@xxx.co.uk"; $emailfrom="no-reply@xxxx.co.uk"; $emailsubject="xx Record Updated"; $emailmessage="Hello Registrar\n\n"; $emailmessage.="News ID: ".$id."\n"; $emailmessage.="Updated on: ".$timestamp."\n\n"; $emailmessage.="Status was: ".$nstatus."\n"; $emailmessage.="Status now: ".$newfnstatus."\n"; $emailmessage.="Thank you,\n\n"; $emailmessage.="Web Site ROBOT\n"; $emailmessage.="(Administrator)\n"; $emailmessage.="xxx.co.uk | xxx.biz\n"; $emailmessage.="----------------------------------------------\n"; $emailmessage.="e. http://www.xxx.co.uk/contact.php\n"; $emailmessage.="w. http://www.xxx.co.uk\n"; $emailheader="From: xxx.co.uk<$emailfrom>"; $emailheader .= 'Cc: xxx@xxx.co.uk'."\r\n"; $emailheader .= 'Bcc: xxx@xxxxx.co.uk'."\r\n"; $ok=mail($emailto,$emailsubject,$emailmessage,$emailheader); mysql_close($connection); if ($ok) { header("Location: list.php"); /* Redirect browser */ exit; } else { $errmsg="There was a problem, please try later or telephone us direct."; $errsta="1"; include("edit_error.html"); //echo "<p>Mail could not be sent. Sorry!</p>"; exit; } ?> Thanks in advance Hi Can you call Class A's methods or properties from Class B's methods? Thanks. If a class has a constructor but also has a static method, if I call the static method does the constructor run so that I can use an output from the constructor in my static method? --Kenoli I have an existing instance of my class Database, now I want to call that instance in my Session class, how would I go about doing this? Ok. I know you can pass the object of a class as an argument. Example: class A { function test() { echo "This is TEST from class A"; } } class B { function __construct( $obj ) { $this->a = $obj; } function test() { $this->a->test(); } } Then you could do: $a = new A(); $b = new B($a); Ok so that's one way i know of. I also thought that you could make a method static, and do this: (assuming class A's test is 'static') class B { function test() { A::test(); } } But that is not working. I'd like to know all possible ways of accomplishing this. Any hints are appreciated. thanks what Im basically trying to do is just like a phpmyadmin function... you select rows you want to update with a checkbox and then it takes you to a page where the rows that are clicked are shown in forms so that you can view and edit info in them... and then have 1 submit button to update them all at once. |