RON_ron
-
Posts
370 -
Joined
-
Last visited
Posts posted by RON_ron
-
-
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);
-
thanks spiderwell!
-
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) {
////
}
-
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?
-
thanks again jesirose!
I'll keep that in mind...
-
$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;
}
-
thanks jesirose!
-
i think he wants to grab a webpage with php and stuff it into a variable to echo out at his leisure
You are correct spiderwell. That's exactly what I need. Can you help?
-
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?
-
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);
-
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"].".";
}
-
Cheers All!!
mysql_real_escape_string ...relying on mysql_* functions should be avoided ...
http://php.net/mysqli-real-escape-string
I'm not really a php star - may I know briefly why? isn't this secure using mysql_real_escape_string?
-
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);
-
I'm using this to store text in to the mysql db. the backslashes shows there.
-
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?
-
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.
-
of course it's correct.
-
$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); }
-
Thanks for the reply darkfreaks.
it's blank.
-
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)
-
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 ?>
-
Thanks you PFMaBiSmAd & Pikachu2000! that solved the problem.
-
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"
-
ya... through HTTP POST.
no luck though??
<?php if (move_uploaded_file($_FILES['Filedata']['tmp_name'])){ $uploadDirectory="uploads/"; $uploadFile=$uploadDirectory.basename($_FILES['Filedata']['name']); copy($_FILES['Filedata']['tmp_name'], $uploadFile); } ?>
mysqlmysqli
in PHP Coding Help
Posted
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?