Jump to content

RichardRotterdam

Members
  • Posts

    1,509
  • Joined

  • Last visited

Everything posted by RichardRotterdam

  1. The first code sniplet works fine for me. What php version are you running? and do you have your error reporting on?
  2. Totally true, however if you are doing this serverside you could create a cron job/ scheduled task and store the data that is required locally (in a database or xml for example). After that it would be a simple task of just fetching the required data locally thus increasing performance. I heaven't tried to use jQuery yet for scraping a remote site. Wouldn't that cause a cross domain scripting implication? I wanna try that out so far I've been getting jsonp to work for cross doimain scripting but not reading a whole remote site as string. What code did you exactly use? just saying "but none of them returned an output" is a little too hard too work with for giving you help.
  3. Just a while ago I stumbled upon phpQuery which is a port of jquery to php. That might also help http://code.google.com/p/phpquery/ However I don't think you really need a third party script. the DOMdocument class is enough to easily do this sort of task. Here is a recent thread about regex and DOMdocument which might help you: http://www.phpfreaks.com/forums/index.php/topic,264032.0.html
  4. Totally depends on where you are I'd say the demand for PHP and .NET is about the same in the Netherlands. On what facts do you base that just curious.
  5. Just do a select query to see if a name already exists. If it does exist don't do the insert and return a error message. SELECT * FROM users WHERE user_name="name_here" When you do the insert query don't use the id as argument in values like so INSERT INTO USERS(name) VALUES("your_name_here") The id will be inserted automatically
  6. Can you call the perl script directy on your webserver? Otherwise why not rewrite the script to PHP. Manipulating a text file is a pretty simple task for PHP
  7. Maybe you have magic quotes on try removing the slashes with strip slashes <?php $data = $_POST['jsonData']; // remove slashes when magic quotes is on $decode = (get_magic_quotes_gpc()==1) ?json_decode(stripslashes($data), true) :json_decode($data, true); // output the array echo '<pre>',print_r($decode),'</pre>'; ?>
  8. something like this perhaps? http://www.phpfreaks.com/forums/index.php/topic,155984.0.html
  9. using document.write won't work since there is a delay between fetching the data and outputting it. try the following and read the comments for explanation. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.3/prototype.js"></script> <script type="text/javascript"> // wait for the dom to load document.observe("dom:loaded", function() { var postcode = "DY12GN"; // create the request new Ajax.Request('/searchprocessing.php?postcode=' + postcode, { method:'get', onSuccess: function(transport){ var response = transport.responseText || "no response text"; // output the retrieved text to <div id="output"> $('output').innerHTML = transport.responseText; }, onFailure: function(){ // output an error to <div id="output"> $('output').innerHTML = 'Something went wrong...'; } }); }); </script> <div id="output"></div>
  10. Re-reading the json i see something now. Ok to make it more readable let's indent it your Json notation { "identifier":"name", "items":{ "Champaign":"Champaign", "Chicago":"Chicago" } } Desired json notation: { identifier:"name", items: [ {name:"Anytown", label:"Alaska"} ] } In the above Json code its still a js object. hover the items inside this object is an array which means you can you store more names inside the items. your php array creation should be something like so: <?php $arr = array ( identifier=>'name', items=>array( array('name'=>'Anytown', 'label'=>'Anytown'), array('name'=>'Second', 'label'=>'Second') ) );
  11. If it uses javascript might as well use Ajax and only refresh the pulldown that is connected. Try looking up "javascript chained select". There are also a couple of examples of that on this forum
  12. json_encode should work and you are correct that it does not produce the square brackets that's because it's a javascript object not a javascript array
  13. looking at the source of that page it seems like the icarousel class for mootools <script src="http://dibusoft.com/js/mootools.v1.1.js" type="text/javascript"></script> <script src="http://dibusoft.com/js/icarousel.js" type="text/javascript">
  14. Hmm odd I actually ran the script you posted and it doesn't produce any parsing errors.
  15. what's not right on the following $first_name[5] = "Michae;l" notice how the final character in that line is not a semicolon?
  16. No you can do more with it then just display it. Yes that does makes sence and that is exacly what you can do with the text returned. Also this is where code would be more explanitory instead of a description of your problem.
  17. It might be a reason but it's still not a GOOD reason. Besides that there is simply no way to fully make sure what browser someone is using other then that forcing someone to use IE isn't an option. And even if you can only view a page in IE you can still get the video which is mentioned to you earlier. You might also want to view the following thread: http://www.phpfreaks.com/forums/index.php/topic,248798.0.html
  18. Basicly what you do with Ajax is call a php script(or any other serverside script) without refreshing the page main. So you can indeed find out if a customer exists in your database. I don't get how returning a piece of text is not helpfull though, what exactly do you mean with return variables? Also how do you wish to check if a user does exist or not? Do you want to use a form? Well code examples are usually the best way to explain but I guess it can be explained with the following Mainpage.html ajax_check_user_exist.php --------------------------------- name ------------------------- | customename: | --> | | | | ------------------------- | ----------------- | yes/no | | | | <-- | ----------------- | | | --------------------------------- In the above example is a form on a html page. Using ajax (XMLHttpRequest) a name gets send to ajax_check_user_exist.php script. The php script returns either yes or no here. On your Mainpage.html you can display this text.
  19. Why I can't imagine any good reason for blocking a type of browser. That must be the user agent switcher for firefox I love that plugin for websites that block firefox. But fixing this in javascript won't help you resolve this.
  20. I think you meant Json instead of Jason. Json stands for JavaScript Object Notation. It's just a notation for transfering data and not really related to your problem. Ajax is not a language. have you read what ajax is yet? the link provided earlier is a good start. You might also want to read the wiki article http://en.wikipedia.org/wiki/Ajax_(programming)
  21. You're prob not waiting for this but since I am a bit of a js junky I made a jQuery script that sorta does what you want. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ var typeSelectElements = $("select[name^='type']"); //console.log(typeSelectElements); typeSelectElements.live('change',function(){ // fetch all current element values var valuesToCheck = new Array(); $.each(typeSelectElements, function() { valuesToCheck.push($(this).val()); }); var valueCount=0; for(var i = 0; i < typeSelectElements.length; i++){ if($(typeSelectElements[i]).val() === $(this).val()){ valueCount++; } if(valueCount>1){ alert('error duplicate entries'); break; } } }); }); </script> <select name="type1"> <option value="">select one</option> <option value="val1">val1</option> <option value="val2">val2</option> <option value="etc">etc</option> </select> <br /> <select name="type2"> <option value="">select one</option> <option value="val1">val1</option> <option value="val2">val2</option> <option value="etc">etc</option> </select> <br /> <select name="type3"> <option value="">select one</option> <option value="val1">val1</option> <option value="val2">val2</option> <option value="etc">etc</option> </select> <br /> You can also just create a form and set the action to your page so it's still no safty
  22. You could use php.js to make this easier it has a js equivalent for array_unique in js http://phpjs.org/functions/array_unique:346 You are probably aware of it but just making sure so I'm asking anyway. You do realize that you shouldn't rely on js validation always do serverside validation since js can be turned off. this would mean you would have HTML similar(without tables) to the following correct? <select name="type1"> <option value="val1">val1</option> <option value="val2">val2</option> <option value="etc">etc</option> </select> <select name="currency1"> <option value="val1">val1</option> <option value="val2">val2</option> <option value="etc">etc</option> </select> <select name="type2"> <option value="val1">val1</option> <option value="val2">val2</option> <option value="etc">etc</option> </select> <select name="currency2"> <option value="val1">val1</option> <option value="val2">val2</option> <option value="etc">etc</option> </select> <select name="type3"> <option value="val1">val1</option> <option value="val2">val2</option> <option value="etc">etc</option> </select> <select name="currency3"> <option value="val1">val1</option> <option value="val2">val2</option> <option value="etc">etc</option> </select> Selecting all select elements is a piece of cake with jQuery's like selector function But then again you might not want to use jQuery but it's there if you like.
  23. Sounds like you want to work with hierarchical data. You might find the following thread of use http://www.phpfreaks.com/forums/index.php/topic,263174.0.html edit Hmmm semi hierarchical yikes nvm that can be tough
  24. Wrong quotes you had ` instead of ' or ". Also added htmlentities to prevent a xss attack <form action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="get">
  25. What is the form action set to? <form action="what_page_does_this_go_to" method="get">
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.