Jump to content

Ge64

Members
  • Posts

    31
  • Joined

  • Last visited

    Never

Everything posted by Ge64

  1. If you fill in the 'action' field on a form, it will load the page again on submit, however I'm trying to use AJAX to pass the post data to a script so that I don't reload the page. If I could put a javascript function in the 'action' of the form somehow and that would work with method="POST" then that would be the easiest way to get the post data, but if that doesnt work then I need to keep using this. I'm not very good with JS so I haven't found a better way to do it
  2. MySQL: 4.1.22 I have a table with a number of cols, one of which is named 'tags' and the tags are in a format such as 'cat mouse plant food stuff'. I now use the following query to get rows with matching tags: SELECT id,data FROM information WHERE tags LIKE '% tag %' However, this only finds tags that are in the middle, not the first and last ones unless I add spaces before and after them. If I remove the spaces from the query, it will also find tags that have nothing to do with it (eg I search for 'cat', it will return anything with 'caterpillar' in it as well). What is a better way to do this?
  3. Wow those are some great ideas! I'm now using Smarty but I'm sure the heredoc syntax will come in handy some time, I'd never heard of these.
  4. I've used PHP for a while and every time I do this differently, but I don't think I'm happy with any of the methods. In the end, a PHP file gets evaluated and becomes HTML, but most of the time you need to put in HTML elements like <table> and <div> in order to form your basic layout, but you add in PHP code in between and all over the place. So, do you start out with a PHP file and add in HTML where you need it? If so, how do you add in the HTML, do you echo it or do you make holes in the PHP? OR do you start with a proper HTML page and put in PHP parts wherever you need PHP, meaning you'll have <?php echo ... ?> all over the place as if there were HTML tags. If you are making a table out of what you get from a MySQL database, do you just have a script somewhere that processes the data, then a HTML table with <?php echo $avalue; ?> inside it, or do you make a php script with echo "<tr><td>" . $avalue . "</tr></td>"; in it? What is the best way to do it, what is the best way to keep it looking neat and organised and what is the best way performance-wise?
  5. Thanks, I had read about that in the manual and then completely forgot again immediately
  6. I've found the answer, but I have a new question. I now use this: function compilePostData(obj) { var poststr = ""; for (i = 0; i < obj.elements.length; i++) { poststr += "&" + escape(encodeURI(obj.elements[i].name)) + "=" + escape(encodeURI(obj.elements[i].value)); } makePOSTRequest('action.php', poststr); } This works fine, however, is there any way to simplify this? I tried using 'this' instead of 'document.getEle....etc' but it doesn't work, why? <form name="searchForm" action="javascript:compilePostData(document.forms['searchForm']);"> Tags to search: <input type="text" name="tags" /> </form>
  7. Hi all At the moment I have the following function which gets 'obj' which represents a HTML form: function compilePostData(obj) { var poststr = "tags=" + escape(encodeURI(obj.tags.value)) + "&otherstuff=" + escape(encodeURI(obj.tags.value)); makePOSTRequest('action.php', poststr); } Rather than just having 'tags' and 'otherstuff', I would prefer it if the function could loop through and find all the inputs in the form and add them to var poststr automatically (excluding any buttons, if possible). Alternatively, if there is a way for a HTML form to send it's POST data to a javascript function on submit that would be easier. Anybody know how to do either?
  8. How do I get this to return some results? mysql> SELECT * FROM information; +------+-----------------------+-----------+------+---------------------+--------+---------+ | id | tags | data | type | date | source | subject | +------+-----------------------+-----------+------+---------------------+--------+---------+ | 0 | this,that,the other | SOMESHIT | NULL | 2008-05-17 16:59:49 | NULL | NULL | | 1 | this,that,the other | whatever3 | NULL | 2008-05-17 16:59:49 | NULL | NULL | | 2 | bla your mouse coffee | whatever | NULL | 2008-05-17 16:59:49 | NULL | NULL | +------+-----------------------+-----------+------+---------------------+--------+---------+ 3 rows in set (0.01 sec) mysql> SELECT id,data FROM information WHERE MATCH (tags) AGAINST('your'); Empty set (0.00 sec) mysql> This is my table according to CocoaMySQL: Is there anything else I need to do before this works, I've never tried it before. Edit: I'm using 4.1.22-log
  9. I found the log and found the problem The problem was whitespace. When I removed the 4 spaces before the 'echo' command inside the loop, it worked. True, I copy/pasted the code from Safari (shame on me) but it appeared as normal spaces in BBEdit. I put back new spaces and it still works so I suppose they weren't actually 'spaces'. This was the error: [error] PHP Fatal error: Call to undefined function \xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0echo() in /Users/ge64/Sites/knowledgebase/action.php on line 27
  10. No, i have echo's and even just HTML after and before the php code and it doesn't output anything. I actually have physical and SSH access to the server and I even had an ssh window open to test the mysql queries. I'll try to find the error log, but is there any way I can get the error to display through the browser instead?
  11. I think he means he bought the script using PayPal, not that the script does any money-related stuff...
  12. I'm making a very simple app at the moment but I'm running into something I can't explain. I have a sql query which is succesful and the result is in $mysqlresult. Whenever I do the following, everything turns out fine (there are 2 rows): $row = mysql_fetch_assoc($mysqlresult); echo $row['data']; mysql_data_seek($mysqlresult, 1); $row = mysql_fetch_assoc($mysqlresult); echo $row['data']; But when I use the normal way: while($row = mysql_fetch_assoc($mysqlresult)) { echo $row['data']; } it doesn't output anything, not even anything I echo before or after that, as if PHP locks up on the loop. I'm using the almost latest version of PHP.
  13. Well not exactly but it does do something similar, that's why I said 'or any other way to do that'. Well maybe I should have posted more about what I'm trying to accomplish
  14. ??? Why not :-[ Edit: Someone on another forum pointed me to [url=http://us3.php.net/manual/en/language.variables.variable.php]variable variables[/url]. Thats exactly what I need :) thanks anyway
  15. Hi, Is there a function that returns the name of the variable? Like: [code]$variable_name = varname($somevariable); //$variable_name == "somevariable"[/code] The other way around would also work, like: [code]$somevariable = variable('variable_name'); //$somevariable == $variable_name[/code] Or is there any other way to get that? Thanks already :P
  16. [!--quoteo(post=349924:date=Feb 27 2006, 07:46 PM:name=Ge64)--][div class=\'quotetop\']QUOTE(Ge64 @ Feb 27 2006, 07:46 PM) [snapback]349924[/snapback][/div][div class=\'quotemain\'][!--quotec--] No ideas? [/quote] I fixed a few things but it still doesn't all work, I uploaded the new source code to [a href=\"http://ge64.nl/files/src.zip\" target=\"_blank\"]http://ge64.nl/files/src.zip[/a]
  17. [!--quoteo(post=350045:date=Feb 28 2006, 12:09 AM:name=ktsirig)--][div class=\'quotetop\']QUOTE(ktsirig @ Feb 28 2006, 12:09 AM) [snapback]350045[/snapback][/div][div class=\'quotemain\'][!--quotec--] Hi everybody! I have a problem and I was told to check out the sessions part in PHP. What I want to deal with is the following : I have a PHP page with a form, where the user writes some data. These data are then written into a file which is then used in a system command as input for an external program (NOTE: The data MUST be written into a file, it cannot be done elsewhise, because the external program takes a file as input). The thing is that I must somehow create a file everytime a user enters data into the form, so I must learn something on sessions I think. My question is, since I don't have a login system or something like that, but just want to create a different file each time (with the session_id being part of it, so that the file is unique), which session commands do I need? [/quote] I dont really think you need sessions here, sessions are for remembering information such as login and password when you move to another page (so the page knows who is logged in). You need the fopen() commands (see www.php.net) and something that makes a unique ID. You could save all the IDs that are used to a file and make a script make up one that isnt in there yet.
  18. [!--quoteo(post=350011:date=Feb 27 2006, 11:18 PM:name=Cloud9247)--][div class=\'quotetop\']QUOTE(Cloud9247 @ Feb 27 2006, 11:18 PM) [snapback]350011[/snapback][/div][div class=\'quotemain\'][!--quotec--] Okay, well I realized I need my site to be coded in templates, but not just HTMl templates, HTML templates that are in a MySQL database(for efficiency). I have looked up nearly every tutorial out there, and have found nothing that anwsers my question. I am absolutely begging for someone's help, I would be more appreciative than you could imagine! Thank You. [/quote] Usually when I make a website I take a standard HTML template and replace all the important things by identifiers like #body#, which you can replace with code in PHP. You can for instance get news posts from a mysql database and put them on the front page like that.
  19. [!--quoteo(post=349917:date=Feb 27 2006, 07:36 PM:name=joecooper)--][div class=\'quotetop\']QUOTE(joecooper @ Feb 27 2006, 07:36 PM) [snapback]349917[/snapback][/div][div class=\'quotemain\'][!--quotec--] tell me the files you want to run, and at what times, and ill add it to the cron jobs on my server [/quote] The site isnt finished yet so I don't know... Is there a cron jobs module for apache2?
  20. [!--quoteo(post=349910:date=Feb 27 2006, 07:23 PM:name=joecooper)--][div class=\'quotetop\']QUOTE(joecooper @ Feb 27 2006, 07:23 PM) [snapback]349910[/snapback][/div][div class=\'quotemain\'][!--quotec--] let me know if your still looking for one, i could whip up a visual basic program for you to run it [/quote] Do you have code to run sql queries on remote mysql servers? Because that would be even better but probably a lot of work. What I need is a few scripts that need to run at all sorts of times, like every day or every hour, or totally random. You would only need to use an Inet control because I have the files on a HTTP server with PHP so you only have to run them then, don't think thats really hard to do right? I would actually do it myself but I lost my VS cd :( Let me know if you feel like doing that...
  21. [!--quoteo(post=349884:date=Feb 27 2006, 05:56 PM:name=craygo)--][div class=\'quotetop\']QUOTE(craygo @ Feb 27 2006, 05:56 PM) [snapback]349884[/snapback][/div][div class=\'quotemain\'][!--quotec--] if your web server uses cron jobs, you can run a script every hour with that. Do a search on cron jobs here and you should find it no problem. Ray [/quote] No it doesnt, but is there software to run php scripts at certain times so I can put it on one of my 24/7 pc's and run it remotely?
  22. [!--quoteo(post=349882:date=Feb 27 2006, 05:55 PM:name=craygo)--][div class=\'quotetop\']QUOTE(craygo @ Feb 27 2006, 05:55 PM) [snapback]349882[/snapback][/div][div class=\'quotemain\'][!--quotec--] I logged in and when I click member list, I get a quick white page with php error but then it goes right into the page and it is all messed up. You should add "die();" in there so that the script ends when errors occur, just until you can debug. Looks like there are some errors in there but it passes by so quick I can't see them. Ray [/quote] Well that's because its not finished yet, the only pages that work are News, Home Base, and Plant. The other ones mess up the template because if there is no page it misses a table, and the errors are probably about the include file not existing.
  23. For my website I need to update a few numbers in the mysql database exactly every hour, so I will need to run a php script then. Is there a way to make a PHP script do something at a particular moment?
×
×
  • 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.