Jump to content

phparray

Members
  • Posts

    96
  • Joined

  • Last visited

    Never

Everything posted by phparray

  1. Your should go directly from the txt file into the mysql db. It was be one heck of a preg_match to do it the other way and very inefficient.
  2. Interesting. Most of the time you are creating and html table from data that exists in a database not the other way around. If this is just a one time thing you could copy and paste the html table from your browser window into an excel spread spreadsheet. clean up the data if need be then import it into access.
  3. I strongly believe what you are trying to do can not be done with a subquery because count(*) only returns one row and you need more than one row of data. This would be far better as separate queries. #not tested $results = mysql_query('select pcatid,pcatname from parent_cats'); while($row = mysql_fetch_row($results)) { $r2 = mysql_query('select count(*) from products where parents_id = "$row[0]";'); $num = mysql_result($r2,0,'count(*)'); echo $row[1] . '('. $num .') <br />'; } mysql_free_result($results); mysql_free_result($r2);
  4. Here you go. This article explains it well. http://www.mattheerema.com/web-design/2006/04/getting-fieldset-backgrounds-and-legends-to-behave-in-ie/
  5. This should fix both problems. Escape the quote with addslashes and break up a sentence into an array of single words building the sql query with each word. Replace $result = mysql_query("SELECT * FROM tbfind WHERE coli LIKE '%$keyword%' OR colii LIKE '%$keyword%' OR coliii LIKE '%$keyword%' OR coliv LIKE '%$keyword%' ORDER BY coli"); With $keyword = addslashes($keyword); $sqlWhere = 'WHERE coli LIKE "%'.$keyword.'%" OR colii LIKE "%'.$keyword.'%" OR coliii LIKE "%'.$keyword.'%" OR coliv LIKE "%'.$keyword.'%"'; $keywordArray = explode(" ",$keyword); foreach($keywordArray as $word) { $word = addslashes($word); $sqlWhere .= ' OR coli LIKE "%'.$word.'%" OR colii LIKE "%'.$word.'%" OR coliv LIKE "%'.$word.'%" '; } $result = mysql_query("SELECT * FROM tbfind ".$sqlWhere." ORDER BY coli");
  6. FULLTEXT index only works with the MyISAM storage engine. In other words you can not use it on a table that also uses foreign keys. So if you happen to be using the InnoDB engine you'll need to work something else out for searches. In many cases this will do. SELECT field WHERE field LIKE "%value%";
  7. When making html emails you have to turn off the part of your brain that says to do things proper. Make email clients such as outlook using very old parsing engines and so you have to use very old methods for them to work. Basically keep the width as small as possible and use inline styles. Yes I just used the cursed term inline styles but that's what you have to do.
  8. Try using curl. As long as curl is enabled it will work more reliably then fopen.
  9. The problem is this script was written for use with register globals turn on and the server you are using has them turned off. Turing them on is very dangerous from a security stand point. You should replace them with the provide post usage. Replace all variables that look like this $FirstName with one that look like this $_POST['FirstName'] That should fix it and make it a little more secure.
  10. If you are moving from one page to another but still want to load the div tag with an asynchronous call you would do something like this. Place your div tag with the appropriate id before calling the script. This way the script is called during the page load. <div id="menu"></div> <script language="javascript"> <!-- AjaxRequest('menu','./includes/eventlist.php?eventdates=".$link_date."') //--> </script>
  11. You'll need to post the contents of /forums/modules/apply.php for anyone to give a good answer.
  12. Here is a really simple function I wrote recently that will do what you need. Add this to the head section of your page. Edit field1,field2,field3 to be the actual ids of your input fields. This function uses and alert box but you could replace that will another method. The alert box is on this line alert('Please complete all required fields'); If you look at my previous post you can see how to use innerHTML instead. <script type="text/javascript"> <!-- function validate() { var required = new Array(); required[1] = 'field1'; required[2] = 'field2'; required[3] = 'field3'; for(x in required) { if(document.getElementById(required[x]).value == '') { alert('Please complete all required fields'); document.getElementById(required[x]).focus(); return false; } } return true; } //--> </script> Then just make sure your input fields actual have assigned ids and add this onclick attribute to your submit button <input type="text" name="field1" id="field1" /> <input type="text" name="field2" id="field2" /> <input type="text" name="field3" id="field3" /> <input type="submit" name="submit" value="Submit" onclick="return validate()" /> Sorry I don't know of any good tutorials for this off the top of my head. But all the information you need it in this reply and the last. Good Luck!
  13. You don't need to ajax for this. All you need to do is check the form values onclick of the submit button and return a message if they are blank. Here's a quick example for you. <script type="text/javascript"> function isBlank(field,div) { if(field.value=='') { document.getElementById(div).innerHTML="Required Field"; return false; } else { return true; } } </script> <form name="myForm"> <div id="errorMessage"></div> <input type="text" name="myField" /> <input onclick="return isBlank(this.form.myField,'errorMessage')" type="submit" name="Submit" value="Submit" /> </form> Never rely on js validation. Always do both server side and client side. Remember users can always turn off javascript and since ajax is javascript that won't work either.
  14. For my own stuff I create a folder called classes and name each class the same as the file name it communicates with on the view layer of the site. When working on a project it is really easy to know right away where to go when a function needs to be modified. For ajax sites I create a folder called output and again put files with the same name as those in the view. My file structure would look pretty close to this. index.php includes/classes/index.php includes/output/index.php forum.php includes/classes/forum.php includes/output/forum.php administrator.php includes/classes/administrator.php includes/output/administrator.php I would not call this common practice or a standard of any kind but it is what I do to keep everything straight and has proved to be a very scalable method.
  15. Since you are just getting started I'd like to suggest using Autoloading Objects http://us.php.net/autoload . I wish someone had told me about it when I was first learning. I started by using a global include file that included ever class file. Using _autoload will prevent messes includes in your applications. Learning how to use this was a real highlight for me!
  16. I am always and advocate for good reference material. Reason being it takes a long time to sift through all the junk that's out on the internet. A good book puts all the information you need in one place. About the hosts file. windows has the same file. It's purpose on both windows and linux is to resolve a domain name locally by storing the ip address and preventing a DNS look up. To create 2 distinctly separated websites in apache with only one ip address you'll need to using what is called name based hosting. Just before the first virtual host contain you would need to add this. NameVirtualHost 127.0.0.1 Name based hosting relies on the requesting domain name to pull up the correct site. The bottom of your httpd.conf file usually where the definitions for each website is stored. I say usually because often apache will be figured with include files to separate the vhosts from the config sections. Right now you most like only have one virtual host contain. It would like like this: <VirtualHost 127.0.0.1:80> ServerAdmin webmaster@dummy-host2.example.com DocumentRoot /www/docs/dummy-host2.example.com ServerName dummy-host2.example.com ErrorLog @rel_logfiledir@/dummy-host2.example.com-error_log CustomLog @rel_logfiledir@/dummy-host2.example.com-access_log common </VirtualHost> To make a second one just copy and paste the existing one then change the DocumentRoot and ServerName data. Note the NameVirtualHost is the same as the ip found in the opening tag of each Virtual Host containers. Once you have 2 sites apache needs some way to tell the difference between the two. This is where using different domain names is important and to create domain names without registering them and without configuring DNS you need to edit your host file. On windows it is usually located here: C:\WINDOWS\system32\drivers\etc\hosts The ServerName field needs to match a domain listing in your host file. This is how apache knows which container to use. One last thing. You have to restart apache before changes to the config file take place.
  17. Each website in apache is defined by a virtual host container. You can simply copy and paste the first one to make a second. Then modify the directive accordingly. You may also want to update the machine's host file. On linux this is /etc/hosts usually. Doing this will also you to create test domains. If you made that file look like this. localhost 127.0.0.1 website1 127.0.0.1 website2 127.0.0.0 You would be able to browse to http://localhost/ http://website1/ http://website2/ In apache the directive ServerName can be set to website1 in the first container and website2 in the second to make each site serve respectively.
  18. I wrote this tutorial awhile back. It's a quick copy paste, get you started type of thing adopted from w3schools. http://forums.hostmysite.com/about9282.html
  19. Your are correct to call session_start(); at the top of each page. You just haven't added anything to the session array yet. That is done like so. <?php session_start(); $_SESSION['name'] = $_POST['1']; echo "hello $_SESSION['name']"; ?> <a href="./3.php">GOTO THE NEXT PAGE</a> <?php session_start(); echo "hello $_SESSION['name']"; ?>
  20. PHP doesn't force you to structure your OOP in any particular way. This leaves everything up to you. I use OOP to create a common structure that is somewhat suitable for just about every application. Reusing this structure makes programming go much quicker because I'm used to do things with my own library of classes and functions. I also use it in conjunction with MVC to create separation between the markup, business logic, and data layers.
  21. Looks like your id will be in $_POST['del_sec'] DELETE FROM words WHERE key_id = $_POST['del_sec']
  22. Use the target attribute. <a target="_blank" ....
  23. If you are using the MyISAM engine you can add a fulltext index to the city column then use this. SELECT * FROM ass_name MATCH (city) AGAINST ($city)
  24. In this case sure you can say that but not because the first argument is and auto incrementing value. The first argument in the "for in" function is the key values. Consider if the keys where not 0 throught 3. <html> <body><script type="text/javascript"> var x; var mycars = new Array(); mycars[0] = "Saab"; mycars[5] = "Volvo"; mycars[8] = "BMW"; for (x in mycars) { document.write(mycars[x] + "<br />"); } </script></body> </html> I this example the x is qual to 0,5, and 8 in that order but the output is identical.
×
×
  • 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.