The Venkman debugger says this:
$("#aboutbox") is null
[Break On This Error] $("#aboutbox").hide();
But I don't know what to do to fix it!
It worked perfectly in HTML: http://leventhan.webfactional.com/static/
But when I moved it to PHP, it just stopped working.
Here's the index.php:
<?php
require_once dirname(__FILE__)."/src/phpfreechat.class.php";
$params = array();
$params["title"] = "Quick chat";
$params["nick"] = "guest".rand(1,1000); // setup the intitial nickname
$params['firstisadmin'] = true;
//$params["isadmin"] = true; // makes everybody admin: do not use it on production servers ;)
$params["serverid"] = md5(__FILE__); // calculate a unique id for this chat
$params["debug"] = false;
$chat = new phpFreeChat( $params );
?>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<title>phpFreeChat- Sources Index</title>
<link rel="stylesheet" title="classic" type="text/css" href="style/styles.css" />
<link rel="stylesheet" title="classic" type="text/css" href="style/content.css" />
<script type="text/javascript"src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="jquery-1.4.4.min.js"></script>
<SCRIPT type="text/javascript" src="oracle.js"></SCRIPT>
<script type="text/javascript">
// some google maps javascript code that works fine
</script>
</head>
<body>
<header>
<div id="aboutbox">
<br>
<p><strong>GeoChat is the perfect chat app to hatch your world domination plans. A place on the web where you can point to maps and chat at the same time.
A great way for teachers to teach and students to learn with an interactive map. </strong></p>
</div>
<div id ="nav">
<h1>GeoChat</h1><h2>Toggle backgroundChat HelpWhat's all this about?</h2>
</div>
</header>
<div id="map_canvas"></div>
<div class="content">
<?php $chat->printChat(); ?>
<?php if (isset($params["isadmin"]) && $params["isadmin"]) { ?>
<?php } ?>
</div>
<footer>
<p>❤ Made by <strong>Author</strong> with love.Go up ↑</p>
</footer>
</body></html>
Here's the live broken site: http://leventhan.webfactional.com/phpfreechat-1.3/
EDIT: Yeah, jQuery worked again when I commented out the chat app (phpFreeChat), this part:
<div class="content">
<?php $chat->printChat(); ?>
<?php if (isset($params["isadmin"]) && $params["isadmin"]) { ?>
<?php } ?>
</div>
And it turns out the problem is really because jQuery is conflicting with Prototype.js (phpFreeChat uses Prototype apparently.) The solution is to use:
jQuery.noConflict();
Edit: Oh, that is actually in your static version, so the static versions seems to be broken. Given this, it is impossible to tell what does not work in your PHP version.
I get an error
oracle.js:4 Uncaught ReferenceError: hide is not defined
The line where the error is thrown is
$("#aboutbox").live(hide());
Maybe you meant $("#aboutbox").hide(); ?
It worked!
It was jQuery and Prototype not getting along with each other.
Here's what I did:
add:
jQuery.noConflict();
change all occurences of:
$(document).ready(function(){
to:
jQuery(document).ready(function($) {
in my external js do a find and replace.
find: $
replace: jQuery (case sensitive).
I am seeing an error here (Chrome)
function showInDiv(text)
{
var sidediv = document.getElementById('content_window');
sidediv.innerHTML = text; // Cannot set property 'innerHTML' of null
}
What's content_window? I could not find it on the page
Related
I'm getting weird results when trying to kind of make a "templating engine". Basically, I want to be able to use PHP variables that contain data from an SQL database.
What happens is that everything works properly with the PHP side, what does not is the page that needs to display this information (index.php).
I'm working on a way to get the website's name from the sql database, so I have something like that on my index:
<?php
include ('php/data/sitename.php');
?>
<!DOCTYPE html>
<html>
<head>
<title><?php echo $sitename; ?> - Home</title>
<!--Import Google Icon Font-->
<link href="http://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<!--Import materialize.css-->
<link type="text/css" rel="stylesheet" href="css/materialize.min.css" media="screen,projection"/>
<!--Let browser know website is optimized for mobile-->
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
</head>
<body>
<div class="container">
<!-- HEADER: Navbar -->
<?php $navbar; ?>
<!-- MAIN: Index Page contents -->
<?php $page_index ?>
<!-- FOOTER: Footer -->
<?php $footer; ?>
<?php $sitename; ?>
</div>
<!--Import jQuery before materialize.js-->
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="js/materialize.min.js"></script>
</body>
</html>
This variable comes from a file (that has been included) called sitename.php, with the following code:
<?php
include ('../db.php');
$sql = "SELECT id, sitename FROM GeneralData";
$getname = mysqli_query($conn, $sql);
if ($getname->num_rows > 0) {
while($row = $getname->fetch_assoc()) {
$sitename = $row['sitename'];
echo $sitename;
}
}
?>
Yes, I used echo $sitename;, I know it wont echo the actual data, but I did it to test some things, and here are the results:
Including the file sitename.php to index.php will do nothing, it would be like if it did not exist. However, if I write "echo "123";" on it, it will echo 123 on index. What does not work is what I need.
If I go to sitename.php directly, it will simply output the correct SQL value I requested because I told it to echo (as I stated before). But, it wont work in index, it will simply not work.
Also, I'll leave my project structure here. It might help.
What can I do?
Thanks in advance!
try set GLOBAL for sitename
GLOBAL $sitename;
or
GLOBALS['sitename'];
$sitename = ...
EDIT
try use
$path = $_SERVER['DOCUMENT_ROOT'];
$path .= "/yourpath/yourfile.php";
include_once($path);
I am making a textEditor website just for fun for me and I got most of what I am going to do down. But now, I am wondering I am having issue with a transfer of data by _GET method in php and won't write to my files if it is < (<). It has to be < for some odd reason. Is there an easy method to override this when it transfer it? I could find some way, but wanted to know if there was a simple way.
EDITOR FILE:
<html>
<head>
<title>Web Editor</title>
<link href="controller.css" rel="stylesheet"/>
<script type="text/javascript" src="script/editor.js"></script>
</head>
<body>
<div class="platform">
<div class="head"><div class="file"><p>File: <div id="file">hello.html</div></p></div></div>
<div class="hotbar"><img src="images/save.png" class="hotbarImage" onClick="save()" />
</div>
<div class="editor"><div contenteditable="true" style="height:100%; overflow:scroll;" id="editPad" ></div></div>
</div>
</body>
</html>
PHP FILE:
<?php
$dir = $_GET['dir'];
$data = $_GET['data'];
$f = fopen($dir,"w");
fwrite($f,$data);
fclose($f);
?>
SAVE JS FILE:
function save() {
var dir = document.getElementById("file").innerHTML;
var data = document.getElementById("editPad").innerHTML;
window.location = "save.php?dir="+dir+"&data="+data;
}
It's not complete just cause I started today, but was working on some of the basics functions.
html_entity_decode('<')
I have created a function inside of my jquery mobile code. its working fine locally. But in the server where I have hosted its not working properly.
please help
Here is a sample code
<!DOCTYPE html>
<html>
<head>
<title>Site title</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" href="images/scbd.ico">
<link rel="stylesheet" href="css/themes/default/jquery.mobile-1.1.0.css" />
<link rel="stylesheet" href="docs/_assets/css/jqm-docs.css"/>
<script src="js/jquery.mobile-1.1.0.js"></script>
<script src="js/jquery.js"></script>
<script src="docs/_assets/js/jqm-docs.js"></script>
</head>
<body>
<div data-role="page" class="type-index">
<div data-role="header" data-theme="f">
<h1 id="jqm-logo"><img src="images/logo.png"></h1>
Home
</div><!-- /header -->
<div id="header_rightpart">
<a name="header"><h2>sfdshsjdhfjdsh</h2></a>
</div>
<?php
here I have written the function
?>
But there is nothing wrong with the function its working fine in the local machine. But cant understand why it is not working in the server. I am getting error "error loading page". Is it just because of using multipel php tag?? I mean I have used <?php ?> twice in the page. Please help me to find out the solution
I have got the solution. I declared a variable like $names=[]; it did not work on my server. That was reason behind the error. I think this was because of php version. Sever php version was 5.2.17 and my local is 5.4.7 so it worked fine on local machine. But something was wrong with server php version.
function f_do ($rootname)
{
$query = "SELECT course_name FROM onlinecourses WHERE root_name = '$rootname'";
$result = mysql_query($query);
$num = mysql_num_rows($result);
//$names=[]; this caused error
//$row=[]; this caused error
if($num > 0)
{
while($row =mysql_fetch_array($result))
{
$names[] = $row['course_name'];
}
}
return $names;
}
commented part shows the variable.
I've been attempting to use jquery and jqueryui to make tabs on my website. However, I can't seem to get them to work. The main page is in PHP, and I am using the Codeigniter framework. If the page fully renders, then the tabs won't work. If I change something that creates a fatal error in the php the tabs appear. While I was attempting to figure out what was going on I created a very basic page with only the jquery demo script, and it wouldn't work either. If it makes any difference, I am hosting on HostGator.
Please advise.
Header:
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Sign Up!</title>
<link rel="stylesheet" href="<?php echo base_url();?>css/style.css" type="text/css" media="screen" />
<link rel="stylesheet" href="<?php echo base_url();?>css/jquery-ui-1.8.11.custom.css" type="text/css" media="screen" />
<!-- Java includes -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.11/jquery-ui.min.js" type="text/javascript"></script>
</head>
<body>
<div class = "header">
<span class="nav_bar"><?php if($this->session->userdata('is_logged_in')){ echo 'Welcome, ' . ucfirst($this->session->userdata('first_name')). " " . ucfirst($this->session->userdata('last_name')) . ' | ' . anchor('site/logout' , 'Logout');} else { echo anchor('site/is_logged_in', 'Login');} ?></span>
</div>
<div class="content">
Body:
<!-- Tab Script -->
<script>
$(function() {
$( "#tabs" ).tabs();
});
</script>
<!-- end Tab Script -->
<div id="tabs">
<ul>
<li>All Contacts</li>
<li>Place Holder Tab</li>
</ul>
<div id="tabs-1">
<?php $this->load->view('all_contacts_tab_view'); ?>
</div>
<div id="tabs-2">
Place Holder tab
</div>
</div>
Footer:
</div> <!-- end content div -->
<div class="footer">
<div class="footer_left">
<div id="copyright"> © 2011 NetworkIgniter. All rights reserved. NetworkIgniter, networkigniter.com and the all designs are trademarks of NetworkIgniter. Created with CodeIgniter and hosted on HostGator.</div>
<div id="legal">Terms and Conditions | Privacy Policy</div>
<div id="benchmarking">{elapsed_time} | {memory_usage}</div>
</div>
</div>
</body>
</html>
I did track down a java error after all, but I'm not sure how to fix it.
Error: $("#tabs").tabs is not a function
Line: 23
it looks like your calling tabs before it generated I would put that in doc ready
$(document).ready(function() {
$( "#tabs" ).tabs();
});
Figured it out.
It was the Google tracking script at the end. It was claiming the $. the reason why it was working when php crashed was because it wasn't getting down to the footer where the Google script was.
Errors on tabs are often due to a missing end of tag such as a </div> or </li> or whatever. Check the code generated by the PHP script to see if everything's fine. You might wanna use the Developper Tools Plugin on FireFox to detect any validation problems (including the missing tags).
Hello friends a newbie question...
The Issue is like this:
I have a static HTML file and I want to import just a portion of that file into another page. How can I do that.
Example Code:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Some title here</title>
<link rel="stylesheet" type="text/css" href="styles.css" />
</head>
<body>
<div id="box-1">
<div class="block">
<!-- Some code here -->
</div>
</div>
<div id="box-2">
<div class="block">
<!-- Some code here -->
</div>
</div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script src="script.js"></script>
</body>
</html>
Now what I want is to read this HTML file and import just this bit:
<div id="box-1">
<div class="block">
<!-- Some code here -->
</div>
</div>
Is there a way of doing it?
Kindly help.
Even a PHP, jQuery, Ajax or any other solution will also do. Please help me.
You can use jQuery's load() to specify only a certain container to be loaded:
$('#targetdiv').load('static.html #box-1');
Here's a solution that differs from the others: It performs a one-time import of a section of content from a large number of static html files/pages (in case that was what you were wanting). I used it successfully to import about 700 pages from straight html to a cms database.
// get the pages you want to import
$pages = array('page1.html',
'page2.html',
'page3.html'
);
foreach($pages as $p) {
$url = 'http://yourDomain.com/' . $p;
// load the webpage
$file = file_get_contents($url);
if($file) {
list($before,$content) = explode('<body>',$file); // chop off beginning
unset($before);
list($content) = explode('<div id="box-2">',$content); // chop off end;
$resultArray[] = trim($content);
// or do it this way to keep the filename associated with the content
// $resultArray[$p] = $content;
}//if file
} //endforeach;
// $resultArray holds your stripped content
// do something with $resultArray;