Jump to content

Ge64

Members
  • Posts

    31
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Ge64's Achievements

Newbie

Newbie (1/5)

0

Reputation

  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
×
×
  • 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.