Jump to content

phparray

Members
  • Posts

    96
  • Joined

  • Last visited

    Never

Everything posted by phparray

  1. change mysql_query('INSERT INTO table (columnName) VALUES ('.$values . ')'); to mysql_query('INSERT INTO table (columnName) VALUES ("'.$values . '")');
  2. Yes switch case can be used with strings or integers. If the value is a string make sure to quote the case values. example case 'car'; You can change it up how ever you want just make sure you validate all data before allowing it to be used within a query. and yes "if(!is_numeric($_GET['orderedby']))"does say is this not a number and the next line says die. In your question you used numbers therefore this code would make sure only a number is being used and if not end the script because someone changed the url var to something other than a number. If you wanted to use strings instead of integers this section of code would need to be changed to fit.
  3. You should avoid writing duplicate code. Use a switch statement to catch the value of orderby and set the value of value_to_find. You also need to make certain you are santizing the url var. Using is_nueric() then make sure it's a valid orderby value before using it. Here is a good start <?php if(!is_numeric($_GET['orderedby'])) die('orderedby was not a number'); include "db.php"; $get_subject = $_GET['orderedby']; switch($get_subject) { case 1; $value_to_find = 'car'; break; case 2; $value_to_find = 'house'; break; case 3; $value_to_find = 'cloths'; break; } $query = mysql_query("SELECT * FROM lisitings WHERE search_text LIKE '%$value_to_find%' AND live = 1") or die(mysql_error()); $num = mysql_num_rows($query); if($num > 0) { while ($fetch = mysql_fetch_array($query)) { echo $fetch['title']."<br>"; } } else { echo 'There are no listing for that subject!'; } ?>
  4. Normalize your tables. Do not create tables with duplicate structures as in creating a table for each user. This will bloat your database for sure.
  5. Use mysql_num_rows to determine if more than 0 rows have been found. $query = mysql_query("SELECT * FROM listings WHERE search_text LIKE '%$get_subject%' AND live = 1") or die(mysql_error()); $num = mysql_num_rows($query); if($num > 0) { while ($fetch = mysql_fetch_array($query)) { echo $fetch['title']."<br>"; } else echo 'No matches found';
  6. Here is an awesome tool for that. http://www.webmaster-toolkit.com/mod_rewrite-rewriterule-generator.shtml
  7. The use of implode() is a great idea! I can't believe I've never thought of that.
  8. lonewolf217 he said the data was in a text file on new lines. It displaying in a browser as spaces because browsers don't use the \n character. This should work. $YourFile = "sql.txt"; $handle = fopen($YourFile, 'r'); $Data = fread($handle, 512); fclose($handle); #make array from each line in the text file. $str=explode("\n",$Data); $values = ''; #loop through array to create the values portion of sql foreach($str as $val) { $values .= '('.$val.'), ' } #remove the last common. $values = rtrim($values,','); #run query mysql_query('INSERT INTO table (columnName) VALUES '.$values);
  9. To answer your question you don't need to use any fancy editor but ultimately things like code block collapse and syntax highlighting is will save you time. Eclipse php is pretty awesome and it's free. Eclipse also has variable highlighting. When you click on a variable it highlights everywhere the variable exists on the page. With the svn plugin eclispe allows you to work out of a svn repository as well. There is also a dreamweaver plugin that works off or tortoise svn if you need that.
  10. on a linux server you want to use \n instead of \r\n for your email headers. You also want to comment out ini_set('sendmail_from', $senderemail); because it does not get used on linux.
  11. Tushay Sir! Maybe slower but will work with any well formatted date not just one with slashes.
  12. this is a little simpler. $date = date('Y-m-d',strtotime($date));
  13. This works. html, body { height:100%; margin:0; padding:0; background: blue; } #main { margin:0 auto 0 auto; height:100%; width:1024px; } #right, #left { color:white; float:left; padding: 1em; margin:0; width:15%; height:100%; background: blue; } #content { margin:0; width:60%; float:left; height:100%; padding: 1em; background-color:#76D16B; } <body> <div id="main"> <div id="left">LEFT</div> <div id="content"> There is a lot of content in here d@mnit dkkkkkkkkk kkkkkkkkkk k k kkkkkkkkkkk kkkkkkkkkkkkk kkkkkkk kkkkkkkk kkkkkkkkk kkkkkkkkkkkk kkkkkkkk kkkkkkkkk kkkkkkkkk kkkkkkkkkkkkk kkkkkkkk kkkkkk kkkkkk kkkkkkkk kkkkkkkkkkkk kkkkk </div> <div id="right">RIGHT</div> </div> </body>
  14. Opps sorry looks like there is a syntax error in mine. Here is mine correct. ini_set('include_path', ini_get('include_path') . ':/path/to/the/additional/path/'); thorpe's is better though. I forgot about the php functions for set_include_path() and get_include_path(). This is a cleaner way. And yes the absolute path does not have to be in your web root. Specify it from the servers root. What you want to do is create a config file for your application that always gets run first. Just put this in that config file then include that file at the top of all outward facing files. Never duplicate code. Write it once and reuse it.
  15. If you are 100% certain the path is correct it could be a corrupt image file. I've seen problem when IE could not display an image that FireFox could and optimizing the image with photoshop fixed the problem. But again triple check to make sure the file name and path is all correct. Then go to using and image application like photoshop to optimize the image.
  16. Here you go. Look like you can download that script here. http://www.soft-spot.co.uk/searchscript.htm
  17. You can set your include path by using ini_set() prior to everything else. This works best if done in an include file that is always loaded first. ini_set('include_path', ini_get('include_path') . ':'/path/to/the/additional/path/'); And since you mentioned it Hostmysite.com has some pretty awesome hosting.
  18. However you authenticate your user's creds simply redirect them to a particular location. The resulting url will be entirely up to your application design. You would never actually have real files for each user. Instead you make one user home page with dynamic content based on the username provided. #pseudo code if authenticated store username in a session $_SESSION['username'] = $username; redirect to /mypage.php?friend=$_SESSION['username']
  19. Give this a shot <input type="text" name="item[1]"> Item 1 <input type="text" name="item[2]"> Item 2 <input type="text" name="item[3]"> Item 3 <input type="text" name="item[4]"> Item 4 <?php if(isset($_POST['item'])) { arsort($_POST['item'],SORT_NUMERIC); $sortedArray = array_reverse($_POST['item'],true); foreach($sortedArray as $item => $order) { echo 'Item number: '.$item.' Ordered value: '.$order.'<br />'; } } ?> This stores the item number in a var called $item and the order by value in the var called $order.
  20. Add a hundred bucks to your quote and buy this. http://www.milldo.com/en16_uk_post_codes_database.htm Problem solved.
  21. As long as the structure of the feed does not change this should work <?php $feedUrl = 'http://www.metacafe.com/api/item/2348336'; $rawFeed = file_get_contents($feedUrl); $handle = xml_parser_create(); xml_parse_into_struct($handle, $rawFeed, $vals, $index); xml_parser_free($handle); echo 'Duration = '. $vals[44]['attributes']['DURATION']; ?> If you are worried the structure might change you can loop through the vals array until you find the key 'DURATION' then display its value.
  22. osCommerce is practically abandon wear at this point. I'd recommend something that has a more active community like zen-cart. http://www.zen-cart.com
  23. topflight Hybrid Kill3r's answer should work for you. To learn from this study the sql statements. He has added ORDER BY ".$sort." ASC" to them. The order by clause will sort the selected rows on the mysql database before the information is returned. To go in reverse order you would use DESC in the place of ASC.
  24. Here is one I found that looks pretty good. http://www.spoono.com/php/tutorials/tutorial.php?id=43 This tutorial shows the use of php with a mysql database.
  25. You have not specified a height or width in the css file for #imagetest. Define the height and width to match that of your image. Once you add this it should fix a few of your problems. Now something to think about. Only do this if your image really should be a background image. Background images are typically used for the design of your site. You should not use the background image css property to just display an image that is part of your site's content. Design and content are two different things. If your image should be considered part of the content use the img tag so that you have the benefits of the img alt attribute. Alt contents get indexed by search bots. If your image is part of the design use the css background image method.
×
×
  • 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.