Jump to content

QuickOldCar

Staff Alumni
  • Posts

    2,972
  • Joined

  • Last visited

  • Days Won

    28

Everything posted by QuickOldCar

  1. Yes I did, just got up, sorry
  2. Or you can just send them back a page using javascript if ($usename == 'User Name' || '') { die("You didn't insert a user name."<br /><a href=\"javascript: history.go(-1)\">Click here to try again </a>."); }
  3. <?php $username = $_POST['username']; $password = $_POST['password']; if ($username == 'User Name' || ''){ echo ("<br /><br /><div align='center' class='errorbox'>Please enter a valid username!</div>"); echo "<meta http-equiv='refresh' content='5;url=http://somesite.com/somepage.php"; } if ($password == 'Password' || ''){ echo ("<br /><br /><div align='center' class='errorbox'>Please enter a valid password!</div>"); echo "<meta http-equiv='refresh' content='5;url=http://somesite.com/somepage.php"; } ?>
  4. I see no reason for this part print_r($images);
  5. Well since this seems like an interesting topic to me I'll write some more. For my dynaindex, I had to give it 2 years of thought in my head before one line of code was written. It took me that long to come up with something I thought could possibly work. I had the idea, I wanted to do it, so attempted in a variety of ways and came to the conclusion of which way was the best way in the long run. Then sitting down and in 3 months with much frustration and hurdles, I finally got something acceptable to me, and progressed with that. I decided to make my own cms/platform so I had more control over it, if there was to be an error somewhere, it was my error and I should be able to find and fix it. For the past 9 months as I use and add features to the site, if I see something I don't like, I make a rule for that squished in somewhere between the rest of my code, sometimes completely rewrite the entire function or process. Other times if is a specific function, then a complete new folder which would include text files and a few separate php files. Basically after all I said above, have the idea, think of a few ways could possibly do it, then attempt to write some code that does it. If those codes don't work the way you want, try a different way you think of. That's the beauty of php.
  6. I agree with what Anti-Moronic said. Additionally you should create a structure that could easily be added upon or edited for the future. Organization is your friend. Make yourself an include folder for any included files like functions, have a cache folder, an images folder, make it so that when need to find something you have a pretty good idea where to look for it. Such as your votes as a for instance, you can add to the code directly to your pages or include a folder or file of this code to be used, then reference to it from the visible page. I feel the most important thing would be flexibility. Mostly thought is required of what you need to get accomplished for the task at hand. There is many instances where there may not be an answer and must be creative, or is multiple ways to get the task done. Many times is trial and error for the most reliable, fastest results, least server usage, adaptable and any other requirements of running a specific website. So you have your basic website built and platform, now just keep adding additional features that you would like it to have. Test the site often for the changes you make so you don't end up having many errors at the end and having a complete mess. I would even suggest having a backup folder of your codes so can always revert back.
  7. What that usually means is you need to have your session at the top of the page and it's not, something must be coming before your session.
  8. print_r is used to show the values of an array lets assume $images is the array. or can be looked at as array($images) foreach ($images as $image) { echo $image; }
  9. Here is a simple form to get you going. I made for a dropdown and also a text input to test Is 2 ways to do, either set the mysql select and include the year variable, or do a multi mysql query. <html> <head> </head> <body> <? //year_value i used because year is no doubt used elsewhere $year_value = $_GET['year_value']; if ($year_value == "2010") { echo "Insert mysql select query here and using $year_value"; } elseif ($year_value == "2009"){ echo "Insert mysql select query here and using $year_value"; } elseif ($year_value == "2008"){ echo "Insert mysql select query here and using $year_value"; } elseif ($year_value == "2007"){ echo "Insert mysql select query here and using $year_value"; } else { echo "<h3>no year selected or a default query<br />I used the text input</h3>"; } echo "<br />"; // or use a simple method of placing the get value into the mysql query //$result = mysql_query("SELECT * FROM `$database_table` WHERE `year` = '$year_value' order by setlist_id DESC, year, month, day",$db) //or die_now("Could not select shows"); ?> Example using dropdow select <form name="input" action="" method="get"> Year:<Select style="color: #FFFFFF; font-family: Verdana; font-weight: bold; font-size: 12px; background-color: #000000;" name="year_value"> <option "Input" style="color: #FFFFFF; font-family: Verdana; font-weight: bold; font-size: 12px; background-color: #000000;" size="15" value="2010">2010</option> <option style="color: #FFFFFF; font-family: Verdana; font-weight: bold; font-size: 12px; background-color: #000000;" size="15" value="2009">2009</option> <option style="color: #FFFFFF; font-family: Verdana; font-weight: bold; font-size: 12px; background-color: #000000;" size="15" value="2008">2008</option> <option style="color: #FFFFFF; font-family: Verdana; font-weight: bold; font-size: 12px; background-color: #000000;" size="15" value="2007">2007</option> </select> <input type="submit" style="color: #FFFFFF; font-family: Verdana; font-weight: bold; font-size: 12px; background-color: #000000;" size="15" value="Get Year" /> </form> Example using text input <form name="input" action="" method="get"> Year:<input onfocus="this.value=''" size="15" type="text" name="year_value" style="color: #FFFFFF; font-family: Verdana; font-weight: bold; font-size: 12px; background-color: #000000;" size="15" value="<?php echo $_GET['year_value']; ?>"/> <input type="submit" style="color: #FFFFFF; font-family: Verdana; font-weight: bold; font-size: 12px; background-color: #000000;" size="15" value="Get Year" /> </form> </body> </html>
  10. What I do is a dropdown select with different get values, then depending on which is chosen it will fetch the different data from mysql. As a last result i do a mysql query in case something input was wrong, so has something as a default to display. For my example I do a self made search navigation system and also integrated a search in boolean mode, full text indexes for that would be advised, the start and stop rows limit was set by using what page number it's on. The below example should give you the idea what to do for your multi-select queries. if ($search == "Date") { $result = mysql_query("SELECT * FROM posts WHERE post_status='publish' AND MATCH (post_date) AGAINST ('\"$search_words\"' IN BOOLEAN MODE) ORDER BY $display $order LIMIT $startrow,$posts_per_page" ); $total_count = mysql_query("SELECT * FROM wp_posts $post_status AND MATCH (post_date) AGAINST ('\"$search_words\"' IN BOOLEAN MODE)"); } elseif ($search == "ID") { $result = mysql_query("SELECT * FROM posts WHERE post_status='publish' AND ID LIKE '".$search_words."%' ORDER BY $display $order LIMIT $startrow,$posts_per_page" ); $total_count = mysql_query("SELECT * FROM posts WHERE post_status='publish' AND ID LIKE '".$search_words."%'"); } elseif ($search == "url_begins_characters") { $result = mysql_query("SELECT * FROM posts WHERE post_status='publish' AND post_title LIKE '".$search_words."%' ORDER BY $display $order LIMIT $startrow,$posts_per_page" ); $total_count = mysql_query("SELECT * FROM posts WHERE post_status='publish' AND post_title LIKE '".$search_words."%'"); } elseif ($search == "url_contains_characters") { $result = mysql_query("SELECT * FROM posts WHERE post_status='publish' AND post_title LIKE '%"."$search_words"."%' ORDER BY $display $order LIMIT $startrow,$posts_per_page" ); $total_count = mysql_query("SELECT * FROM posts WHERE post_status='publish' AND post_title LIKE '%"."$search_words"."%'"); } elseif ($search == "feed_single_word") { $result = mysql_query("SELECT * FROM posts WHERE post_status='publish' AND link_rss LIKE '%"."$search_words"."%' ORDER BY $display $order LIMIT $startrow,$posts_per_page" ); $total_count = mysql_query("SELECT * FROM posts WHERE post_status='publish' AND link_rss LIKE '%"."$search_words"."%'"); } elseif ($search == "one_word") { $result = mysql_query("SELECT * FROM posts WHERE post_status='publish' AND MATCH (post_title,post_content) AGAINST ('$search_words' IN BOOLEAN MODE) ORDER BY $display $order LIMIT $startrow,$posts_per_page" ); $total_count = mysql_query("SELECT * FROM posts WHERE post_status='publish' AND MATCH (post_title,post_content) AGAINST ('$search_words' IN BOOLEAN MODE)"); } elseif ($search == "exact_words") { $result = mysql_query("SELECT * FROM posts WHERE post_status='publish' AND MATCH (post_title,post_content) AGAINST ('\"$search_words\"' IN BOOLEAN MODE) ORDER BY $display $order LIMIT $startrow,$posts_per_page" ); $total_count = mysql_query("SELECT * FROM posts WHERE post_status='publish' AND MATCH (post_title,post_content) AGAINST ('\"$search_words\"' IN BOOLEAN MODE)"); } elseif ($search == "least_one_word") { $result = mysql_query("SELECT * FROM posts WHERE post_status='publish' AND MATCH (post_title,post_content) AGAINST ('$search_words' IN BOOLEAN MODE) ORDER BY $display $order LIMIT $startrow,$posts_per_page" ); $total_count = mysql_query("SELECT * FROM posts WHERE post_status='publish' AND MATCH (post_title,post_content) AGAINST ('$search_words' IN BOOLEAN MODE)"); } elseif ($search == "exclude_word") { $result = mysql_query("SELECT * FROM posts WHERE post_status='publish' AND MATCH (post_title,post_content) AGAINST ('+$search_words -$search_words' IN BOOLEAN MODE) ORDER BY $display $order LIMIT $startrow,$posts_per_page" ); $total_count = mysql_query("SELECT * FROM posts WHERE post_status='publish' AND MATCH (post_title,post_content) AGAINST ('+$search_words -$search_words' IN BOOLEAN MODE)"); } elseif ($search == "title_one_word") { $result = mysql_query("SELECT * FROM posts WHERE post_status='publish' AND MATCH (title_2) AGAINST ('$search_words' IN BOOLEAN MODE) ORDER BY $display $order LIMIT $startrow,$posts_per_page" ); $total_count = mysql_query("SELECT * FROM posts WHERE post_status='publish' AND MATCH (title_2) AGAINST ('$search_words' IN BOOLEAN MODE)"); } elseif ($search == "title_exact_words") { $result = mysql_query("SELECT * FROM posts WHERE post_status='publish' AND MATCH (title_2) AGAINST ('\"$search_words\"' IN BOOLEAN MODE) ORDER BY $display $order LIMIT $startrow,$posts_per_page" ); $total_count = mysql_query("SELECT * FROM posts WHERE post_status='publish' AND MATCH (title_2) AGAINST ('\"$search_words\"' IN BOOLEAN MODE)"); } elseif ($search == "title_least_one_word") { $result = mysql_query("SELECT * FROM posts WHERE post_status='publish' AND MATCH (title_2) AGAINST ('$search_words' IN BOOLEAN MODE) ORDER BY $display $order LIMIT $startrow,$posts_per_page" ); $total_count = mysql_query("SELECT * FROM posts WHERE post_status='publish' AND MATCH (title_2) AGAINST ('$search_words' IN BOOLEAN MODE)"); } elseif ($search == "title_exclude_word") { $result = mysql_query("SELECT * FROM posts WHERE post_status='publish' AND MATCH (title_2) AGAINST ('+$search_words -$search_words' IN BOOLEAN MODE) ORDER BY $display $order LIMIT $startrow,$posts_per_page" ); $total_count = mysql_query("SELECT * FROM posts WHERE post_status='publish' AND MATCH (title_2) AGAINST ('+$search_words -$search_words' IN BOOLEAN MODE)"); } elseif ($search == "description_one_word") { $result = mysql_query("SELECT * FROM posts WHERE post_status='publish' AND MATCH (post_description) AGAINST ('$search_words' IN BOOLEAN MODE) ORDER BY $display $order LIMIT $startrow,$posts_per_page" ); $total_count = mysql_query("SELECT * FROM posts WHERE post_status='publish' AND MATCH (post_description) AGAINST ('$search_words' IN BOOLEAN MODE)"); } elseif ($search == "description_exact_words") { $result = mysql_query("SELECT * FROM posts WHERE post_status='publish' AND MATCH (post_description) AGAINST ('\"$search_words\"' IN BOOLEAN MODE) ORDER BY $display $order LIMIT $startrow,$posts_per_page" ); $total_count = mysql_query("SELECT * FROM posts WHERE post_status='publish' AND MATCH (post_description) AGAINST ('\"$search_words\"' IN BOOLEAN MODE)"); } elseif ($search == "description_least_one_word") { $result = mysql_query("SELECT * FROM posts WHERE post_status='publish' AND MATCH (post_description) AGAINST ('$search_words' IN BOOLEAN MODE) ORDER BY $display $order LIMIT $startrow,$posts_per_page" ); $total_count = mysql_query("SELECT * FROM posts WHERE post_status='publish' AND MATCH (post_description) AGAINST ('$search_words' IN BOOLEAN MODE)"); } elseif ($search == "description_exclude_word") { $result = mysql_query("SELECT * FROM posts WHERE post_status='publish' AND MATCH (post_description) AGAINST ('+$search_words -$search_words' IN BOOLEAN MODE) ORDER BY $display $order LIMIT $startrow,$posts_per_page" ); $total_count = mysql_query("SELECT * FROM posts WHERE post_status='publish' AND MATCH (post_description) AGAINST ('+$search_words -$search_words' IN BOOLEAN MODE)"); } elseif ($search == "keyword_one_word") { $result = mysql_query("SELECT * FROM posts WHERE post_status='publish' AND MATCH (post_keywords) AGAINST ('$search_words' IN BOOLEAN MODE) ORDER BY $display $order LIMIT $startrow,$posts_per_page" ); $total_count = mysql_query("SELECT * FROM posts WHERE post_status='publish' AND MATCH (post_keywords) AGAINST ('$search_words' IN BOOLEAN MODE)"); } elseif ($search == "keyword_exact_words") { $result = mysql_query("SELECT * FROM posts WHERE post_status='publish' AND MATCH (post_keywords) AGAINST ('\"$search_words\"' IN BOOLEAN MODE) ORDER BY $display $order LIMIT $startrow,$posts_per_page" ); $total_count = mysql_query("SELECT * FROM posts WHERE post_status='publish' AND MATCH (post_keywords) AGAINST ('\"$search_words\"' IN BOOLEAN MODE)"); } elseif ($search == "keyword_least_one_word") { $result = mysql_query("SELECT * FROM posts WHERE post_status='publish' AND MATCH (post_keywords) AGAINST ('$search_words' IN BOOLEAN MODE) ORDER BY $display $order LIMIT $startrow,$posts_per_page" ); $total_count = mysql_query("SELECT * FROM posts WHERE post_status='publish' AND MATCH (post_keywords) AGAINST ('$search_words' IN BOOLEAN MODE)"); } elseif ($search == "keyword_exclude_word") { $result = mysql_query("SELECT * FROM posts WHERE post_status='publish' AND MATCH (post_keywords) AGAINST ('+$search_words -$search_words' IN BOOLEAN MODE) ORDER BY $display $order LIMIT $startrow,$posts_per_page" ); $total_count = mysql_query("SELECT * FROM posts WHERE post_status='publish' AND MATCH (post_keywords) AGAINST ('+$search_words -$search_words' IN BOOLEAN MODE)"); } else { //if anything goes wrong above or nothing selected, this will be used as the default query instead $result = mysql_query("SELECT * FROM posts WHERE post_status='publish' AND post_date LIKE '".$today_date."%' ORDER BY $display $order LIMIT $startrow,$posts_per_page" ); $total_count = mysql_query("SELECT * FROM posts WHERE post_status='publish' AND post_date LIKE '".$today_date."%'"); }
  11. Got a link to where you wanna get stuff from? You may be able to do it with simple html dom. http://simplehtmldom.sourceforge.net/
  12. Well actually I use this, I also have another post counter that uses a mysql db and different, if needed that just ask, because can call for the highest votes and all that jazz. Your code was just basic file read, and a little gd, very common stuff. <?php /* name this file index.php and place it into a folder called counters the function will create a unique text file for each unique item, good for posts or pages and store all the files in the counters folder For the total website views,add this to your header file or top of your page <?php include('counters/index.php'); $website_view_url = "http://".$_SERVER['HTTP_HOST']; } $website_views = getViews("$website_view_url"); echo "<br />".$website_views."<br />"; ?> For the total pages or scripts views,add this to your header file or top of your page <?php include('counters/index.php'); $total_page_view_url = "http://".$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME']; } $total_page_views = getViews("$total_page_view_url"); echo "<br />".$total_page_views."<br />"; ?> For entire urls including queries,add this to your header file or top of your page <?php include('counters/index.php'); $page_queries_view_url = "http://".$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME']; if (!empty($_SERVER["QUERY_STRING"])) { $page_queries_view_url .= "?".$_SERVER['QUERY_STRING']; } $page_queries_views = getViews("$page_queries_view_url"); echo "<br />".$page_queries_views."<br />"; ?> for usage in posts like by id: if do not want the pages counted and did not do the above code,include the below somewhere near the beginning of your page <?php include('counters/index.php');?> Then in the posts loop, you can associate your $row['id']; or some other unique value <?php $post_views = $row['id']; $post_views = getViews("$post_views"); echo "<br />Post Views ".$post_views."<br />"; ?> if would like to combine any the above or use them all, just be sure to just include include('counters/index.php'); only one time */ function getViews($views_count_value) { $views_count_value = md5("$views_count_value"); $views_count_file_name = "counters/$views_count_value.txt"; if (!file_exists($views_count_file_name)) { $views_count =0; $file_handle = fopen($views_count_file_name, 'w') or die("can't open file"); fwrite($file_handle, "$views_count"); fclose($file_handle); } $file_handle = fopen($views_count_file_name, "r"); $views_count = fread($file_handle, filesize("$views_count_file_name")); fclose($file_handle); if ($views_count <= 0){ $views_count =1; } else { ++$views_count; } $file_handle = fopen($views_count_file_name, "w+"); fwrite($file_handle, "$views_count"); fclose($file_handle); return("$views_count"); } ?>
  13. Look into the pstools suite and specifically psexec. http://technet.microsoft.com/en-us/sysinternals/bb896649
  14. I been trying these url's with my thumbnailer, and so far they been working, but maybe ms is just down at the times that are trying to get them and didn't work. Maybe you should cache the images if use the same ones a lot.
  15. No am just being nice and helping someone who may need this. I was editing the code, but then couldn't edit it, so please use the code below. <?php /* name this file index.php and place it into a folder called counters the function will create a unique text file for each unique item, good for posts or pages and store all the files in the counters folder For the total website views,add this to your header file or top of your page <?php include('counters/index.php'); $website_view_url = "http://".$_SERVER['HTTP_HOST']; } $website_views = getViews("$website_view_url"); echo "<br />".$website_views."<br />"; ?> For the total pages or scripts views,add this to your header file or top of your page <?php include('counters/index.php'); $total_page_view_url = "http://".$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME']; } $total_page_views = getViews("$total_page_view_url"); echo "<br />".$total_page_views."<br />"; ?> For entire urls including queries,add this to your header file or top of your page <?php include('counters/index.php'); $page_queries_view_url = "http://".$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME']; if (!empty($_SERVER["QUERY_STRING"])) { $page_queries_view_url .= "?".$_SERVER['QUERY_STRING']; } $page_queries_views = getViews("$page_queries_view_url"); echo "<br />".$page_queries_views."<br />"; ?> for usage in posts like by id: if do not want the pages counted and did not do the above code,include the below somewhere near the beginning of your page <?php include('counters/index.php');?> Then in the posts loop, you can associate your $row['id']; or some other unique value <?php $post_views = $row['id']; $post_views = getViews("$post_views"); echo "<br />Post Views ".$post_views."<br />"; ?> if would like to combine any the above or use them all, just be sure to just include include('counters/index.php'); only one time */ function getViews($views_count_value) { $views_count_value = md5("$views_count_value"); $views_count_file_name = "counters/$views_count_value.txt"; if (!file_exists($views_count_file_name)) { $views_count =0; $file_handle = fopen($views_count_file_name, 'w') or die("can't open file"); fwrite($file_handle, "$views_count"); fclose($file_handle); } $file_handle = fopen($views_count_file_name, "r"); $views_count = fread($file_handle, filesize("$views_count_file_name")); fclose($file_handle); if ($views_count <= 0){ $views_count =1; } else { ++$views_count; } $file_handle = fopen($views_count_file_name, "w+"); fwrite($file_handle, "$views_count"); fclose($file_handle); return("$views_count"); } ?>
  16. I made this for my site and decided to share with the community. Depending on how you do the code and where, this can keep count of the views in different ways. Please read the somewhat directions have in the code, make a folder called counters, and be sure to include this below function file. I named the function file index.php and belongs in the counters folder you make. <?php /* name this file index.php and place it into a folder called counters the function will create a unique text file for each unique item, good for posts or pages and store all the files in the counters folder For the total website views,add this to your header file or top of your page <?php include('counters/index.php'); $website_view_url = "http://".$_SERVER['HTTP_HOST']; } $website_views = getViews("$website_view_url"); echo "<br />".$website_views."<br />"; ?> For the total pages or scripts views,add this to your header file or top of your page <?php include('counters/index.php'); $total_page_view_url = "http://".$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME']; } $total_page_views = getViews("$total_page_view_url"); echo "<br />".$total_page_views."<br />"; ?> For entire urls including queries,add this to your header file or top of your page <?php include('counters/index.php'); $page_queries_view_url = "http://".$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME']; if (!empty($_SERVER["QUERY_STRING"])) { $page_queries_view_url .= "?".$_SERVER['QUERY_STRING']; } $page_queries_views = getViews("$page_queries_view_url"); echo "<br />".$page_views."<br />"; ?> for usage in posts like by id: if do not want the pages counted and did not do the above code,include the below somewhere near the beginning of your page <?php include('counters/index.php');?> Then in the posts loop, you can associate your $row['id']; or some other unique value <?php $post_views = $row['id']; $post_views = getViews("$post_views"); echo "<br />Post Views ".$post_views."<br />"; ?> if would like to combine any the above or use them all, just be sure to just include include('counters/index.php'); only one time */ function getViews($views_count_value) { $views_count_value = md5("$views_count_value"); $views_count_file_name = "counters/$views_count_value.txt"; if (!file_exists($views_count_file_name)) { $views_count =0; $file_handle = fopen($views_count_file_name, 'w') or die("can't open file"); fwrite($file_handle, "$views_count"); fclose($file_handle); } $file_handle = fopen($views_count_file_name, "r"); $views_count = fread($file_handle, filesize("$views_count_file_name")); fclose($file_handle); if ($views_count <= 0){ $views_count =1; } else { ++$views_count; } $file_handle = fopen($views_count_file_name, "w+"); fwrite($file_handle, "$views_count"); fclose($file_handle); return("$views_count"); } ?>
  17. I changed the code more, this one def works even if is no value in hits.txt <?php /** * @author Jragon * @copyright 2010 */ getHits(); function getHits() { $file = "hits.txt"; $fh = fopen($file, "r"); $hits = @fread($fh, filesize("$file")); fclose($fh); if ($hits <= 0){ $hits =1; } else { ++$hits; } $fh = fopen($file, "w+"); fwrite($fh, "$hits"); fclose($fh); getImage("$hits"); } function getImage($string) { //Make $string to to a string $string = "$string"; //Define fontsize $font = 5; //use imagefontwidth to find out the widht of each charicter, //then times it by how many charicters theere are, //and add some padding. $width = imagefontwidth($font) * strlen($string) + 10; //height of a charicter, and add some padding. $height = imagefontheight($font) + 10; //random color thingy. $r = rand(25, 250); $g = rand(25, 250); $b = rand(25, 250); //create a blank image using the dimsions set above. $image = imagecreate($width, $height); //set the background color $background_color = imagecolorallocate($image, 0, 0, 0); //set the text color using the random integers made above. $text_color = imagecolorallocate($image, $r, $g, $b); //Put the text into the image. imagestring($image, $font, 6, 6, $string, $text_color); //Change the type of webpage so you see the image header("Content-type: image/png"); //put everything together and make the image imagepng($image); //free up some space on the temp drive imagedestroy($image); } ?>
  18. I tried the code and works fine. But you had if was no value of at least 1 it would not work, so I added a small rule to be at least 1 hit. working example here: http://dynaindex.com/counter/ <?php /** * @author Jragon * @copyright 2010 */ getHits(); function getHits() { $file = "hits.txt"; $fh = fopen($file, "r"); $hits = fread($fh, filesize("$file")); if ($hits <= 1) { $hits =1; } fclose($fh); ++$hits; $fh = fopen($file, "w+"); fwrite($fh, "$hits"); fclose($fh); getImage("$hits"); } function getImage($string) { //Make $string to to a string $string = "$string"; //Define fontsize $font = 5; //use imagefontwidth to find out the widht of each charicter, //then times it by how many charicters theere are, //and add some padding. $width = imagefontwidth($font) * strlen($string) + 10; //height of a charicter, and add some padding. $height = imagefontheight($font) + 10; //random color thingy. $r = rand(25, 250); $g = rand(25, 250); $b = rand(25, 250); //create a blank image using the dimsions set above. $image = imagecreate($width, $height); //set the background color $background_color = imagecolorallocate($image, 0, 0, 0); //set the text color using the random integers made above. $text_color = imagecolorallocate($image, $r, $g, $b); //Put the text into the image. imagestring($image, $font, 6, 6, $string, $text_color); //Change the type of webpage so you see the image header("Content-type: image/png"); //put everything together and make the image imagepng($image); //free up some space on the temp drive imagedestroy($image); } ?>
  19. To lower the word length edit your my.ini or my.cnf file depending what os using. So in the mysql: ft_min_word_len = 3 then restart naturally. Trying the double fields is quick solution, if wanted more advanced like exact phrases and exclude, look into doing searches in boolean mode, but would also need full text indexes. http://dev.mysql.com/doc/refman/5.1/en/fulltext-boolean.html
  20. Try adding timestamp, because there could only be one. Try this. <?php //This is the directory where images will be saved $timestamp = time(); $target = "image/"; $target = $target.$timestamp. '-' . basename( $_FILES['photo']['name']); //This gets all the other information from the form $name=$_POST['name']; $email=$_POST['email']; $phone=$_POST['phone']; $pic = $timestamp. '-' . $_FILES['photo']['name']; // Connects to your Database mysql_connect("localhost", "data_admin2", "data25") or die(mysql_error()) ; mysql_select_db("Resumebank") or die(mysql_error()) ; //Writes the photo to the server move_uploaded_file($_FILES['photo']['tmp_name'], $target); //Writes the information to the database mysql_query("INSERT INTO `employee` VALUES ('$name', '$email', '$phone', '$pic')") ; echo "The file has been uploaded, and your information has been added to the directory"; ?>
  21. I second that statement. School is to learn, if you don't even try to do it and ask for someone else to do it for you, then you are not really learning.
  22. No idea why would want every second. But how about a meta redirect. echo('<meta http-equiv="refresh" content="1">'); or can point it somewhere also echo('<meta http-equiv="page.php" content="1">');
  23. Use LIMIT in your select query. 0 is starting from where, 10 is the max limit from the starting point displays the first 10 results from the database SELECT * FROM `your_table` LIMIT 0, 10 displays records 6, 7, 8, 9,,10 SELECT * FROM `your_table` LIMIT 5, 5 $searchterm = $_POST['searchterm']; trim ($searchterm); /*check if search term was entered*/ if (!$searchterm){ echo 'Please enter a search term.'; echo $searchterm; } /*add slashes to search term*/ if (!get_magic_quotes_gpc()) { $searchterm = addslashes($searchterm); } /*query the database*/ $query = "SELECT * from (products LEFT JOIN categories_products_link ON products.prod_id = categories_products_link.prod_id) LEFT JOIN categories ON categories_products_link.cat_id = categories.cat_id WHERE prod_title LIKE '%" . $searchterm . "%' ORDER BY cat_title, prod_title LIMIT 0,1"; $result = mysql_query($query); /*number of rows found*/ $num_results = mysql_num_rows($result); echo '<p><h1>Search Results: '.$num_results.'</h1></p><br />'; /*loops through results*/ for ($i=0; $i <$num_results; $i++) { $num_found = $i + 1; $row = mysql_fetch_assoc($result); echo "$num_found. "?><a href="store-<?php echo $row['cat_id'];?>-<?php echo $row['prod_id']; ?>/<?php echo seo_makeSafeURI($row['prod_title']); ?>.html"><strong><?php echo $row['prod_title']; ?></strong></a> <br />
  24. It sounds to me you need something more like html dom and to fetch tags from the page, like images,href, or anything else you want located in a divider or in the html. http://simplehtmldom.sourceforge.net/
  25. I added a closing statement to the while loop, not sure if this was your complete code or not. $db = mysql_connect($host,$user,$pw) or die("Cannot connect to MySQL."); mysql_select_db($database,$db) or die("Cannot connect to database."); echo "Success! Connected to database ".$database."<br /><br />"; // $jsearch is variable sent in from form "title" name $jsearch = $_POST['jobsearch']; // I confirmed that all the field names are correct //-query the database table $sql="SELECT id,title,details,status FROM jobs WHERE title = '$jsearch';"; //-run the query against the mysql query function $result=mysql_query($sql) or die("<br>Query string: $result<br>Returned error: " . mysql_error() ); //-create while loop and loop through result set while($row=mysql_fetch_array($result)){ $title =$row['title']; echo title."<br />"; $details=$row['details']; echo $details."<br />"; $status=$row['status']; echo $status."<br />"; $ID=$row['id']; }
×
×
  • 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.