-
Posts
14,780 -
Joined
-
Last visited
-
Days Won
43
Everything posted by .josh
-
change $path[1] = $valuePath; to $valuePath = $path[1][$key];
-
you cannot directly call php from javascript because php is a server-side language and javascript is client-side. In order to have javascript execute a php function, you have to use AJAX. Basically with AJAX you use javascript to make an http request and receive a response, without the full page reloading. The easiest way to do an AJAX request is to use a javascript framework like jquery, as it has built into it cross-browser AJAX functionality. Getting jquery is as easy as getting the latest source file from jquery.com (click on the big download button on the right to be taken to the latest .js file). Upload it and include it on your page with standard javascript script include tag. Then you would do something like this: page with the javascript: <script type='text/javascript' src='jquery.js'></script> <script type='text/javascript'> // your other js stuff here...at the time that you need the php function to be called... $.get( // name of php script to call 'phpFile.php', // if you have any parameters to send, do it here (this can be grabbed with php via $_GET['paramX'] { 'param1' : 'value', 'param2' : 'value', // etc... }, // response returned from the php script. If you need some value to be returned, this is where it will be function(response) { // response is the js variable that holds whatever is returned from the php script } ); </script> Simple AJAX example: <script type='text/javascript' src='jquery.js'></script> <script type='text/javascript'> $.get( 'phpFile.php', { 'foo' : 'bar' }, function(response) { alert(response); } ); </script> phpFile.php : <?php if ($_GET['foo']) echo $_GET['foo']; ?> This example will load your page, then make an AJAX http GET request to phpFile.php, sending parameter foo=bar. The php script will then echo it out and that is what the js response variable will contain, and it will alert('bar'); NOTE: You can also do an AJAX http POST request by using the same syntax above, except using jquery's $.post(...) and in your php script using $_POST
-
I learned more about php from helping out on the forums and going to the manual than any of the books I've read. Just jump in, read a question, try to research keywords in manual and google, etc.. try to answer. The hardest part about programming is not really learning the syntax, it is being able to do detective work, assess situations, solve problems. Those skills are not really programmer-specific.
-
but to specifically answer your question, the reason you are seeing the "markers" returned is because you are looking at the first element of the matches returned, which is always the full matched pattern. If you want to get rid of the "markers" you need to capture the parts you specifically want (using parenthesis) and look at the additional elements. For example: $string = "XblahX"; preg_match('~X.*?X~',$string,$match); This will give you just $match[0] => "XblahX" But to capture just the "blah" you would do: $string = "XblahX"; preg_match('~X(.*?)X~',$string,$match); This would return $match[0] => "XblahX" $match[1] => "blah" And the specific part (minus the "markers") would be in $match[1].
-
<?php // example data set $data[] = "Firstname1 Lastname1 (13) reported contact (0.06) with another vehicle Firstname2 Lastname2 (37)"; $data[] = "Firstname3 Lastname3 (45) reported contact (0.03) with another vehicle Firstname4 Lastname4 (54)"; $data[] = "Firstname5 Lastname5 (42) reported contact (0.42) with another vehicle Firstname6 Lastname6 (22)"; // loop foreach ($data as $key => $string) { $string = preg_split('~\(([^)]+)\)~',$string,-1,PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY); $array[$key]['Name'] = trim($string[0]); $array[$key]['Type'] = trim($string[2]) . ' ' . trim($string[4]); $array[$key]['Intensity'] = trim($string[3]); } // final multi-dim array echo "<pre>"; print_r($array); ?> output: Array ( [0] => Array ( [Name] => Firstname1 Lastname1 [Type] => reported contact with another vehicle Firstname2 Lastname2 [intensity] => 0.06 ) [1] => Array ( [Name] => Firstname3 Lastname3 [Type] => reported contact with another vehicle Firstname4 Lastname4 [intensity] => 0.03 ) [2] => Array ( [Name] => Firstname5 Lastname5 [Type] => reported contact with another vehicle Firstname6 Lastname6 [intensity] => 0.42 ) )
-
Weird issue with Firefox browser 3.5.15 when executing jquery tabs
.josh replied to genzedu777's topic in Javascript Help
Well I'm using 3.6.12 and clicking on the tabs seems to work just fine for me...dunno but I think my first suggestion would be for you to upgrade to the latest version of jquery. You are currently using v1.3.2 and the current version is v1.4.4. I can tell you from my own experience that I've had random issues with jquery a while back (and if i really sat here and thought about it, it was probably when FF 3.5 was current) when i was using v1.3 and when I updated to jquery v1.4 things seemed to have worked themselves out. -
no, it is not possible.
-
soo...did you actually look at your code and research what it is actually doing? Just as I suspected, you are outputting a raw image as a response (making a call with header() to tell the browser the data is raw image data) and then in Imagejpeg() you are outputting the raw image data instead of saving it to a file. So what happens is when you make a request to the server for that script, it will respond with a raw image. So how are you trying to call this script for the rest of your site? Because as it stands now, you can do something like <img src='path/to/your/script.php' width='100' height='100' /> and your script will generate and return the image to be used in a normal html tag.
-
At face value and without seeing the context of this code, I'd say that every time you click, it "slides down" on first click, "slides up" on 2nd, etc... (because slideToggle() works by the current visibility state of the object is)...but then you have that animate() in there. EVERY time you click, it moves your item to the right 232px and down 50px. I think what you probably need to do is instead of using .click(), use .toggle() and make the first function be what you have now, and the 2nd one be the same thing, only reverse the order of slideToggle() and animate() and also reverse the animation properties. Something like... <script type='text/javascript'> $(document).ready(function() { $('.rij2_content_fav').hide(); $('.mijngames').toggle( function() { $('.rij2_content_fav').slideToggle('slow', function() { $('.rij2_content_fav').animate( { left : '-=232px', top: '+=50px' } ); }); }, function() { $('.rij2_content_fav').animate( { left : '+=232px', top: '-=50px' }, function () { $('.rij2_content_fav').slideToggle('slow'); } ); } ); }); </script>
-
look at the basic database handling tut on the main site.
-
can't tell you what's wrong with your code if you don't show it. But it sounds like you are outputting the raw image instead of saving it to a file. Anyways, there is a tut on the main site about adding text to images.
-
So you have a negative lookahead looking for the absence of <div you aren't actually consuming any characters, matching anything in-between your main opening div and closing div.
-
it's hard to say what you are doing wrong when you don't post any code... but in general, if you want it to forever rotate, you need to recursively call the function.
-
try wrapping submit in quotes: $("a[title='submit']").click(function(){
-
Well, yes. The point being, what's the point in asking why something is one way vs. another when it is a naturally occurring thing.
-
Anyways, I think the overall point Alex was trying to make is that unlike concrete houses, you don't choose to grow up with fake teeth, so your question is more or less moot and/or rhetorical.
-
Even if your house was made of concrete, that wouldn't stop things inside it from burning. given that you have all kinds of burnable things in your house, there's a good chance you'll die just the same. Especially if you are sleeping on that nice flammable bed. Which is mainly what smoke detectors are useful for...waking your ass up when you are sleeping. Also, most modern smoke detectors not only detect smoke, but they also detect other harmful gases. But I'm done straying from the point.
-
suggestions for improvement: - make case insensitive - check if href attrib uses double OR single quotes - optional spacing between href=" (ex: href = " or href= " or href =") #<a[^>]*href\s?=\s?[\"']([^\"']+)[\"'][^>]*>Click here to find out more</a>#i
-
-
yes, there is array_intersect, however, you will need to reformat your arrays to work with it.
-
need help with syntax php username need help
.josh replied to Minimeallolla's topic in PHP Coding Help
yes, you solved one error, but you said you are having another error now, a sql error. Did you not want help solving that? -
need help with syntax php username need help
.josh replied to Minimeallolla's topic in PHP Coding Help
And I told you that error has nothing to do with the code you posted. I told you it has to do with a database query you are attempting to perform. But instead of posting relevant code, you just tell me what you want to do. Do you expect me to bust out with a crystal ball and divine what your code is? Use some common sense. -
need help with syntax php username need help
.josh replied to Minimeallolla's topic in PHP Coding Help
Do you want some help or not? -
need help with syntax php username need help
.josh replied to Minimeallolla's topic in PHP Coding Help
This has nothing to do with the code you posted. Are you even reading the error? You need to put more effort into this. That error is telling you that there is an error in a sql query you are trying to perform. Do you see ANYTHING in the code you posted here that has ANYTHING to do with performing a database query? -
need help with syntax php username need help
.josh replied to Minimeallolla's topic in PHP Coding Help
syntax errors like that are not usually on the actual line reported. They are on the first line where things start to go wrong. Look for quotes you forgot to close somewhere above that line.