Jump to content

QuickOldCar

Staff Alumni
  • Posts

    2,972
  • Joined

  • Last visited

  • Days Won

    28

Everything posted by QuickOldCar

  1. This should be easier to read, enclose in the code tags please. Change your mysql connection credentials, you posted them online for everyone to see. <?php $id=$_REQUEST['id']; $firstname=$_GET['firstname']; $surname=$_GET['surname']; $db="prs"; $link=mysql_connect("localhost",".....",".....") or die("Cannot Connect to the database!"); mysql_select_db($db,$link) or die ("Cannot select the database!"); $query="DELETE FROM students WHERE upn='".$id."'"; if(!mysql_query($query,$link)) { die ("An unexpected error occured while <b>deleting</b> the record, Please try again!"); } else { echo "Student with Student Number #".$id." ".$firstname." ".$surname." removed successfully!"; } ?>
  2. You mean something like this? $image_number = floor($json['Rating']).".png"; So if the json value was 7.5, it would become 7.png
  3. I thought I explained it to you. And it's an example of how I check for duplicate urls, I wasn't trying to make you a complete code. If you needed more or different you can edit it. If not then don't use any of my advice and continue what you were doing.
  4. Might as well do this all one line, the missing quote was messing me up before. $image_number = str_replace(".","",$json['Rating']).".png";
  5. Missed a single quote $image_number = $json['Rating']; $image_number = str_replace(".","",$image_number).".png"; echo $image_number;
  6. Here's a simple example <?php $rating = "7.5/10"; $rating_number = explode("/",$rating); $rating_number[0] = str_replace(".","",$rating_number[0]); $image_number = $rating_number[0].".png"; echo $image_number; ?> But in your case you already have value can use. $image_number = $json['Rating]; $image_number = str_replace(".","",$image_number).".png"; echo $image_number;
  7. Do the renaming in the first for loop, and get rid of that second loop It's just as easy to add a timestamp to the front of the image name if (move_uploaded_file($_FILES['images']['tmp_name'][$i], $upload_directory . time()."-".$_FILES['images']['name'][$i])) {
  8. I agree with kingphillip. Although many languages have similar functionality, some also have unique built in functions another may not have. Knowing a functions name along with proper usage is key. It's more about familiarity with what a language does or does not have, and using the proper formats as well. For any coding language, it still takes time to learn it properly, or they are just "winging" it with the basics.
  9. Sorry to hear about your last boyfriend. If you can post any relevant code, I'm sure someone would help you out.
  10. Your main concern should be looking for duplicates of websites, the titles shouldn't matter. also parsing the websites would help to prevent duplicate sites such as different protocols like http versus https. http://mysite.com, www.mysite.com, mysite.com, mysite.com/index.php, mysite.com/whatever/whatever Your goal is to list the website and just one of them. Users should be able to post more than one, so as long as check for username,password,email, then continue with the rest of script. Here is just an example of how I do it, although i run them through curl first to see if they are a real url and follow redirects You probably want to not add any feed and ftp type protocols, can edit all that to how you want. <form action="" method="POST"> <input type="text" name="site" value="<?php echo $_POST['site'];?>" placeholder="site url" /> <input type="text" name="title" value="<?php echo $_POST['title'];?>" placeholder="site title" /> <input type="submit" value="Add Site" /> </form> <?php if (isset($_POST['site']) && $_POST['site'] != "" && isset($_POST['title']) && $_POST['title'] != "") { $url_input = $_POST['site']; $title_input = $_POST['title']; function getparsedHost($new_parse_url) { $parsedUrl = parse_url(trim($new_parse_url)); return strtolower(trim($parsedUrl['host'] ? $parsedUrl['host'] : array_shift(explode('/', $parsedUrl['path'], 2)))); } //much easier to resolve urls with curl and also be sure that site exists, but lets try and fix some if ((substr($url_input, 0, == "https://") || (substr($url_input, 0, 12) == "https://www.") || (substr($url_input, 0, 7) == "http://") || (substr($url_input, 0, 11) == "http://www.") || (substr($input_parse_url, 0, 6) == "ftp://") || (substr($input_parse_url, 0, 11) == "feed://www.") || (substr($input_parse_url, 0, 7) == "feed://")) { $new_parse_url = $url_input; } else { $new_parse_url = "http://$url_input"; } //start mysql connection here include("config.php"); $site = str_ireplace("www.", "", getparsedHost($new_parse_url)); $site = mysql_real_escape_string($site); $title = mysql_real_escape_string($title_input); $q = mysql_query("SELECT * FROM `sites` WHERE `link`='".$site."'"); $check = mysql_num_rows($q); mysql_query("SET NAMES 'utf8'"); if($check > 0) { //or you can just display the already submitted site information to them instead of this update echo "The site was updated !!"; mysql_query("UPDATE `sites` SET link='$site',title='$title''"); } else { //if doesn't exist, insert new echo "The site was added.</h2>"; mysql_query("INSERT INTO `sites` (link,title) VALUES ('$site', '$title')"); } echo "Site: " . $site . "<br /> Title: " . $title; } else { echo "Please insert a site and title."; } ?>
  11. Just for the record, virtualmin is just an administration panel for you, and has nothing to do with what versions apache or php are running. create a new php file and place this code within it to see your version information. <?php phpinfo(); ?>
  12. The first link I could never connect to, and the second is very slow, but it appears the pagination works, as far as in the address bar goes. Posting code relevant to your problem here would get you better help.
  13. One thing can do is to include the youtu.be shortened urls The url text input for the form could also be longer
  14. Usually when doing a search the values are broken up by spaces, or by each $_POST or $_GET value and not a colon. And since using a colon is common for what you are doing, I feel it's a bad mix. But I see Muddy's code works for you. Alternately you can make a form breaking up these 3 values and use the post input a very simple example <form action="" method="POST"> <input type="text" name="book" value="<?php echo $_POST['book'];?>" placeholder="book name" /> <input type="text" name="chapter" value="<?php echo $_POST['chapter'];?>" placeholder="chapter number" /> <input type="text" name="verse" value="<?php echo $_POST['verse'];?>" placeholder="verse number" /> <input type="submit" value="Search" /> </form> You should be checking for empty or incorrect values, like if is an integer or not, and also escaping the users input before the mysql query.
  15. There's a simple javascript popup image script here that does what you want. http://www.codelifter.com/main/javascript/autosizeimagepopup.html
  16. Here's a good opensource editor can integrate into any site easily. http://www.tinymce.com/ Here's the demo. http://www.tinymce.com/tryit/full.php
  17. Could you possibly be seeing a cached version in your browser?
  18. ahh, yeah I missed this part. So 11 / 2 works 3 times I am using this to work out where my value falls in terms of power of 2 in a sequence
  19. How not good? 2 goes into 11 5 times
  20. $result = floor(sqrt(11)); echo $result; if x was 11, the result would be 3, so no good
  21. Using floor() is what were after <?php function divideCount($x,$y){ $value = floor($x/$y); return $value; } echo divideCount(11,2)."<br />"; echo divideCount(5,2)."<br />"; echo divideCount(2,2)."<br />"; ?>
  22. It's better when do it this way. php lottery system
  23. I'm sure if you have any drive-by-downloads.... they are coming through your ads. Go to the ad company your ads are coming from and check/filter through them.
  24. You can use google's search query api. But I'm pretty sure they have a max 64 results per query for their api's. I think would have to make yourself a scraper to do it properly, and even then, they only display x amount of results and then by date. While google may have no problem scraping your site continuously, they certainly will when you try and scrape them back. Here's an idea. Cycle through all your links, and for each link... check if the link exists at google or not through their search query api, save and tag the results into a database.
  25. I guess I will link to more information about doing this. http://www.w3.org/TR/html4/struct/objects.html#edef-AREA
×
×
  • 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.