Jump to content

RON_ron

Members
  • Posts

    370
  • Joined

  • Last visited

Everything posted by RON_ron

  1. I'd like a stright forward answer from you expert... I've got a bunch of mysql_real_string() statements in my codes. Can I just go ahead and replace the word mysql to mysqli? will it cause any problems?
  2. I've got the user signup time stored in a database formatted to my timezone. Can someone help me to find the difference between the current time and the stored time. This is my code - no success though. $tzone = new DateTimeZone('Asia/Manila'); $date = new DateTime('now', $tzone); $currenttime = $date->format('Y-m-d g:ia'); $userTimeFromDB = "2012-09-10 6:20pm"; $difference= ($userTimeFromDB - $currenttime); echo ($difference);
  3. RON_ron

    ||

    thanks spiderwell!
  4. RON_ron

    ||

    how do I include a OR to this statement? I tried the below... but no success. Could someone help? (my idea is to check the name and marks match and at the same time to check if the grade is 1 or 2) $result=sprintf("SELECT * FROM db WHERE name = '%s' AND marks ='%s' AND grade = '1' || grade = '2'", mysql_real_escape_string($person), mysql_real_escape_string($mark)); $results = mysql_query($result); if(mysql_num_rows ($results) == 0) { //// }
  5. I've got a database with a lot of ip addresses. I want to list the country names of them. I'm using the code below. $loc = file_get_contents('http://api.hostip.info/country.php?ip='.$ip); $countryName=Mage::app()->getLocale()->getCountryTranslation($loc); echo $countryName; 1. echo $loc shows the country code. But I need to echo the Country Name instead of the Country code? 2. Any better ideas to echo the country names using a list of ip addresses?
  6. thanks again jesirose! I'll keep that in mind...
  7. $place is not giving the expected output. I'm sure the issue is with the syntax? Could someone help me on this? $query = "SELECT * FROM db1 LEFT OUTER JOIN db2 ON db1.user = db2.User ORDER BY db1 user DESC"; $results = mysql_query($query); while($line = mysql_fetch_array($results)) { echo $line["user"]; echo $line["ip"]; $country = $line["ip"]; $place = file_get_contents('http://api.hostip.info/country.php?ip="$country"'); echo $place; }
  8. thanks jesirose!
  9. You are correct spiderwell. That's exactly what I need. Can you help?
  10. http://api.hostip.info/country.php?ip= gives the below result in my browser. XX how do I echo the result in php same as the result in the browser?
  11. I tried this but I'm not quite sure what's wrong? Could someone help? $query = "SELECT * FROM my_db1 LEFT OUTER JOIN my_db2 ON my_db1.City = my_db2.name ORDER BY my_db1.City DESC"; $results= mysql_query($query);
  12. I've 2 databases with a lot of records. I need a way to pull all the records of my_db2 and at the same time to pull the relevant record from my_db2 as a string.(e.g. NAME and CITY and ELIGIBILITY.). This is my code. But not outputting the way I want. (outputs only the first record). $query1 = "SELECT Name, City FROM my_db1 ORDER BY City DESC"; $results1 = mysql_query($query1); while($line1 = mysql_fetch_array($results1)) { $person = $line1["Name"]; echo $line1["Name"]." and "; echo $line1["City"]." and "; } $query2 = "SELECT eligibility FROM my_db2 WHERE name=$person"; $results2 = mysql_query($query2); while($line2 = mysql_fetch_array($results2)) { echo $line2["eligibility"]."."; }
  13. Cheers All!! I'm not really a php star - may I know briefly why? isn't this secure using mysql_real_escape_string?
  14. Thanks. This is the full code. if( get_magic_quotes_gpc() ) { $subjects = mysql_real_escape_string(stripslashes($_POST['subjects'])); $codeA = mysql_real_escape_string(stripslashes($_POST['codeA'])); } else { $subjects = mysql_real_escape_string($_POST['subjects']); $codeA = mysql_real_escape_string($_POST['codeA']); } $update = sprintf("INSERT INTO newdb (subject, code) VALUES ('%s', '%s')", mysql_real_escape_string($subjects), mysql_real_escape_string($codeA)); $result = mysql_query($update);
  15. I'm using this to store text in to the mysql db. the backslashes shows there.
  16. if( get_magic_quotes_gpc() ) { $subjects = mysql_real_escape_string(stripslashes($_POST['subjects'])); $codeA = mysql_real_escape_string(stripslashes($_POST['codeA'])); } else { $subjects = mysql_real_escape_string($_POST['subjects']); $codeA = mysql_real_escape_string($_POST['codeA']); } I'm using the above to maintain the new paragraphs (when the user hits the Enter key). But unfortunately the back slashes are still appearing... Could someone help me here?
  17. I need to implement a way to check if the web user belongs to 2 selected countries. can the IP address be used to identify the country?Any suggestions are highly appreciated.
  18. of course it's correct.
  19. $query3 =sprintf("SELECT * FROM student WHERE Mail ='%s' AND Usr = '1'", mysql_real_escape_string($Mail)); $query3a = mysql_query($query3); if(mysql_num_rows($query3a) > 0){ $res = sprintf("UPDATE student SET Pas = '%s' WHERE Mail = '%s'", mysql_real_escape_string($Ber), mysql_real_escape_string($Mail)); $resDone = mysql_query($res); }
  20. Thanks for the reply darkfreaks. it's blank.
  21. my code with the problem: $res = sprintf("UPDATE student SET Pas = '%s' WHERE Mail = '%s'", mysql_real_escape_string($Ber), mysql_real_escape_string($Mail)); $resDone = mysql_query($res); I can not get this work? I don't see any mistake in this code?? Could someone please help... I tried echo ($res)... it was blank? (I can assure the variable names are correct)
  22. How do I put this in my email code? When i use the code below, it shows the URL as "1"? <?php $link = require( dirname( __FILE__ ) . '/../../../../essentials/myData.php' ); return ($link); //rest of the code <a href='http://www.web.com.au/'".$link."' target='_blank'> <img src='http://www.web.com.au/dir/image_mail.gif' style='max-width:110px;' mc:label='image' mc:edit='tiwc200_image00' /></a> //rest of the code ?>
  23. Thanks you PFMaBiSmAd & Pikachu2000! that solved the problem.
  24. A <?php echo "names/new_batch/DataSheet.pdf"; ?> B <?php $link = require( dirname( __FILE__ ) . '/../../../../essentials/myData.php' ); echo ($link); ?> when i call B the result is is shown with an extra "1" at the end names/new_batch/DataSheet.pdf1 What am I doing wrong? How can I get the output as "names/new_batch/DataSheet.pdf"
×
×
  • 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.