Jump to content

phparray

Members
  • Posts

    96
  • Joined

  • Last visited

    Never

Contact Methods

  • Website URL
    http://www.hostmysite.com/?utm_source=bb

Profile Information

  • Gender
    Not Telling

phparray's Achievements

Newbie

Newbie (1/5)

0

Reputation

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