PHP - Question About Strict Standards
I would like some expertise of some one that could help me on this i m getting the following error, on the code i m developing:
Quote Strict Standards: Non-static method authentication::login() should not be called statically in C:\xampp\htdocs\myanidb\includes\common\content\login.php on line 12 these are the lines of code (not completed ofc ..) login.php Code: [Select] <?php # The PHP extention files are usually protected by the webserver, but abit of # extra protection never hurted anyone. if( !defined('abspath')){die("Accessing this file directly is not allowed." );} # The login sequence for the user is made by the following steps: # Uppon entering this file (login.php) the POST variables 'username' and 'password' # are tested to see if the user entered any data to be authenticated this test is # made by checking if both variables are set (by using isset). if they are set this # means the user is trying to authenticate if( isset( $_POST['username'] ) && isset( $_POST['password'] ) ){ $login = authentication::login( $_POST['username'], $_POST['password'] ); }else{ ?> <form action="?go=login" method="post"> <table align="center"> <tr> <td><font size="2">Username</font></td> <td><input type="text" name="username" /></td> </tr> <tr> <td><font size="2">Password</font></td> <td><input type="password" name="password" /></td> </tr> <tr> <td colspan="2" align="center"><input type="submit" value="Login" /></td> </tr> </table> </form> <? } ?> class.authentication.php Code: [Select] <?php # The PHP extention files are usually protected by the webserver, but abit of # extra protection never hurted anyone. if( !defined('abspath')){die("Accessing this file directly is not allowed." );} class authentication{ protected $loginquery = ''; # Uppon class declaration, this class will start an php session function __construct(){ session_start(); } # Main function on the autentication class, this function will be triggered # out site de class and will carry out all the necessary steps to authenticate # an user. public function login( $username, $password ){ echo "Username: ". $username ." | Password: ". $password; } # Clean's up the user session variables by unsetting the $_SESSION array, # destroying the session and regenerate an new ID if the user comes wants # to stay on the page but not logged in. public function logout(){ session_unset(); session_destroy(); session_regenerate_id(); } } ?> I started to learn PHP not so long ago where some of the time i couldnt do much or learn due to work and rl, so i know probably i m not doing things the right way, if possible please let me know what i m doing wrong. Thanks in Advance Similar TutorialsI'm making forums at the minute and everything is going well, apart from these stupid errors that I can't seem to get rid of for the life of me. It is frustrating me so much! I've looked through the code and cannot find anything wrong.
The first error appears at the top of my forums whenever you're logged in about strict standards. This is what the error says:
Line 6 of viewthread.php is - require('../structure/forum.thread.php');;
Here is the code of the thread::canView() and thread::canView() that is located within my structure.
thread::canView function below
public function canView($id, $username, $powerLevel) { I keep getting this error code and not sure why Quote Strict Standards: Only variables should be passed by reference in This is the line of code that it reference to. Code: [Select] $file_ext = strtolower(end(explode(".", $file_name))); Can someone please help me Hello guys, not sure why I keep getting this error, can anyone help me? Here is the code:
$ext=end(explode('.',$thum)); Hello, I have a "working" upload script but i do get an error: Strict Standards: Only variables should be passed by reference in C:\Users\UHN\Desktop\xampp-win32-1.7.4-VC6\xampp\htdocs\upload.php on line 99 Line 99: $file_ext = strtolower(end(explode('.', $file_name))); thanks.. Hi... I tried to import to my database an xml file using this code: <?php //ini_set('display_errors', -1); //error_reporting(E_ALL); //error_reporting(-1); error_reporting(E_ALL | E_STRICT); //error_reporting(E_ALL ^ E_NOTICE); date_default_timezone_set("Asia/Singapore"); //set the time zone $data = array(); $con = mysql_connect("localhost", "root",""); if (!$con) { die(mysql_error()); } $db = mysql_select_db("mes", $con); if (!$db) { die(mysql_error()); } function add_employee($ETD,$PO_No,$SKUCode,$Description,$POReq ,$Comp) { global $data; $con = mysql_connect("localhost", "root",""); if (!$con){ die(mysql_error());} $db = mysql_select_db("mes", $con); if (!$db) { die(mysql_error()); } $ETD= $ETD; $PO_No = $PO_No; $SKUCode = $SKUCode; $Description = $Description; $POReq = $POReq; $Comp = $Comp; $sql = "INSERT INTO sales_order (ETD,PO_No,SKUCode,Description,POReq,Comp) VALUES ('$ETD','$PO_No','$SKUCode','$Description','$POReq','$Comp') ON DUPLICATE KEY UPDATE ETD = '$ETD', PO_No = '$PO_No', SKUCode = '$SKUCode', Description = '$Description', POReq = '$POReq', Comp = '$Comp'" or die(mysql_error()); $res = mysql_query($sql, $con); $data []= array('ETD'=>$ETD,'PO_No'=>$PO_No,'SKUCode'=>$SKUCode,'Description'=>$Description,'POReq'=>$POReq,'Comp'=>$Comp); } // if (isset($_FILES['file']['tmp_name'])){ if(empty($_FILES['file']['tmp_name']['error'])){ $dom = new DOMDocument(); $dom = DOMDocument::load('SalesOrder.xml'); //$dom = DOMDocument::load($_FILES['file']['tmp_name']); //$dom = DOMDocument::__construct(); $rows = $dom->getElementsByTagName('Row'); global $last_row; $last_row = false; $first_row = true; foreach ($rows as $row) { if ( !$first_row ) { $ETD = ""; $PO_No = ""; $SKUCode = ""; $Description = ""; $POReq = ""; $Comp = ""; $index = 1; $cells = $row->getElementsByTagName( 'Cell' ); foreach( $cells as $cell ) { $ind = $cell->getAttribute( 'Index' ); if ( $ind != null ) $index = $ind; if ( $index == 1 ) $ETD = $cell->nodeValue; if ( $index == 2 ) $PO_No = $cell->nodeValue; if ( $index == 3 ) $SKUCode = $cell->nodeValue; if ( $index == 4 ) $Description = $cell->nodeValue; if ( $index == 5 ) $POReq = $cell->nodeValue; if ( $index == 6 ) $Comp = $cell->nodeValue; $index += 1; } if ($ETD=='' AND $PO_No=='' AND $SKUCode=='' AND $Description=='' AND $POReq=='' AND $Comp=='') { $last_row = true; } else { add_employee($ETD,$PO_No,$SKUCode,$Description, $POReq, $Comp); } } if ($last_row==true) { $first_row = true; } else { $first_row = false; } } } ?> but I got an error: Strict Standards: Non-static method DOMDocument::load() should not be called statically in this part: $dom = DOMDocument::load('SalesOrder.xml'); I hope somebody can help me...I need to import data from .xml to my database. Thank you so much I am working in wordpress. I am using a switch statement to call a php page. It looks like this Code: [Select] $slider_type = $options['type']; switch($slider_type) { case "Half Page Slider" : include('nivo-default.php'); break; case "Full Page Slider" : include('nivo-fullpage.php'); break; default: include('nivo-fullpage.php'); } The code works fine. My question is this. I want to use the exact same code to call the css file that runs each page. So instead of inlcuding a php page, I would replace that with the css call. So is it a bad idea to use the variables in the head section and then again in the page a little further down? or should I change the names? What is the best coding practice here? What are some common standards to writing a php class? One thing I think is a standard is using "Camel Case" (example): public function myFunctionName instead of using: public function my_function_name Is that true, and are there any others that you know about? I would like to hear what they are! Thanks! I am working on a Contact Form in my .php file. I have always worked with loose doctypes, however, today I am using strict. I have my php above my html, and none of the code runs. Instead, it just displays some of the Echos to the page (these aren't even called yet). Also, in my form, I have the following: <INPUT NAME="Name" SIZE="30" value="<?php echo $Name; ?>"> On the page inside the field, it is displaying: <?php echo $Name; ?> What is going on here and how can I fix this issue? Yes, the pages are .php Here is the doctype: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> Any input appreciated Hey Guys. I am trying to create a strict data type within a function. (Boolean only) However when I pass a string it doesn't display any errors. Below is the fucntion I am using. Any help would be really appreciated
function outputAddress($resolve){ if(!is_bool($resolve)) { die("outputAddress() requires a boolean argument"); } outputAddress("true"); // Doesn't display any error messages?? when in a form, I wish to build a conditional that if the response to a radio button is a value of 2 (female), it will display an input requesting for users maiden name. If not 2 goes to the next input statement. Here is code I was experimenting with: <html> <body> <form action="" name="test" method='POST'> <input type="radio" id="sex" value=1 checked><label>Male</label> <input type="radio" id="sex" value=2><label>Femaleale</label> <?php $result = "value"; if ($result == 2) echo "<input type='int' id='gradYear' size='3' required>"; else echo "Not a female!" ?> <input type="submit" value="GO"> </form> </body> </html> The code passes debug, however, Not a Female is displayed. My question is - Can I do this and if so, what value do I test against id='sex' or value. I tried each one but gave the same results. I realize that $_POST[sex] would be used after the submit button is clicked. But this has me stumped. Thanks for the assis in advance. hi, im trying to say if field ARTIST = Eminem then do the following. here is my current code Code: [Select] $hmm = simplexml_load_file('http://localhost/1.0/?method=player.getPlayQueue'); foreach($hmm->tracks->track as $tracks) { $artist = $tracks->artist; $title = $tracks->title; $album = $tracks->album; $index = $tracks->index; $id = $tracks->id; //If we submitted the form if('.$artist.'="eminem") { echo '<table border="0" width="70%" align="center">'; echo '<tr>'; i just need to know how to do the if(***) part. thanks. Code: [Select] <?php if ($News_1_Status=="Y") echo <div class="newstitle" align="left"><?php echo $News_1_Date;?> <a href="<?php echo $News_1_URL;?>"><?php echo $News_1_Name;?></a></div><br>; else echo "Have a nice day!"; ?> how do i get the above script working any clue? Hello. I'm trying to pull information out of an xml file. However I'm a bit lost in getting the actual value. Code: [Select] $url="http://ws.audioscrobbler.com/2.0/?method=artist.getimages&artist=Dr%20Feelgood&limit=1&autocorrect=1&api_key=c107c9b5c09cb5693b6c19409dd984c1"; $xml = simpleXML_load_file($url,"SimpleXMLElement",LIBXML_NOCDATA); $largesquare=$xml->images->sizes->size[2]; Is what I have but its not pulling the information. The above url will give you the link to a set xml file for this example. And I want to get the info for the Code: [Select] <size name="largesquare" width="126" height="126">http://userserve-ak.last.fm/serve/126s/43173899.jpg</size> I'm sure I'm doing something wrong that's a simple fix but I am lost here. In the sizes there are 6 different size options each with different names and I have no idea how to pull the one with the correct name that I need. Thank you to who ever can help me sort this out. Hello, I have a 'strange' situtation. I have this string "Who Am I" that will be used as an header (site for a client) but the design shows that the word "Who" and the words "Am I" are in 2 different colors, in HTML this is a quick fix, but in PHP? What I was thinking was explode the string and fetch the first element put it in a var en then concat the 2 others. But what if the title is more then 3 elements after exploding? It needs to be more dynamic, but I don't know how to do it. Does anyone have an idea? U guys know in forums how at the top or bottom there links to the "1 2 3 4 5 next" and stuff? and how it loads a database? how would i do that exactly? or explain to me what it could be called. cause me i have no idea :/ Just get started with OO in PHP. If I create an object while on one page and then call another page, can I still access that first object, or is it destroyed when the second page is called? For example, if I have on page1.php: Code: [Select] $obj = new $MyObject(); and then call page2.php, is it possible to still access $obj while on that page? hi php people, I am wondering will if the code below will work when I call $C->getafoo() will I get foo; I keep getting an error at this point return $this->A->a(); saying the method is not there Code: [Select] class A{ public function a(){ return "foo"; } } class B { public $A; function __construct($A) { $this->A = $A; } public function geta(){ return $this->A->a(); } } class C extends B{ public function getafoo(){ return geta(); } } $C = new C(new A()); echo $C->getafoo(); In php, which function is best used to act something like the sql "LIKE" command? and how would that function be used like? i have took a test that i think it has some errors: can you please confirm or infirm that A is the right answer? Question: The default value for __FILE__ is _______________________________. A. the complete path of the currently executing script B. the relative path of the currently executing script C. a magical constant; it does not have a default value D. the complete path of the previous executed script E. the relative path of the previous executed script Correct Answer: C User Answer: A Explanation: The PHP engine stores the full path and filename of the currently executing script within the __FILE__ constant. I am trying to make it so that it will load if the site if the site is online(EG. $siteonline = 1), and so on. I can't seem to think of how I could do this so it will work from the very top of the page's html, to the very bottom. Like the following code is meant to list all of the stuff in that database. <?php $list_q = mysql_query("SELECT * FROM settings") or die (mysql_error()); while($list_f = mysql_fetch_assoc($list_q)) { } ?> I have my page laid out like this.. <?php include "includes/connect.php"; include "includes/config.php"; ?> <?php $list_q = mysql_query("SELECT * FROM settings") or die (mysql_error()); while($list_f = mysql_fetch_assoc($list_q)) { ?> Html content etc.. <?php } include 'includes/footer.php'; ?> But if I do it that way, It only displays what is in footer.php. |