trq
Staff Alumni-
Posts
30,999 -
Joined
-
Last visited
-
Days Won
26
Everything posted by trq
-
Find a directory in expanded file and copy its contents
trq replied to satre's topic in PHP Coding Help
Here, something like (not tested)..... <?php function getPN($path) { if ($dh = opendir($path)) { while(false !== ($file = readdir($dh))) { if (is_dir("$path/$file")) { if (substr($file, -3) == '.pn') { return "$path/$file"; } else { getPN("$path/$file"); } } } } } ?> that should return the path to your *.pn directory. -
You should look in the manual before wasting your time asking such simple questions. http://dev.mysql.com/doc/refman/5.1/en/stored-routines.html
-
Even if there was (which there isn't) you would still need to query the database to find out (which is actually what you are doing).
-
Find a directory in expanded file and copy its contents
trq replied to satre's topic in PHP Coding Help
You'll need to recurse through the directory structure until you find what your after. Not too difficult. -
How are you accessing this script though? Via HTTP?
-
There is literally no reason why this does not work.
trq replied to turkman's topic in Javascript Help
It's pretty rare you'll get help with third party code, especially when you don't seem to have made any attempts to debug the issue yourself. -
You might find this.... http://www.subbu.org/blog/2006/04/dissecting-ajax-server-push interesting.
-
Kinda sounds like your fishing around for what is called the MVC pattern. This post..... http://www.phpfreaks.com/forums/application-design/fully-understanding-mvc-concept/msg729041/#msg729041 might help.
-
A few things. Firstly, you passing the data parameter a variable called data, this is undefined and you don't need it. Secondly, your telling the $.ajax() function that it is to receive the dataType of json from this request, then you return it plain text. You should stick with the json dataType, but fix your php accordingly. (this will make things more flexible in the long run). Lastly, jQuery provides mechanisms that mean you don't need to mix Javscript in with your markup, use them. So, with those things in mind, your code should not look like. <?php echo json_encode(array('foo' => 'Here i am')); ?> <html> <head></head> <body> <form> <input type="button" id="clicker" value="Click me!" /> </form> <div id="here"></div> </body> <script src="jquery.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function() { $('#clicker).click(function() { $.ajax({ type: "POST", url: "variable.php", dataType: "json", cache: false, success: function(json) { $('#here').html(json.foo); } }); }); }); </script> </html>
-
This topic has been moved to PHP Coding Help. http://www.phpfreaks.com/forums/index.php?topic=321568.0
-
This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=321572.0
-
You already have the data, why do you need an array? Anyway, try... foreach( $keywords->responseData->keywords as $keyword) { echo $keyword->content; }
-
Where not here to write code for people, where are you stuck exactly?
-
Object properties are access via ->, this is all covered here. If your still stuck, can you please paste the source of what the call to print_r() produces so it is at least readable?
-
How to accept JSON via AJAX and turn it into a Javascript array?
trq replied to galvin's topic in Javascript Help
You'll likely want to form some markup and use that. eg var tmp = ''; for (var question in answers) { tmp += '<div>'; tmp += ' <span class="question'> + question + '</span>'; tmp += ' <span class="answer'> + answer[question] + '</span>'; tmp += '</div>'; } document.getElementById('answers').innerHTML = tmp; I'll kill two birds here. yes, console.log() is used for debugging via firebug. It's also a good thing to use in examples posted on forums IMO, because people will be outputting things in different way, I was just pointing out how you access data within json objects. As for how you can see your json data? Take look at it in console.log(). -
How can you go to a non-existant URL and still get a page there?
trq replied to millicent's topic in Apache HTTP Server
It's common practice in PHP applications. Or web applications in general really. Unless of course that is your used to working in Windows and IIS. -
How can you go to a non-existant URL and still get a page there?
trq replied to millicent's topic in Apache HTTP Server
That basically says, send all request for /blog to post.php and pass anything after it (eg; /blog/foo, would be foo) to the querystring variable post. So, within post.php 'foo' would show up within $_GET['post']. -
How to accept JSON via AJAX and turn it into a Javascript array?
trq replied to galvin's topic in Javascript Help
Just to reiterate. Lets say your var answers, is a json object that looks like..... var answers = {"q1": "Pigs that fly", "q2": "Because", "q3": "Why not"}; You can access easily them via.... console.log(answers.q1); console.log(answers.q2); console.log(answers.q3); If you want to loop through them, use.... for (var answer in answers) { console.log(answers[answer]); } -
How to accept JSON via AJAX and turn it into a Javascript array?
trq replied to galvin's topic in Javascript Help
You don't want to convert json to a javascript array. it is already a simple javascript object. Given this json.... var json = {"id":12,"name":"foo"} You can access it easily using.... var json = {"id":12,"name":"foo"}; console.log(json.id); -
How to load a jquery popup in successful completion of form
trq replied to davelearning's topic in Javascript Help
Have you installed jquery ui? -
How can you go to a non-existant URL and still get a page there?
trq replied to millicent's topic in Apache HTTP Server
It's done with Apache's mod_rewrite module. -
How to load a jquery popup in successful completion of form
trq replied to davelearning's topic in Javascript Help
You should take a look at http://jqueryui.com/demos/dialog/