Jump to content

NotionCommotion

Members
  • Posts

    2,446
  • Joined

  • Last visited

  • Days Won

    10

Everything posted by NotionCommotion

  1. I understood the requirements to be display the text Geen resultaat gevonden met opgegeven nummer. <br> Kijk na of U het nummer correct heeft ingevuld. zero or one time only. But then again, I stated I really did not understand the requirements.
  2. By the way, your statement "the else will show the text when there is no data found in that column" is incorrect. I will show when, $data->zoeknummer is not equal to $_GET['zoeknummer'] Also, not positive about what you are saying above so maybe something like the following won't work for you. $flag=false; while ($lead = $res->fetchColumn()) { $data = json_decode($lead); if ($data->zoeknummer == $_GET['zoeknummer']) { echo "Uw plaats voor " ; echo $data->wachtlijstkomplex . ' : ' . $data->wachtlijstplaats . '<br>'; } else { $flag=true; } } if($flag) { echo 'Geen resultaat gevonden met opgegeven nummer. <br> Kijk na of U het nummer correct heeft ingevuld.'; }
  3. You could use a flag (true/false) which starts off as FALSE, but then can be set to TRUE in your IF LOOP. When you are done with the WHILE LOOP, check to see if the flag is set, and if so, print your text. Based on your desired presentation, you might need to not directly echo the column text, but either add them to a string or buffer them (http://php.net/manual/en/function.ob-flush.php)
  4. Totally agree that efficiency isn't an issue, and making it the most readable (and maintainable) is much more important. Often it will also be the most efficient as well as you will not make silly mistakes.
  5. But it would also be silly to make 30 requests to the same table to retrieve 30 column values, no?
  6. Well, I suppose it is more efficient to hardcode the title, but it is less flexible and realistically, it the performance doesn't matter. But instead, why not get all your site information with one query, and then just echo("<h1>$siteStuff[title]</h1>");?
  7. What is not working?
  8. It appears that call_user_func_array() expects parameter 1 to be a valid callback, no array or string given in C:\AAAA WEB MASTER\webroot\rihut-mashlim\wp-includes\class-wp-hook.php on line 298. PS. Wrapping your code in the code tags is a nice thing to do.
  9. Well, your HTML is a wreck. Your also not doing any PHP other than potentially setting up a database connection. Notes and Potential IssuesThe following notes and warnings highlight missing or conflicting information which caused the validator to perform some guesswork prior to validation, or other things affecting the output below. If the guess or fallback is incorrect, it could make validation results entirely incoherent. It is highly recommended to check these potential issues, and, if necessary, fix them and re-validate the document. Unable to Determine Parse Mode! The validator can process documents either as XML (for document types such as XHTML, SVG, etc.) or SGML (for HTML 4.01 and prior versions). For this document, the information available was not sufficient to determine the parsing mode unambiguously, because: in Direct Input mode, no MIME Media Type is served to the validator No known Document Type could be detected No XML declaration (e.g <?xml version="1.0"?>) could be found at the beginning of the document. No XML namespace (e.g <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> ) could be found at the root of the document. As a default, the validator is falling back to SGML mode. No DOCTYPE found! Checking with default HTML 4.01 Transitional Document Type. No DOCTYPE Declaration could be found or recognized in this document. This generally means that the document is not declaring its Document Type at the top. It can also mean that the DOCTYPE declaration contains a spelling error, or that it is not using the correct syntax. The document was checked using a default "fallback" Document Type Definition that closely resembles “HTML 4.01 Transitional”. Learn how to add a doctype to your document from our FAQ. No Character encoding declared at document level No character encoding information was found within the document, either in an HTML meta element or an XML declaration. It is often recommended to declare the character encoding in the document itself, especially if there is a chance that the document will be read from or saved to disk, CD, etc. See this tutorial on character encoding for techniques and explanations. Using Direct Input mode: UTF-8 character encoding assumed Unlike the “by URI” and “by File Upload” modes, the “Direct Input” mode of the validator provides validated content in the form of characters pasted or typed in the validator's form field. This will automatically make the data UTF-8, and therefore the validator does not need to determine the character encoding of your document, and will ignore any charset information specified. If you notice a discrepancy in detected character encoding between the “Direct Input” mode and other validator modes, this is likely to be the reason. It is neither a bug in the validator, nor in your document. ↑ Top Validation Output: 10 Errors Line 1, Column 1: no document type declaration; implying "<!DOCTYPE HTML SYSTEM>" <html> ✉ The checked page did not contain a document type ("DOCTYPE") declaration. The Validator has tried to validate with a fallback DTD, but this is quite likely to be incorrect and will generate a large number of incorrect error messages. It is highly recommended that you insert the proper DOCTYPE declaration in your document -- instructions for doing this are given above -- and it is necessary to have this declaration before the page can be declared to be valid. Line 8, Column 16: element "HEADER" undefined <header> ✉ You have used the element named above in your document, but the document type you are using does not define an element of that name. This error is often caused by: incorrect use of the "Strict" document type with a document that uses frames (e.g. you must use the "Frameset" document type to get the "<frameset>" element), by using vendor proprietary extensions such as "<spacer>" or "<marquee>" (this is usually fixed by using CSS to achieve the desired effect instead). by using upper-case tags in XHTML (in XHTML attributes and elements must be all lower-case). Line 12, Column 13: element "NAV" undefined <nav> ✉ You have used the element named above in your document, but the document type you are using does not define an element of that name. This error is often caused by: incorrect use of the "Strict" document type with a document that uses frames (e.g. you must use the "Frameset" document type to get the "<frameset>" element), by using vendor proprietary extensions such as "<spacer>" or "<marquee>" (this is usually fixed by using CSS to achieve the desired effect instead). by using upper-case tags in XHTML (in XHTML attributes and elements must be all lower-case). Line 18, Column 17: element "SECTION" undefined <section> ✉ You have used the element named above in your document, but the document type you are using does not define an element of that name. This error is often caused by: incorrect use of the "Strict" document type with a document that uses frames (e.g. you must use the "Frameset" document type to get the "<frameset>" element), by using vendor proprietary extensions such as "<spacer>" or "<marquee>" (this is usually fixed by using CSS to achieve the desired effect instead). by using upper-case tags in XHTML (in XHTML attributes and elements must be all lower-case). Line 19, Column 56: there is no attribute "HEIGHT" <table class="pagina3" width="100%" height="100%" cellpadding="10"> ✉ You have used the attribute named above in your document, but the document type you are using does not support that attribute for this element. This error is often caused by incorrect use of the "Strict" document type with a document that uses frames (e.g. you must use the "Transitional" document type to get the "target" attribute), or by using vendor proprietary extensions such as "marginheight" (this is usually fixed by using CSS to achieve the desired effect instead). This error may also result if the element itself is not supported in the document type you are using, as an undefined element will have no supported attributes; in this case, see the element-undefined error message for further information. How to fix: check the spelling and case of the element and attribute, (Remember XHTML is all lower-case) and/or check that they are both allowed in the chosen document type, and/or use CSS instead of this attribute. If you received this error when using the <embed> element to incorporate flash media in a Web page, see the FAQ item on valid flash. Line 30, Column 74: there is no attribute "MINLENGHT" … <td><input type="Text" minlenght="6" name="gebruikersnaam"></td> ✉ You have used the attribute named above in your document, but the document type you are using does not support that attribute for this element. This error is often caused by incorrect use of the "Strict" document type with a document that uses frames (e.g. you must use the "Transitional" document type to get the "target" attribute), or by using vendor proprietary extensions such as "marginheight" (this is usually fixed by using CSS to achieve the desired effect instead). This error may also result if the element itself is not supported in the document type you are using, as an undefined element will have no supported attributes; in this case, see the element-undefined error message for further information. How to fix: check the spelling and case of the element and attribute, (Remember XHTML is all lower-case) and/or check that they are both allowed in the chosen document type, and/or use CSS instead of this attribute. If you received this error when using the <embed> element to incorporate flash media in a Web page, see the FAQ item on valid flash. Line 54, Column 64: value of attribute "TYPE" cannot be "NUMBER"; must be one of "TEXT", "PASSWORD", "CHECKBOX", "RADIO", "SUBMIT", "RESET", "FILE", "HIDDEN", "IMAGE", "BUTTON" … <td><input type="Number" name="leeftijd" min="1" max="150" ></t… ✉ The value of the attribute is defined to be one of a list of possible values but in the document it contained something that is not allowed for that type of attribute. For instance, the “selected” attribute must be either minimized as “selected” or spelled out in full as “selected="selected"”; a value like “selected="true"” is not allowed. Line 54, Column 86: there is no attribute "MIN" … <td><input type="Number" name="leeftijd" min="1" max="150" ></td> ✉ You have used the attribute named above in your document, but the document type you are using does not support that attribute for this element. This error is often caused by incorrect use of the "Strict" document type with a document that uses frames (e.g. you must use the "Transitional" document type to get the "target" attribute), or by using vendor proprietary extensions such as "marginheight" (this is usually fixed by using CSS to achieve the desired effect instead). This error may also result if the element itself is not supported in the document type you are using, as an undefined element will have no supported attributes; in this case, see the element-undefined error message for further information. How to fix: check the spelling and case of the element and attribute, (Remember XHTML is all lower-case) and/or check that they are both allowed in the chosen document type, and/or use CSS instead of this attribute. If you received this error when using the <embed> element to incorporate flash media in a Web page, see the FAQ item on valid flash. Line 54, Column 94: there is no attribute "MAX" … <td><input type="Number" name="leeftijd" min="1" max="150" ></td> ✉ You have used the attribute named above in your document, but the document type you are using does not support that attribute for this element. This error is often caused by incorrect use of the "Strict" document type with a document that uses frames (e.g. you must use the "Transitional" document type to get the "target" attribute), or by using vendor proprietary extensions such as "marginheight" (this is usually fixed by using CSS to achieve the desired effect instead). This error may also result if the element itself is not supported in the document type you are using, as an undefined element will have no supported attributes; in this case, see the element-undefined error message for further information. How to fix: check the spelling and case of the element and attribute, (Remember XHTML is all lower-case) and/or check that they are both allowed in the chosen document type, and/or use CSS instead of this attribute. If you received this error when using the <embed> element to incorporate flash media in a Web page, see the FAQ item on valid flash. Line 119, Column 16: element "FOOTER" undefined <footer> ✉ You have used the element named above in your document, but the document type you are using does not define an element of that name. This error is often caused by: incorrect use of the "Strict" document type with a document that uses frames (e.g. you must use the "Frameset" document type to get the "<frameset>" element), by using vendor proprietary extensions such as "<spacer>" or "<marquee>" (this is usually fixed by using CSS to achieve the desired effect instead). by using upper-case tags in XHTML (in XHTML attributes and elements must be all lower-case).
  10. I am sure I will eventually have a "oh yea" moment, but I am not there yet. This "client service" is effectively a endless loop. So with your second multiple small classes solution, maybe I first need to do UpdateDatabaseCommand, then I later need to do SomeOtherCommand, and then I need to do UpdateDatabaseCommand again. I've already created the UpdateDatabaseCommand object. I guess I "could" just create it again, but it seems excessive, and I am not sure how PHP deals with memory this being an endless loop and all. As an alternative, I guess I could store the newly created objects in another object, and check if they are set before creating? if (/* need to update database */) { $command = new UpdateDatabaseCommand($this->db, ...); } // execute $command
  11. Yea, I considered your "worst case" options, but as you suggest, they just seem wrong. Commands typically updates a database. A PHP implemented cron access that database upon initial runtime, and stores it in memory. When a command is received, not only is the DB updated, but the memory variable is updated as well. Commands also updates the time period of the cron (as well as the DB). Why I can create distinct Command objects at runtime? At first, I was going to say "I can't because I am using PHP as a service so a new distinct object is not created upon each request". But maybe I should rethink this. Maybe?
  12. Yea, that is what I said for WAY too long. Yes, you could create your own PHP based library and mimic a really good 3rd party library. And you can even review the twig (or whatever) source code for inspiration. But do you have the time and will you do so? If you are like me, you will make a decent (at least in my head) template engine which addresses your specific needs. But then those needs may change. If you have a very niche need, maybe spin your own. But if you are just rendering a webpage (and a good template engine can do more), then look into a 3rd party library. PS. I feel that PHP should add modern template functionality using a lower level language in the future.
  13. The noreply@yourdomain.dom is not ideal as the email recipient should and could reply to the email using the reply-to email. They just shouldn't reply to the from email. I've always thought that when receiving such an email, a reply would go to the noreply email. I've since tested it, and dropbox among others actually do as I wish to do and reply to the human sender, so maybe it is not so bad. Thanks
  14. Another option is you create your typical entire HTML page, but you include placeholders to insert custom HTML. You "could" then create custom PHP script to insert your custom content, but don't, and instead look into http://twig.sensiolabs.org/, http://www.smarty.net/, etc, etc. <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>myproject</title> <link rel="stylesheet" type="text/css" href="style.css" /> <script type="text/javascript" src="jquery-1.11.3.js"></script> <script type="text/javascript" src="javascript.js"></script> </head> <body> {{ content }} <div>Your footer on every page</div> </body> </html>
  15. Not sure I understand your question, so forgive me if you already know this. Every time the browser makes a request to the server, it should include the region name in the URL (maybe use a default region name if none provided, and be sure to use isset() or something to make sure it exists). You then get the data based on the region name, pass it to a template, and display it. $stmt = $conn->prepare('SELECT x,y,z FROM yourTable WHERE Region_Name=:Region_Name'); $stmt->execute(['Region_Name'=>$_GET['Region_Name']]); $rs=$stmt->fetch(); yourTemplate($rs);
  16. Thanks requinix, but can we back up a bit. How is Client injected into Commands? <?php $db = new \PDO("sqlite:".__DIR__."/db/datalogger.db"); $db->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); $logger = new \Monolog\Logger('my_logger'); $logger->pushHandler(new \Monolog\Handler\StreamHandler(__DIR__."/logs/client.log")); $commands=new Commands($client, $db, $logger); // Oops! $client yet doesn't exist! $client = new Client($commands); $client->start(); class Commands { protected $db, $logger, $client; public function __construct(Client $client, $db, $logger) { $this->client=$client; $this->db=$db; $this->logger=$logger; } public function foo(){} } class Client { protected $commands; public function __construct(Commands $commands) { $this->commands=$commands; } public function bar(){ $this->commands->foo(); } }
  17. Situation User sets up an account, assigns the account a unique account name, and enters his email. Note that user email must be unique across all accounts. User then enter his contacts along with the contact's emails and assigns each contact a unique username. Note that contact email must be unique for a given account. User then selects several (typically 10 or less) contacts and sends mass email. The email has a FROM email of usersName@mysite.com and a REPLY TO email of usersEmail@usersDomain.com. Problem Instead of replying to the email, email recipient copies and pastes the email displayed in his email client and generates a new email to send to the user, but the email is not delivered as usersName@mysite.com doesn't exist. Possible Solutions Make user educate recipients to reply to the email instead of copying and pasting the email. Not really an option. Somehow spoof the email client to display the user's real FROM email. Is this possible and still ensure that emails are not often blocked by spam filters? Make the FROM email usersName.accountName@mysite.com. Somehow use PHP to catch them emails, and create a new email to send to the user. Is this possible? Would having an email such as realEmail@mysite.com no longer be possible?
  18. Okay, I will merge the class. Thank you. No, the problem is not solved, just not committed twice. I wish to inject some object into another object where the injected object needs to be able to access some capabilities of the injecti (is that a word? Maybe I should use "recipient"?) object. But the injecti/recipient object does not exist when creating the injected object. Sorry for being obtuse.
  19. First to abstract. Hopefully now not not abstract enough
  20. Currently, I have three classes: Client, ClientApp, and Commands. Maybe I should only have two classes and combine Client and ClientApp? Commands does various commands and pretty much does its own thing, however, might need to send a message to the server using ClientApp::sendMessageToServer(), and (the whole reason for this post) needs to change the period which Client send data to server (i.e. ClientApp::work()). I feel I am doing some things just wrong. For instance, in ClientApp's constructor, I create another an object from Commands. Per dependency injection, shouldn't I create this object in the initial script, and inject it? But it needs to have access to the object which created it. And around and around I go... <?php require 'vendor/autoload.php'; use React\EventLoop\Factory; use React\Socket\Connection; use MyServer\ClientApp; $logger = new \Monolog\Logger('my_logger'); $logger->pushHandler(new \Monolog\Handler\StreamHandler(__DIR__."/logs/client.log")); $db = new \PDO("sqlite:".__DIR__."/db/datalogger.db"); $db->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); $client = new Client(new ClientApp($db, $logger)); $client->start(); <?php class Client { protected $app; public function __construct(ClientApp $app) { $this->app = $app; } public function start() { $host = $this->app->config->urlDestination; $port = $this->app->config->portDestination; $loop = Factory::create(); $app = $this->app; $this->server = @stream_socket_client("tcp://{$host}:{$port}", $errno, $errstr, STREAM_CLIENT_ASYNC_CONNECT); // periodically check connection to the server and recconect if connetion is lost $loop->addPeriodicTimer($this->app->config->reconnect_interval, function() use ($loop, $host, $port, $app) { if($this->server) { if(!isset($this->socket)) { echo 'Connection successful!' . PHP_EOL; $this->socket = new Connection($this->server, $loop); $app->onConnect($this->socket); $this->socket->on('data', function($data) use ($app) { dm('data: '.json_encode($data)); $app->onMessage($this->socket, $data); }); $this->socket->on('close', function() use ($app) { $app->onClose($this->socket); $this->socket->close(); unset($this->socket); $this->server = false; }); } } else { echo 'reconnect...' . PHP_EOL; $this->server = @stream_socket_client("tcp://{$host}:{$port}", $errno, $errstr, STREAM_CLIENT_ASYNC_CONNECT); } }); // periodically send data to server $loop->addPeriodicTimer($this->app->config->work_interval, function() use ($app) { $app->work(); }); echo 'Start Client ...' . PHP_EOL; $loop->run(); } } <?php namespace MyServer; class ClientApp { private $connect = false, $db, $logger, $commands; public $config; public function __construct($db, $logger) { $this->db = $db; $this->logger = $logger; $this->config=$this->getConfig(); $this->commands = new Commands($this->config, $db, $logger, $this); } public function onConnect($conn) { dm("onConnect"); $this->connect = $conn; $this->sendIdentifyCommand(); } function onMessage($conn, $msg) { $message = json_decode($msg); if($message && $message->cmd && $message->data && method_exists($this->commands,$message->cmd) && $message->cmd!='__construct') { $this->commands->{$message->cmd}($message->data); } else { dm('Invalid message :'.$msg,true); } } public function onClose($conn) { dm("onClose"); $this->connect = false; } public function work() { // Collect data and send it to the server } public function sendMessageToServer($msg) { if($this->connect) { $this->connect->write(json_encode($msg) . PHP_EOL); } } private function sendIdentifyCommand() { $this->sendMessageToServer([ 'cmd' => self::CMD_IDENTIFY, 'guid' => $this->config->guid, 'data' => true, ]); } }
  21. $obj1 is a react client which will initiate a socket to a server, perform a loop to send data to the server, and listen to that server and perform various tasks based on what it hears. Based on data received by listening to the server, the loop frequency can be changed (i.e. not only read-only but modification). I wish to move the task methods out of $obj1 regarding what the client should do based on the data received by listening to the server, and put them in $obj2. But the loop is in the encompassing object, so somehow I must modify $obj1 (aka client) from the $obj2 which was inserted into it (or consider a totally different approach). I was hoping not for react specific advice, but more general advice when an injected object needs to access the object which injected it.
  22. I would like to give obj2 some access to obj1 where obj2 is inserted into obj1. Ideally, I would like to do it once in perhaps obj2's constructor, but that will not work as obj1 is not defined when obj2 is defined. I suppose I could pass obj1 when I call obj2's methods, however, then I need to pass obj1 for every obj2 method which I would rather not do. Maybe I should set $this->obj2->obj1=$this in $obj1's constructor or use some sort of setter in $obj1? In addition, I don't wish to give $obj2 access to all of $obj1's methods or properties, but just the single method obj1Method2() and wish this method to have access to the properties and other methods in $obj1. I've included the following script to attempt to clarify what I am trying to do. Thanks <?php $obj1=new obj1(new obj2()); $obj1->obj1Method1(); class obj1 { var $obj1Prop1=123; public function __construct($obj2) { $this->obj2=$obj2; //Maybe??? $this->obj2->obj1=$this; } public function obj1Method1() { $this->obj2->obj2Method1($this); } public function obj1Method2() { $this->obj1Method3($this->obj1Prop1); } private function obj1Method3($o) { // } } class obj2 { public function __construct($obj1=null) { //$this->obj1=$obj1; //Won't work as $obj1 is not yet defined } public function obj2Method1($obj1) { $obj1->obj1Method2(); } }
  23. Never said they were evil, just that I have heard others say so. I've gone back and forth trying to form my own opinion. I've heard arguments against using them as it is more difficult to unit test. I've currently never really gotten into unit testing, so I don't have an opinion. Thoughts? Also, I don't have a reason to think so, but expect it would not be a good idea to initially set a database connection to a global or use dotenv. Thoughts? Thanks
  24. Seems a lot like a global variable, I always hear people saying how evil globals are.
  25. Thanks kicken, When "digging around", where do you normally start? Does one normally start on the interface code?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.