JQuery and PHP connection


I had this problem. I’ve never seen anything like this before….

There is a site half of which is written in jQuery and just Javascript. Now I have a task to connect the java script part with the php code.
I just started doing this when I got into a complete stupor. When I write the following lines of php code (whether before or after including jQuery in the html):

$db1 = mysql_connect ('localhost', 'root', 'root_pass');
mysql_select_db ('site_62', $db1);

ALL PART of jQuery just stops working for me. And this code, as you can see, does not output anything. And the output of errors on the server is disabled (display_errors = Off). But when I select the database the whole jQuery part stops working and the javascript WORKS like it used to! Moreover, if you write this php code further, then it works fine: it selects the necessary records for me from the table. And jquery, no matter how strange it sounds, starts working only if this part of the code is commented out. The exact same thing happens when you add the line:

ini_set('display_errors', 1);

But there is only one difference here: if you write 0 instead of 1 in the second argument of this function, then jquery works, and if you write one (i.e. change the global value on the server), then it stops working…

Here’s how I declared the use of jQuery (I didn’t do it):

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />
<link href="css/main.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="index/index.css">
<link rel="stylesheet" type="text/css" href="modalbox/modalbox.css">
<!--[if IE 7]>
<link href="css/ie7.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="jQuery/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="jQuery/ui/jquery.ui.core.js"></script>
<script type="text/javascript" src="jQuery/ui/jquery.ui.widget.js"></script>
<script type="text/javascript" src="jQuery/ui/jquery.ui.progressbar.js"></script>
<script type="text/javascript" src="jQuery/ui/jquery.effects.core.js"></script>
<script type="text/javascript" src="jQuery/ui/jquery.effects.fold.js"></script>
<script type="text/javascript" src="jQuery/jquery.betterTooltip.js"></script>
<script type="text/javascript" src="jQuery/jquery.backgroundPosition.js"></script>
<script type="text/javascript" src="jQuery/jquery.ui.mouse.js"></script>
<script type="text/javascript" src="jQuery/jquery.ui.slider.js"></script>
<script type="text/javascript" src="jQuery/jquery.ui.sortable.js"></script>
<script type="text/javascript" src="jQuery/jwysiwyg/jquery.wysiwyg.js"></script>
<script type="text/javascript" src="jQuery/json.js"></script>
<script type="text/javascript" src="jQuery/jquery.form.js"></script>

If anyone has encountered a similar problem or just knows what to do in this situation, what to do, then I appeal to you for help! Thanks in advance.

P.S. And one more thing… It doesn’t matter which browser you use. Whether it’s Opera or Chrome, everything is the same everywhere!

Answer 1, authority 100%

Problem fixed. The error was that JavaScript was executed up to a certain point. And I had this:

<div id='actinfo' style="display:none">

When adding that php line, instead of a json array, a skool error was written, and therefore javascript was not executed after the line:

var menu = new Object();
            eval("menu = "+eval_str);

Answer 2

By the way, I also encountered this, for some reason such a thing did not work for me…
Try replacing this line with pure javascript

eval_str = document.getElementById('actinfo').innerHTML;
menu = eval('('+eval_str+')');