PHP - Do Namespaces Exist In Php?
Does the concept of a "Namespace" exist in PHP?
If so, how do you use them? This is a snippet from ASP.NET that made me ask this question... Quote <%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.SqlClient" %> TomTees Similar Tutorialsi have error where my code should update existing data where id exist, it get updated ..but the others data is disappeared .only the data updated is remained $sql1 ="select*from semakan_dokumen where email='$stdEmail'"; $sqlsearch1 = mysqli_query($dbconfig,$sql1); $resultcount1 = mysqli_num_rows($sqlsearch1); if($resultcount1 > 0){ $query1=("UPDATE semakan_dokumen set student_id='$noMatrik', email= '$stdEmail', surat_tawaran='$fileName', ic='$fileName1',sijil_lahir='$fileName2',sijil_spm= '$fileName3',sijil_sekolah= '$fileName4', sijil_dip= '$fileName5',sej_julai='$fileName6',bm_julai='$fileName7',muet='$fileName8', mid1='$fileName9',yuran= '$fileName10',umpa_bend1= '$fileName11',umpa_bend2='$fileName12',bpkp='$fileName13', penaja='$fileName14',kesihatan= '$fileName15', jhepa='$fileName16' where email= '$stdEmail' "); }else{ //filezip $query1 = "INSERT INTO semakan_dokumen (email,surat_tawaran,ic,sijil_lahir,sijil_spm,sijil_sekolah,sijil_dip,sej_julai,bm_julai,muet,mid1,yuran,umpa_bend1,umpa_bend2,bpkp,penaja,kesihatan,jhepa) VALUES ('$stdEmail','$fileName','$fileName1','$fileName2','$fileName3','$fileName4','$fileName5','$fileName6','$fileName7','$fileName8','$fileName9','$fileName10','$fileName11','$fileName12','$fileName13','$fileName14','$fileName15','$fileName16')"; }
Hey Guys. I am new to using namespaces. I am trying to use it on the code below but it keeps giving me an error message saying Class 'lesson_one\Lecture' not found
I am not sure what I am doing wrong here... I have provided an example below. I know there is a duplicate conditional statement. But I am just working with this code to test out the namespace.
Any help would be really appreciated!
namespace lesson_one; abstract class Lesson { protected $duration; const FIXED = 1; const TIMED = 2; private $costtype; function __construct($duration, $costtype=1) { $this->duration = $duration; $this->costtype = $costtype; } function cost(){ switch($this->costtype) { case self::TIMED: return (5* $this->duration); break; case self::FIXED: return 30; break; default: $this->costtype = self::FIXED; return 30; } } function chargeType() { switch($this->costtype) { case SELF::TIMED: return "hourly rate"; break; case self::FIXED : return "fixed rate"; break; default: $this->costtype = self::FIXED; return "fixed rate"; } } } class Lecture extends Lesson { } class Seminar extends Lesson { } //echo Lesson::FIXED; $lecture = new \lesson_one\Lecture("5", Lesson1::FIXED); echo $lecture->cost(). "<br>"; echo $lecture->chargeType(). "<br>"; when trying to call
get_class($this)it will return the namespace of my class Application\Models\User_Model But what im really after is just User_Model... is there a way of actually getting the class name and not the namespace itself? thought i'd ask before making a class for that...thank you
I have to be doing something wrong here, but so far Googling hasn't helped. Take a look he
https://demo.envrin.com/api/classes/apex.app.msg.emailer.html#method_send
The doc-block is correct, or at least as far as I can tell it is, character-by-character. I'm blind though, but have tried different combinations of things like "String" instead of "string" or "@Param" instead of "@param". Made sure the ends of the @param lines ende din a period, and that seemed to help a little.
Nonetheless, why does it keep adding the namespace to everything in front of "string" like that? Any why are the paramaters section all screwed up?
Any help would be appreciated. Thanks!
I'm not entirely sure what is wrong with me, but I'm having a super difficult time understanding namespaces.
I have 2 primary classes
# Resides within class.DataTypeBase.php namespace DTB\Base; class DataTypeBase { protected $name = ''; protected function getName() { return $this->name; } protected function setName($name) { $this->name = $name; } } # Resides within class.DataType.php namespace DTB; class DataType extends DataTypeBase { public function process_data(){ .... } }I then have a third file that contains approximately 9 different classes that further extend DataType # Resides within class.DataTypes.php namespace DataTypes; class Silver extends DataType { public function differ($type) { .... } }The namespace system seems to work for class DataTypes, but with the class Silver I get an error message saying that the class DataType does not exist. From what I read online, and using the example above I figured the "extends DataType" may have to be "extends \DTB\DataType" but it results in the same error message. I'm not entirely sure what I need to do for this to work properly Hi,
Well, I'm having this
The formatter threw an exception while trying to deserialize the message: Error in deserializing body of request message for operation 'GetSomething'. End element 'Body' from namespace 'http://schemas.xmlso.../soap/envelope/' expected. Found element 'param1' from namespace ''.
The soapclient request itself is something with multiple namespaces, like :
<aaa xmlns="namespace1"> <bbb xmlns="namespace2" xmlns:i="http://www.w3.org/20...hema-instance"> <requestparams>xxxxx</requestparams> </bbb> </aaa> So far I think this may got to do with multiple namespaces, so I've been trying to figure out how to deal with this for hours to no avail. Anyone can shed a light into this problem ? Thanks in advance, if so how would they be used in a mysql query? hello, i am having an issue with tables using incorrect data. i have 2 columns, first is employee name, second is location if the employee doesnt have a location for the current day, it is telling me he is at the same location as the guy in the row above him. i need this to be blank. is this possible? Hi.. So what i want to do is basicly to check if id XX exist in my database. How can this be done? Im thinking of something like: if(xx exist){do this} else{do this} Iv'e tried google etc before i posted here, but couldent really find anything where i found a soutable answer.. Hope someone can help! (: hi, im having trouble adding a get variable to a url if one already exists. eg current url = http://www.example.com/index.php?var1=something i want to be able to change this to new url = http://www.example.com/index.php?var1=something&var2=another even so i can have a few get variable there. I can add the first var through a form or link, but how would i add more through a link or through the header function? I am positivly stuck. Thanks Hi all, I want to make a script that identifies if an image JPG file exists. Would somthing like this work? <?php $file = "images/image.jpg"; if ($file > 0) { echo "file exists"; } else { echo "no file"; } ?> Gud pm!! So i made this script to check if a username and password exist but it kinda fails me. It gives me a database connection error from my confirm_query() which means it returned false? so here's my code: Code: [Select] function check_if_exist($username, $password) { global $connection; $query = "SELECT username, hashed_password"; $query .= "FROM users "; $query .= "WHERE username = '$username' "; $query .= "AND hashed_password = '$password' "; $query .= " LIMIT 1"; $result_set = mysql_query($query, $connection); confirm_query($result_set); if(mysql_num_rows($result_set) == 1) { return true; } else { return false; } } my confirm_query(): Code: [Select] function confirm_query($result) { if(!$result) { die("Database connection failure ". mysql_error()); } } I have a another script to check if the email exist and it works perfectly, i dunno why this won't work properly.. maybe another simple mistake.. Any ideas or Violent reaction? Thanks! Hi all - I have a form that let's a user upload an image to their specified folder. The folder is determined by the "password" the user inputs. The "password" is really just the folder name on my server, so if "michael83" was entered as a password, the directory would be "images/uploaded/michael83". That works great now, thanks to a forum user, litebearer. Thanks again. Here's my second question: I'm working on a "history" page so that a user can input their "password" and view their upload history. The form works right now. If you enter a "password" (folder name) that exists, the code will spit out the contents / files. So, now I'm looking for two things: (1) if a user enters a "password" (folder name) that exists, but there are no files in the folder, "There are no files in the $dir directory." will be echoed; and (2) if a "password" (folder name) is entered that does NOT exist, "The directory $dir does not exist." will be echoed. Here's my code so far (minus the if statements I'm looking for): $dir = $_POST['password']; $path = "images/uploaded/". $dir; $dir_handle = @opendir($path); while ($file = readdir($dir_handle)) { if($file == "." || $file == ".." ) continue; if(isset($_POST['Submit'])) $url = "http://www.mysite.com/". $path . "/" . $file; { echo "<a href=\"$url\">$url</a><br />"; }} closedir($dir_handle); As always, many thanks in advance for any help on this. Basically this gets a number from a table on my DB, and displays the content relevent to that number...the second part checks for that number and gets other information according to that number... what i want to do is make sure that the number from the first query exists in the table from the query, and if it doesn't print out and error saying "there is no information" or whatever.. anyone have an idea? hopefully this makes sense Code: [Select] <?php require_once('Connections/myConnect.php'); $detnum = $_GET['Details']; $detinfo = mysql_query("SELECT* FROM `Agency Stores - Table 1` WHERE F11=".$detnum); $det = mysql_fetch_array($detinfo); $salesnum = $det['F3']; $salesinfo = mysql_query("SELECT* FROM `By Agency Store _` WHERE store_store=".$salesnum); $sales = mysql_fetch_array($salesinfo); if(mysql_query("SELECT* FROM `By Agency Store _` WHERE store_store=".$salesnum)){ } ?> hi, i have a select which gets todays schedule for each user. sometimes that user doesnt have anything for todays date and it will display the info from the user above him. how can i make it so it stays blank if there is no record? Is it possible to check if multiple rows exist at the same time. For example, if a row with the id "1" and another row with id "2" exists, and return something like true then false if only the first exists?
I have a file that provides tens of thousands to check and it takes forever. I know this sounds bad off the start, but it's not something that is run normally. Only to update my database with new additions.
Is there any good way to check a lot at once? I know you can insert many at a time and save a lot of time.
This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=357281.0 I have an array like so Array (14) ( | ['0'] => Array (5) | ( | | ['name'] = String(7) "Pikemen" | | ['hp'] = Integer(1) 0 | | ['atk'] = Integer(1) 5 | | ['def'] = Integer(1) 5 | | ['rng'] = Integer(2) 15 | ) | ['1'] => Array (5) | ( | | ['name'] = String(7) "Pikemen" | | ['hp'] = Integer(1) 0 | | ['atk'] = Integer(1) 5 | | ['def'] = Integer(1) 5 | | ['rng'] = Integer(2) 15 | ) | ['2'] => Array (5) | ( | | ['name'] = String(7) "Pikemen" | | ['hp'] = Integer(1) 0 | | ['atk'] = Integer(1) 5 | | ['def'] = Integer(1) 5 | | ['rng'] = Integer(2) 15 | ) | ['3'] => Array (5) | ( | | ['name'] = String(7) "Pikemen" | | ['hp'] = Integer(1) 0 | | ['atk'] = Integer(1) 5 | | ['def'] = Integer(1) 5 | | ['rng'] = Integer(2) 15 | ) | ['4'] => Array (5) | ( | | ['name'] = String(7) "Pikemen" | | ['hp'] = Integer(1) 0 | | ['atk'] = Integer(1) 5 | | ['def'] = Integer(1) 5 | | ['rng'] = Integer(2) 15 | ) | ['5'] => Array (5) | ( | | ['name'] = String(7) "Pikemen" | | ['hp'] = Integer(1) 0 | | ['atk'] = Integer(1) 5 | | ['def'] = Integer(1) 5 | | ['rng'] = Integer(2) 15 | ) | ['6'] => Array (5) | ( | | ['name'] = String(7) "Pikemen" | | ['hp'] = Integer(1) 0 | | ['atk'] = Integer(1) 5 | | ['def'] = Integer(1) 5 | | ['rng'] = Integer(2) 15 | ) | ['7'] => Array (5) | ( | | ['name'] = String(7) "Pikemen" | | ['hp'] = Integer(1) 0 | | ['atk'] = Integer(1) 5 | | ['def'] = Integer(1) 5 | | ['rng'] = Integer(2) 15 | ) | ['8'] => Array (5) | ( | | ['name'] = String(7) "Pikemen" | | ['hp'] = Integer(1) 0 | | ['atk'] = Integer(1) 5 | | ['def'] = Integer(1) 5 | | ['rng'] = Integer(2) 15 | ) | ['9'] => Array (5) | ( | | ['name'] = String(7) "Pikemen" | | ['hp'] = Integer(1) 0 | | ['atk'] = Integer(1) 5 | | ['def'] = Integer(1) 5 | | ['rng'] = Integer(2) 15 | ) | ['10'] => Array (5) | ( | | ['name'] = String(7) "Pikemen" | | ['hp'] = Integer(1) 0 | | ['atk'] = Integer(1) 5 | | ['def'] = Integer(1) 5 | | ['rng'] = Integer(2) 15 | ) | ['11'] => Array (5) | ( | | ['name'] = String(7) "Pikemen" | | ['hp'] = Integer(1) 0 | | ['atk'] = Integer(1) 5 | | ['def'] = Integer(1) 5 | | ['rng'] = Integer(2) 15 | ) | ['12'] => Array (5) | ( | | ['name'] = String(7) "Pikemen" | | ['hp'] = Integer(1) 0 | | ['atk'] = Integer(1) 5 | | ['def'] = Integer(1) 5 | | ['rng'] = Integer(2) 15 | ) | ['13'] => Array (5) | ( | | ['name'] = String(7) "Pikemen" | | ['hp'] = Integer(1) 0 | | ['atk'] = Integer(1) 5 | | ['def'] = Integer(1) 5 | | ['rng'] = Integer(2) 15 | ) ) what i want to do is add the details to a new multi dimensional array but only add one each like so array( ['units'] = array( ['name'] => 'Pikemen', ['lost'] => 14 ) ) basically where the HP is 0 in the first array i need to add them to the second if the name is unique. I have tried array unique but it didnt seem to work. Any ideas? All i get it a loop of each Pikemen Working with authorize.net script that is included in my php. Trying to figure out how to use a variable beyond the 'case' I can do just about anything... inside the case... But I need to use the variable outside of there. Code: [Select] //several cases above case 5: $this->approval_code = $pstr_trimmed; break; // case 7 is the authorize.net transaction ID - This is the one I want to work with case 7: echo "Transaction ID: "; echo $pstr_trimmed; $trans_id_test = $pstr_trimmed; break; // but this below won't work. I can't use the variable anywhere outside of the case. echo "the new variable is now...".$trans_id_test; I have a field in a table named flights I hope to find a 1 line statement to bypass inserting a new row if $flight_no is already in the field flight_no btw flight_no is the primary key and won't allow a duplicate anyway but I want to avoid the error message this is what I tried but doesn't work if(SELECT * FROM flights WHERE flight_no !LIKE %$flight_no%) { |