Note that there are some explanatory texts on larger screens.

plurals
  1. POBoth Javascript and Mysql calls not working on page
    text
    copied!<p>I have a really strange problem I've been trying to work around for a while now, but it's to the point where I can't anymore. </p> <p>I have a simple php script. It does some api calls and pulls some data down from facebook and then displays it. For some reason on this page ANY Javascript/jquery that I put in the script just simply does not work. I insert an iframe with the javascript in the source and it works, but if the javascript is in this page it simply doesn't register. No response at all..the javascript plugin won't show up, or the function will not fire on-click.</p> <p>Also MYSQL calls aren't working either. I simply get nothing back. Has this ever happened to any of you before? Any possible causes? </p> <p>I don't think I have any syntax errors..I'll keep checking though. Any help is much appreciated!!</p> <p>Here is the first part of my code up until the body, I can't show the rest unfortunately:</p> <pre><code>&lt;?php require 'includes/connection.php'; require 'src/facebook.php'; // Create our Application instance (replace this with your appId and secret). $facebook = new Facebook(array( 'appId' =&gt; '~myid~', 'secret' =&gt; '~mysecret~', )); // Get User ID $user = $facebook-&gt;getUser(); // If we have a $user id here, it means we know the user is logged into // Facebook, but we don't know if the access token is valid. An access // token is invalid if the user logged out of Facebook. if ($user) { try { // Proceed knowing you have a logged in user who's authenticated. $user_profile = $facebook-&gt;api('/me'); $access_token = $facebook-&gt;getAccessToken(); $user_name = $user_profile[first_name]; /* echo $user; echo "&lt;br/&gt;&lt;br/&gt;"; echo $access_token; */ } catch (FacebookApiException $e) { error_log($e); $user = null; } }/*elseif($_GET[user]){ $user = $_GET[user]; if ($user) { try { // Proceed knowing you have a logged in user who's authenticated. $user_profile = $facebook-&gt;api('/me'); $access_token = $facebook-&gt;getAccessToken(); $user_name = $user_profile[first_name]; /* echo $user; echo "&lt;br/&gt;&lt;br/&gt;"; echo $access_token; } catch (FacebookApiException $e) { error_log($e); $user = null; } } }*/ // Login or logout url will be needed depending on current user state. $logoutUrl = $facebook-&gt;getLogoutUrl(); $loginUrl = $facebook-&gt;getLoginUrl(array('scope'=&gt;'offline_access')); //Get youtube video ID from URL // &amp; Linkify youtube URLs which are not already links. function linkifyYouTubeURLs($text) { $text = preg_replace('~ # Match non-linked youtube URL in the wild. (Rev:20111012) https?:// # Required scheme. Either http or https. (?:[0-9A-Z-]+\.)? # Optional subdomain. (?: # Group host alternatives. youtu\.be/ # Either youtu.be, | youtube\.com # or youtube.com followed by \S* # Allow anything up to VIDEO_ID, [^\w\-\s] # but char before ID is non-ID char. ) # End host alternatives. ([\w\-]{11}) # $1: VIDEO_ID is exactly 11 chars. (?=[^\w\-]|$) # Assert next char is non-ID or EOS. (?! # Assert URL is not pre-linked. [?=&amp;+%\w]* # Allow URL (query) remainder. (?: # Group pre-linked alternatives. [\'"][^&lt;&gt;]*&gt; # Either inside a start tag, | &lt;/a&gt; # or inside &lt;a&gt; element text contents. ) # End recognized pre-linked alts. ) # End negative lookahead assertion. [?=&amp;+%\w]* # Consume any URL (query) remainder. ~ix', '$1', $text); return $text; } // function to convert second to time ( minute and secong format) function secTomin($secs) { $sec = $secs % 60; if($sec &lt; 10) { $sec = '0'.$sec; } $min = floor($secs/60); $ret = $min.':'.$sec; return $ret; } //Output Buffering // make sure output buffering is off before we start it // this will ensure same effect whether or not ob is enabled already while (ob_get_level()) { ob_end_flush(); } // start output buffering if (ob_get_length() === false) { ob_start(); } //replace accents function replaceAccentedCharacters($str) { $search = explode(",","ç,æ,œ,á,é,í,ó,ú,à,è,ì,ò,ù,ä,ë,ï,ö,ü,ÿ,â,ê,î,ô,û,å,e,i,ø,u"); $replace = explode(",","c,ae,oe,a,e,i,o,u,a,e,i,o,u,a,e,i,o,u,y,a,e,i,o,u,a,e,i,o,u"); $strreplaced = str_replace($search, $replace, $str); return $strreplaced; } ?&gt; &lt;!DOCTYPE&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt; &lt;script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="http://connect.soundcloud.com/sdk.js" type="text/JavaScript"&gt;&lt;/script&gt; &lt;script src="togglemenu.js" type="text/JavaScript"&gt;&lt;/script&gt; &lt;script type="text/JavaScript"&gt; SC.initialize({ client_id: "~mycliendid~", redirect_uri: "~myurl~", }); &lt;/script&gt; &lt;script type="text/javascript" src="ajax.js"&gt;&lt;/script&gt; &lt;link type="text/css" rel="stylesheet" href="css/jquery-ui-1.8.9.custom/jquery-ui-1.8.9.custom.css" /&gt; &lt;script type="text/javascript" src="jquery-ui-1.8.13.custom.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="jquery.multi-accordion-1.5.3.js"&gt;&lt;/script&gt; &lt;link rel='stylesheet' href='css/lionbars.css' /&gt; &lt;script type="text/javascript" src="jquery.lionbars.0.3.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function(){ $('#song_list').lionbars({ autohide: true }); }); &lt;/script&gt; &lt;/head&gt; </code></pre> <p>None of the javascript in this code is working right now. Also I've replaced my app data for facebook and soundcloud in the above code. Sorry it's a little messy. Wish I could post it all but it's not up to me. Thanks for your help in advance!</p> <p>Here is my SQL Statement as requested - actually just a test one I set up w/ the same format: </p> <pre><code>$query = "SELECT * FROM users WHERE fb_user_id = '$user'"; $likes = mysql_query($query); $num = mysql_num_rows($likes); echo $num; while ($like_list = mysql_fetch_array($likes, MYSQL_ASSOC)){ $like = $like_list['fb_from_id']; echo $like; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload