-
Posts
66 -
Joined
-
Last visited
Everything posted by 684425
-
Thank you sir, The issue is resolved. Your advice helped me. i am checking URLs now.๐
-
Thank you for your reply. For some invalid URLs i have created a class in php class Bootstrap{ private $controller; private $action; private $request; public function __construct($request){ $this->request = $request; if($this->request['controller'] == ""){ $this->controller = 'home'; } else { $this->controller = $this->request['controller']; } if($this->request['action'] == ""){ $this->action = 'index'; } else { $this->action = $this->request['action']; } } public function createController(){ // Check Class if(class_exists($this->controller)){ $parents = class_parents($this->controller); // Check Extend if(in_array("Controller", $parents)){ if(method_exists($this->controller, $this->action)){ return new $this->controller($this->action, $this->request); } else { // Method Does Not Exist echo '<h1>Method does not exist</h1>'; // This line can be changed, redirect to a method that exists return; } } else { // Base Controller Does Not Exist echo '<h1>Base controller not found</h1>'; // This line can be changed, redirect to a base controller that exists return; } } else { // Controller Class Does Not Exist echo '<h1>Controller class does not exist</h1>'; // This line can be changed, redirect to a controller class that exists return; } } } For the rest of invalid URLs an error message "Not found is thrown". I am thinking of handling this via htaccess because i am failed to find a solution for handling this via php.
-
I have URLs of my project on my localserver like localhost/shareboard/users/login in which (users is my sub directory and login is php file named login.php) I am already using the following htaccess rules for this Options +FollowSymLinks RewriteEngine on RewriteRule ^([a-zA-Z]*)/?([a-zA-Z]*)?/?([a-zA-Z0-9]*)?/?$ index.php?controller=$1&action=$2&id=$3 [NC,L] Is there a way of removing sub directory only from URLs without changing above htaccess? or some other idea that gives result as localhost/shareboard/login (In my php code i am using the above address in hyperlinks as <a href="<?php echo ROOT_URL; ?>users/login">Login</a> And the following lines are added in my config.php file define("ROOT_PATH", "/shareboard/"); // I am using this one for linking files define("ROOT_URL", "http://localhost/shareboard/"); // and using this one in hyperlinks Please guide me if there is a possible solution for what I want to do. Thanks๐
-
Project works on local server but not on live server
684425 replied to 684425's topic in PHP Coding Help
Thank you for reply, From log file I found the issue and resolved it -
Following a tutorial on udemy, i tried to learn the very basics of mvc structure. I built the same project on my local server and it worked without giving me any error. but when i tried it on live server. its not working as it should. not showing any error. I tried to figure out the problem and found that for every page loading, it stops at the same line in my main.php file. <?php require($view); ?> starting from the above line. it stops. i came here to share my problem but i am unable to upload my files here. if there is a way to upload and share my files, please guide. zip file size of the whole project is 31.6 kb
-
I have created a session array on one page and stored some values as $_SESSION['users'] = array( "id" => $row['id'], "fname" => $row['ufname'], "lname" => $row['ulname'] ); and then on another page I have some more values for the same session array "boss" => $row['bossid'], "tasks" => $row['tasks'], "timeframe" => $row['tframe'] I want to add these values into session array both keys and values. is there any way of doing this? Please help
-
I have date stored in database in any of the given forms 2020-06-01, 2020-05-01 or 2019-04-01 I want to compare the old date with current date 2020-06-14 And the result should be in days. Any help please? PS: I want to do it on php side. but if its possible to do on database side (I am using myslq) please share both ways๐
-
Random records from one table based on a row from other table
684425 replied to 684425's topic in MySQL Help
Sir, I am following your advice. I have normalized my database and now I am working on app to remove errors that is why my reply is late๐ -
Random records from one table based on a row from other table
684425 replied to 684425's topic in MySQL Help
SELECT tbl1.pay AS bpay, tbl2.grade AS t1, tbl3.grade AS t2, tbl4.grade AS t3, tbl5.hours1 AS d1, tbl6.hours2 AS d2, tbl7.hours3 AS d3 FROM employees AS tbl1 LEFT JOIN employees AS tbl2 ON tbl1.time1 = tbl2.id LEFT JOIN employees AS tbl3 ON tbl1.time2 = tbl3.id LEFT JOIN employees AS tbl4 ON tbl1.time3 = tbl4.id LEFT JOIN overtimes AS tbl5 ON tbl2.grade = tbl5.ranks LEFT JOIN overtimes AS tbl6 ON tbl3.grade = tbl6.ranks LEFT JOIN overtimes AS tbl7 ON tbl4.grade = tbl7.ranks WHERE tbl1.id = 67 The above query returns result including red highlighted values which I am trying to remove -
From tables shown in image, I am trying to run a query for employee 67 which return only one row containing id, pay from employee table and from overtime table i want to choose values from columns hours1, hours2, hours3 based on references mentioned in employees table. I have highlighted the values in both tables for which i want to run the query.
-
I was not sure whether i should separate them or not, but after your advice i separated them ๐
-
Sir, your query worked as expected but last day after posting my problem here i searched for the solution. From w3schools i found one example in SELF JOIN. SELECT A.fname AS yourname, B.fname AS yourbossname FROM employee A, employee B WHERE A.boss_id = B.id Not challenging your knowledge and your experience but just for increasing my knowledge. Do both LEFT JOIN and SELF JOIN are same in working or is there any difference in both? PS: if its up to you, which one you would like to prefer?๐
-
I have an employees table which stores id as auto increment values, names of employees and boss id chosen from the same table. I want to run a query which shows result as Hi Jane Doe, your BOSS is John Doe But it seems beyond my knowledge. Any help please? I have attached image of similar data
-
Thank you for your help. With some modification, it works fine ๐
-
In some countries 123456789 amount of currency of in general, it is counted as (if i am not wrong) one hundred twenty three million, four hundred fifty six thousand, seven hundred and eighty nine. Comma separated format is 123,456,789 But in some countries (like mine) the same amount is counted as twelve crore, thirty four lac, fifty six thousand seven hundred and eighty nine. Comma separated format is 12,34,56,789 As we people are used to the second format that is common here, the thousands separated format mostly confuses us in reading.
-
In php number format function works like.... number_format("1000000",2); // 1,000,000.00 is there a way to format numbers like... 10,00,00,000 (from right. No decimal. First comma after 3 digits and then commas after every 2 digits)
-
The code in attached file is not working for me. and i am failed to find any mistake. Anyone help me please. deletedept.php
-
Plz check attached file. it does not give any error when letters are typed. new.html
-
<input id="numb" type="number" /> <input type="submit" onclick="myFunction()" /> <p id="demo"></p> <script> function myFunction(){ var x = document.getElementById('numb').value; var regex=/^[1-9]+$/; if (x == ""){ document.getElementById('demo').innerHTML = "Input is Missing"; } else if (!x.match(regex)){ document.getElementById('demo').innerHTML = "Input Incorrect"; } else { document.getElementById('demo').innerHTML = "Input OK"; } } /* if (x == "") { document.getElementById('demo').innerHTML = "Input is Missing"; } else if (isNaN(x)) { document.getElementById('demo').innerHTML = "Input Incorrect"; } else { document.getElementById('demo').innerHTML = "Input OK"; } } */ </script> When input type is "text" it works fine. but when i change input type to "number" and then if i type letters or letters plus numbers. it says "input missing" How can i get correct output while using input type "number" ? Please guide. Thankyou.