PHP - Php Define Not Working With Jquery Load
I have a main file index.php into which iam loading myinnerpage.php. I have defined a variable inside index.php & checks it on myinnerpage.php, but when i load innerpage it shows restricted access, any idea why? following is my code.
index.php Code: [Select] <?php define( '_JEXEC', true ); ?> <div class="mypage"> </div> <ul> <li><a href="#" onclick="loadpages('myiinerpage.php')">about page</a></li> </ul> <script type="text/javascript"> var $jq = jQuery.noConflict(); function loadpages(page) { $jq('.mypage').load('myfolder/'+page); } </script> and now in the myiinerpage.php which is in the folder myfolder i have the following code. Code: [Select] <?php defined('_JEXEC') or die('Restricted access'); ?> <div> my page elements </div> but when i click on the link it shows restricted access. I have loaded jquery too, any idea y this is happening? Similar TutorialsHi all. My first post, I haved scoured the web for answers to this, have not come up with anything useful so far. I am also finding it hard to explain my problem well I suppose. None the less - here goes ! Im not a professional dev, nor do i claim to be. I have learnt everything I know about php and jquery from folks like yourselfs, youtube and various other online documentation. I am unable to show you the live code as the website is internal unfortunately. The "issue" I am building a dashboard to monitor the status of Ms Exchange 2010 queues, Exchange backup status and AD replication. I have an index.php file in the root folder. There are an img,css,js and lib folders. Then there is a folder called "X" for argument sake - this is the company folder and contains subfolders - one for each product, so there is a "exchange" folder and an "ad" folder For exchange and ad folders, they both have their own css,js,img and lib subfolders and can be accessed independently from the main index.php file in the root, so they are complete websites in themselfs if you were to connect to the index.php of the "exchange" and "ad" subfolders? What I am doing now is making the root index.php act as some sort of "summary" view for those "backend" web pages. What I'm trying to accomplish is to enable a link on the root index.php file that will use Jquery's load() method to use ajax to load parts of the "exchange" and "ad" pages depending on whic link I clicked, so for example, if i were to click the "exchange" link it must load only the bit that shows me what the queues are doing. On the full backend page it will show the queues and also the backup status. The problem is that this backend index.php on the exchange folder has some PHP includes defined in the index.php. The paths to these files are abviously already set. My main issue is that as soon as I load the exchange index.php using ajax load(), i lose all css and js functionality which makes the exchange page dynamic in the first place. I just cannot figure out how to handle already existing css,js and php includes on the backend and load them with ajax on my front page without losing functionality. I appologise in advance if this makes no sense at all, but I really need to wrap my head around this. Thanks so much for your help. Hi all, I was reading a bit in the manual about the defined function. Since i have seen it being used quite a lot to disallow direct access. But one of the comments made me think if there are any alternatives to get the same. it's this comment: http://www.php.net/manual/en/function.defined.php#89886 If i read it correct it tells that defined() seems to be pretty slow. I was thinking, if that is the case what are the alternatives... Does anyone know how to interpret this comment and if there are alternatives? I am not yet a guru tofully understand the results. cheers! In many cases, variable have to be explicitly defined for whatever reason. However, often it is not required for a simple web page script. Yet, even in those cases, if a variable is NOT explicitly defined, the web server error log (example: my_domain.com-error_log) will rack up a lot of entries such as this: Quote [Fri Dec 31 01:31:43 2010] [error] [client 123.123.123.123] PHP Notice: Undefined variable: some_variable_name in /home/my_domain/public_html/some_page.php on line 6 A busy site could result in large error logs... What is considered "best practice"? Should all variables always be explicitly defined with the var key word? Hello there, I have a script which uses the LOAD DATA LOCAL INFILE command see below: <?php //connect to your database mysql_connect("localhost", "xxx", "xxx"); //(host, username, password) //specify database mysql_select_db("xxx") or die("Unable to select database"); //select which database we're using // Build SQL Query $query = "LOAD DATA INFILE '/public_html/admin/files/test-jp-stock.csv' INTO TABLE 'jpaero_stocksearch' FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n' IGNORE 1 LINES"; if(mysql_query($query)){ echo ">> New Stock Data has now been uploaded. Database is now live and searchable.";} else{ echo "Upload failed. Please contact support.";} ?> Initially I uploaded the csv file through phpmyadmin and everything worked fine - so I then used the SQL generated inside my script, changing the location to where the file actually is - however now nothing happens at all. Any ideas on whats gone wrong, gratefully received! Thanks, This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=345904.0 I am trying to make a simple vertical scrolling slideshow type page. I have 1 div that is 100% width and height of the body and inside that 4 divs that are 100% w&h one below the other. In each "slide" div is an input button with an onclick call to a JavaScript function that uses jquery animate and scrolltop to move to the next div. Moving from the first to second is OK. It will not move from second to third. If I set each inner divs height to 90%, I can see the third div's next button. Clicking that moves the third slide to the top, though it is supposed to move the forth slide to the top. Not sure what I'm missing? I hope my attempt to paste the code on my note 3 works OK! Thanks for even looking! Nick <code> <html> <head> </head> <body style="margin:0px;padding:0px;"> <style> .a_slide { width:100%;height:100%;background-color:blue; } .b_slide { width:100%;height:100%;background-color:green; } .c_slide { width:100%;height:100%;background-color:blue; } .d_slide { width:100%;height:100%;background-color:green; } </style> <div style="width:100%;height:100%;overflow:hidden;margin-left:auto;margin-right:auto;" id="container" name="container" class="container"> <div class="a_slide" id="a_slide">a <input type="button" onclick="move(this.name);" name="b_slide" value="Next Page"> </div> <div class="b_slide" id="b_slide">b <input type="button" onclick="move(this.name);" name="c_slide" value="Next Page"> <input type="button" onclick="move(this.name);" name="a_slide" value="top"> </div> <div class="c_slide" id="c_slide">c <input type="button" onclick="move(this.name);" name="d_slide" value="Next Page"> <input type="button" onclick="move(this.name);" name="a_slide" value="top"> </div> <div class="d_slide" id="d_slide">d <input type="button" onclick="move(this.name);" name="a_slide" value="top"> </div> </div> <script type="text/javascript" src="http://ajax.googleap...n.js"></script> <script type="text/javascript"> function move(to_who) { $('.container').animate({scrollTop: $("."+to_who).offset().top},'slow'); }; </script> </body> </html></code> Hi,
what I'm tryng is to append a table row with associated jquery code...
I have a jquery code just like this
<script type="text/javascript"> jQuery(function($) { var rowCtr = 0; $('.addRow').click(function(){ $('#tableID > tbody:last').append('<tr name="rowEq['+rowCtr+']" id="rowEq['+rowCtr+']"><td>'+ '<select id="stype'+rowCtr+'" name="rowData['+rowCtr+'][equipment_type]">'+ '<option value="0"> -- </option>'+ '<option value="1"> Type 1 </option>'+ '<option value="2"> Type 2 </option>'+ '<option value="3"> Other </option>'+ '</select>'+ '<input id="other_type'+rowCtr+'" type="text" name="rowData['+rowCtr+'][other_type]">'+ ); $('#stype'+rowCtr).change(function() { if(jQuery('#stype'+rowCtr).val() == '3') { jQuery('#other_type'+rowCtr).show(); }else{ jQuery('#other_type'+rowCtr).hide(); } }); if(jQuery( '#stype'+rowCtr ).val() != '3') { jQuery('#other_type'+rowCtr).hide(); } rowCtr++; }); }); </script>And html like this.. <input type='button' class='addRow' value="Add Row"> <form> <table id="tableId"> <thead> <tr> <th> Type </th> </tr> </thead> <tbody> <tr> <td> dummy text.. </td> </tr> </tbody> </table> </form>The appending is ok but the hidding/showing of "other_type" field is not working. It always hide "other_type" field even if I already selected the 'other' option. tbl1.png 3.38KB 0 downloads I'm having a problem and need an answer to why its happening and how to prevent it. Scenario: I begin load my home page which starts with a session_start(); .... Before it FULLY completes loading I try to navigate to another page and BOOM, that page will not load and any other page that begins with session_start(); will not load unless I close and restart the entire browser or wait about 10 minutes.... I will note my website makes ajax calls every 5 seconds or so, but I use setTimeout for them. Any help??? Thanks ahead! I have at the very top of my web page the following. Not inside any function in case that would have a scope issue. Define ('GROUP', '1'); Define ('ROUNDOF16', '2'); Define ('QUARTERFINAL', '3'); Define ('SEMIFINAL', '4'); Define ('FINAL', '5'); Lower down I have if($Round == 5) This works but this if($Round == FINAL) has error Parse error: syntax error, unexpected T_FINAL in ....... I thought this was correct ! Hi, I have the define(); function where i need to put the variable for directory name which is relative ... How to do that ... Code: [Select] <?php if (TARGET_PLATFORM == FILE_SYSTEM_PLATFORM) { /** * if FILE_SYSTEM_PLATFORM is selected as TARGET_PLATFORM, * then assign root folder adress to FILE_ROOT macro */ define("FILE_ROOT", "$diro"); } public function __construct($fileRoot) { if (is_dir($fileRoot)) { $this->fileRoot = $fileRoot; //if ($this->fileRoot[strlen($this->fileRoot) - 1] != '/' ) { // $this->fileRoot .= '/'; //} } else { die($fileRoot .' is not a directory '); } } ?> When i go with this, it says this: " 'dir name ' is not a directory". But I need the variable for this to work as I want to. Does anyone have an idea? To make it clear, this is only the small part of code, which is a part of the directory root for the directory tree. Ive got a simple function that's counting percentages of the results, and what I want is when the first line does $variable / 100 - to go on 2 decimals(ex. 0.72142141 what I want is to write 0.72). Code: [Select] function postotak(){ $p = $bodovi / 100; $postotak = $p * 100; Imagine a site programmed using full OOP. Where would you store information like this: $companyName = "ABC Ltd"; $companyPhone = "02476 999 999"; $companyAddress etc... Would you just define them in the public scope? (and use global or pass them in when needed??) Is there a better way? They will be needed in more places than just a navigation bar and would be needed by more than one class. i tried googling but didnt really know how to "google it" as i cant think of a short phrase that best describes it.. but i want to chance the database setting of "localhost" in my php script to another websites database how do i acheive this? im having a problem getting this code to work...i know it may not make sence why i would do this but it is for a larger script...is there any reason why it wont echo please? define ('TEST_VAR', 'hello'); $var = "TEST"; echo {$var}_VAR; im doing it wrong can some one help me ? , thanks { Code: [Select] define('userlevel'( 9="admin" , 1="guest"));} <HTML> <?php $arr = array("sue" => "betsy", "frank" => "marge"); ?> </HTML> This produces the following HTML page: "betsy", "frank" => "marge"); Its like when I use the => to make my associative array, the code thinks I'm closing the php codeblock and then just prints the rest of it to the screen... I am trying to use absolute path across my project excluding the domain as of now and I am trying to do it as follows: Code: [Select] define('root', '/php_projects/myproject/'); // The Standard Data $path = "path.php"; $connectvars = "connectvars.php"; // The CSS Styles $reset_css = root . "view/reset.css"; $style_css = root . "view/style.css"; This works so far, the only problem I am having is that it is producing a notice. And my question is, how can I get rid of the notice? The notice is this one: Code: [Select] Notice: Constant root already defined in C:\xampp\htdocs\php_projects\myproject\path.php on line 3 Why does the notice get produced in first place? I never defined it twice, as it states. Hi , how I can save something into form? I mean , insert something in variable and than insert it into value in the form so when i send the form the value will be send too. I also want that it will be can not change. for example : <input name="email" value="a@s.d"/> but this example can be change if you insert something else. thanks , Mor. I'm being told I have an undefined variable. Similar to sumUsagekWH (in the code below) there are other placeholders called sumUsageKHW, sumUsageWKWp, sumUsageWKWi and so on. Each script of code looks similar to below where the 'totalUsage' is added into sumUsageKHW, sumUsageKHE and so on. All references are highlighted red below to make it easier to follow.
So, if I am only using these sumUsagesXXXX's as placeholders for the following post....
<input name="electric_charge_total" type="hidden" id="electric_charge_total" value="<?php echo number_format($basic_charge + ($sumUsageKWH * $energy_charge) + ($sumUsageWKWp * $peak_rate) + ($sumUsageWKWi * $intermediate_rate) + ( ($sumUsageWKW+$sumUsageWEW) * $base_rate),"2"); ?>" align="right"/>
how to I define them in PHP?
Based on the code below, they are only used as a way to introduce totalUsage ( it looks silly the way it was done, but later the code will be expanded so it makes sense). What I mean is that totalUsage is being entered (in the below case) into sumUsageKWH from the $sumUsageKWH += $row[totalUsage]
Notice: Undefined variable: sumUsageKWH in C:\xampp1\htdocs\Utrack\invoice.php on line 73
<?php $sql = ";WITH TOTAL_KWH_WINTER AS ( SELECT CONVERT(VARCHAR(10),cdate,111)AS trans_date, datepart(hh, cdate) as trans_hour, comm_id, MIN((total_energy_a+total_energy_b+total_energy_c)/100) AS minUsage, MAX((total_energy_a+total_energy_b+total_energy_c)/100) AS maxUsage, meter_multiplier FROM [radiogates].[dbo].[purge_data] LEFT OUTER JOIN [radiogates].[dbo].[ops_invoice] on [radiogates].[dbo].[purge_data].[comm_id] = [radiogates].[dbo].[ops_invoice].[meter_id] where comm_id='$comm_id'and meter_multiplier is not null group by comm_id, CONVERT(VARCHAR(10),cdate,111), datepart(hh, cdate), meter_multiplier ) SELECT *, datepart(weekday, trans_date) as trans_date_day, datepart(month, trans_date) as trans_date_month, ((maxUsage - minUsage)*meter_multiplier) as totalUsage FROM TOTAL_KWH_WINTER where datepart(weekday, trans_date) IN ('1', '2', '3', '4', '5', '6', '7') AND DATEPART(MONTH, trans_date) IN ('10','11','12','1','2','3','4') and trans_date BETWEEN '$startdate2 00:00:01' AND '$enddate2 24:00:00' "; $query = sqlsrv_query($conn, $sql); if ($query === false){ exit("<pre>".print_r(sqlsrv_errors(), true));}while ($row = sqlsrv_fetch_array($query)) { $sumUsageKWH += $row[totalUsage];}sqlsrv_free_stmt($query);?> How come I cannot do this? define('IMG_EXT', array("jpg", "jpeg", "png", "gif", "bmp", "tif"), true); |