I Have to calculate date time difference how to do that in PHP.
I need exact hours , mins and secs. any body have the scripts for that please give me :-P
Hi everyone,
What do I need to do to call $this-two() from inside my function innerOne? Is that possible with PHP OOP?
Here's the error I am recieving:
Fatal error: Using $this when not in object context
Here's how my code looks:
class myClass {
function one(){
function innerOne() {
// Some code
$this->two($var1, $var2);
}
// Some code
innerOne();
}
function two($var1, $var2) {
// Does magic with passed variables
return $var1 . $var2;
}
}
Thanks a lot!
How would I go about ensuring that the overridden parent method exists before I call it?
I've tried this:
public function func() {
if (function_exists('parent::func')) {
return parent::func();
}
}
However the function_exists never evaluates to true.
Hi,
I've inherited a project which we are trying to migrate to MySQL 5 from MySQL 4.0(!) and from myISAM to InnoDB. Queries are now falling down because they are being constructed using an ADODB connection's -qstr() on all parameters, including ints. Where no value is provided I end up with:
INSERT INTO tablename VALUES ('', 'stuff'...)
where the first column is an auto_increment. This causes an error (fair enough since '' isn't an int). Is there a switch in MySQL to make it behave as it used to (I assume it just silently converted to 0?)
Thanks.
Currently im just using something like:
in the DB Table:
access: home,register,login
and then in each page:
if(!Functions::has_rights('content'))
{
Functions::noAccess();
}
is there more efficient way to do it, php & MySQL? i may want to gain access even to several parts a page, for example: user can read a page, but doesnt comment to it, and I dont want to build a separate system to each module.
Thanks in advanced, Tal.
Hi,
I’m currently trying to develop a method to get a overview of all my different web templates I’ve created and (legally) downloaded over the years. I thought about a displaying them like Wordpress is previewing it’s templates view a small preview windows, displaying the concrete file with styles and everything.
How to divide them into rows and columns and create AJAX modal window open on preview and pagination and so on I believe I can manage, but it is the concept itself about iterate over several folders then find all index.htm / index.html pages and displaying them.
I’ve not worked very much with directories in PHP and the only references and code stumps I’ve found so far is just to list all the files in a certain directory like, what it contains.
I would be really grateful if someone knew about a script, a function, snippet or just could get me a nudge in the right direction to create such a (probably simple) preview function.
Sincere
Mestika
I'm using wordpress, and I want to add the adsense javascript tags where the Read More tag goes in a blogpost. It's stored as <!--more--> in the database, but when you use the_content() this is automatically changed before I have the chance to use a str_replace() function.
I'm looking to place an adsense tag for each post in the single.php page where the teaser ends. Has anyone been able to do this?
?
username:
';
}
else
{
$user=$_POST['user'];
$query="select name from login where name='$user'";
$result=mysql_query($query) or die(mysql_error());
$rows=mysql_num_rows($result)or die(mysql_error());
session_start();
//echo "results";
$username=mysql_fetch_array($result) or die(mysql_error());
$fields=mysql_num_fields($result) or die(mysql_error());
echo "username:$username[0]";
$_SESSION['username']=$username[0];
$sesion_username=$_SESSION['username'];
//echo "rows:$rows"." "."fields:$fields";
echo""."username:$sesion_username";
}
?
i wanted to create a site where user can login and upload their details depending on their user name have stored their details in a database,the problem i am facing is two people 'a' and 'b' login one after other session_variable $_SESSION['username'] will have 'b's' username ,so i can't display 'a's' details now. . . .
what i want to achieve is when a user logins in i want to store his name and other details in session variable and navigate him according and display his details
I'm trying to take a query:
SHOW TABLES;
which will display a bunch of tables with the chat_ prefix. I want to remove the chat_ prefix from the string, format the variable (with a link), and display it. How is this accomplished?
I am new to PHP & want to we send email from localhost to my gmail address.
I used:
$to = "[email protected]";
$subject = "Account Confirmation";
$headers = "From: [email protected]";
$message = "Testing";
$mail = mail($to, $subject, $message, $headers);
if ($mail) {
echo "Mail sent.";
} else {
echo "Some Error occur.";
}
And it show Some Error occur.
please help.
Thanks
What I'd like is for this class
class Car {
public function __construct(Engine $engine, Make $make, Model $model)
{
// stuff
}
}
Get an array that has the types needed to construct this car (Engine, Make, Model) in the order they are needed for the constructor. I'm using this for a Dependency Injection-esque thing I'm making.
I maintain an application where users are able to store images, and then share them. The system is powered by MongoDB at the back end. Most of the image depiction pages are cached as flat HTML files, but I can run some code just before loading the file.
I've decided to implement a view count for the system. I am wondering what is the best storage place for that. It should be like Memcached but it should save the viewcounts every hour or so, so even if our server has to be restarted we won't lose the view counts.
What is the best solution for that (preferably with a PHP extension as a client)?
I'm using this php code. but it's giving error
Deprecated: Function eregi() is
deprecated in
C:\xampp\htdocs\fuel\emailcheck.php on
line 7
<?
include_once("mastersecure.php");
$emailcheck=$_POST["member_name"];
function isValidEmail($email){
$pattern = "^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$";
if (eregi($pattern, $email)){
return true;
}
else {
return false;
}
}
if (!isValidEmail($_POST['member_name'])){
echo "The email is invalid!";
}
else
{
$query="select email from fuel where email='$_POST[member_name]'";
$res=mysql_query($query);
$rowcount=mysql_num_rows($res);
if($rowcount!=0)
{ echo "This mail is already exits"; }
}
?>
Any solution for this?
I am trying to run cimyadmin(http://cimyadmin.net/) but i am getting a lot of helper depreciation errors and after looking around the web for answers i am convinced its a php issue.Is there a way to run php 5.0.2 or earlier but not less than php 5 code on latest distributions of php.
Hey All.
Trying to create a 1-liner to loop through a mysql result set.
Example:
$sql = "SELECT uid, role FROM usr WHERE uid = '$this-uid'";
$r = db::q($sql);
if($r-rows()) {
$q = mysql_fetch_assoc($r-result);
while(list($k, $v) = each($q)) { // would like to omit line above and consolidate here
$_SESSION['usr'][$k] = $this->$k = $v;
}
}
problem is that consolidating while loop like so:
while(list($k, $v) = each(mysql_fetch_assoc($r-result))
returns an error a la each() not getting object or array, even though of course it is. I think the problem is a casting issue, but it does not seem you can do:
each( (array) mysql_fetch_assoc($r-result))
Any ideas? I like to code as tersely as possible, and having "$q = mysql_fetch_assoc($r-result)" everywhere will annoy me, does already.
Keep posted...
Thanks!
I have three php scripts. main.php questions.php and values.php
Here's the code
main.php
<html>
<head>
<title></title>
</head>
<body>
<h1>Be Prepare for the battle</h1>
<?php
$strTitle = "Begin";
$strLink = "<a href = 'question.php?ques_id=1'>" . $strTitle ."</a>";
echo $strLink;
?>
</body>
</html>
questions.php
<?php require_once('../connect.php'); $quesSQL = mysql_query("SELECT * FROM `questions` WHERE `ques_id`=". $_GET["ques_id"]);
if(!mysql_num_rows($quesSQL)>=1)
{
die('Complete.');
}
$next = $_GET["ques_id"]; while($row = mysql_fetch_array($quesSQL)) {
$id = $row['ques_id'];
$strTitle = $row['ques_title'];
echo "<li>". $strTitle ."</li><br/>";
}
$optSQL = mysql_query("SELECT `options`,`values` FROM questions_options WHERE ".$id."= ques_id");
echo "<form action=\"values.php\" method=\"POST\">";
while($row = mysql_fetch_array($optSQL) ) {
$strOptions = $row['options'];
$strValues = $row['values'];
echo "<input type =\"radio\" name =\"valueIn\" value=".$strValues." />". $strOptions ."<br/>";
}
echo "</form>";
$strTitle = "<input type =\"submit\" value=\"Next\">";
$next = $next+1;
$strLink = "<a href = 'values.php?ques_id=".$next."'>" . $strTitle ."</a>";
echo $strLink;
mysql_close();
?>
and values.php
<?php
require_once('../connect.php');
$input = $_POST['valueIn'];
$ansSQL = mysql_query("SELECT `answer` FROM questions WHERE 1-".$_GET["ques_id"]."= ques_id");
$marks = 0;
if($input == $ansSQL)
{
$marks = $marks+1;
}
else
{
$marks = $marks+0;
}
echo $marks;
?>
Now problem is i have to pass one value from second script(questions.php) to third script(values.php).
And it is from the <form> section in radio button's name value "valueIn". But I can't do that. Because I'm sending another value ques_id with $strLink variable at the end of the second script.
So how can i do that?
0 down vote
hi,
I have problem in showing $date="2011-02-10 15:26:20"; in the format of Thursday 10th of February 2011 03:26:20 PM in php.
i know there is one date function in php and can be done in one line for example: but via this it will flash today date or so.
i want to do it when user check any date and want that date in the format which i mention earlier.
please revert me back as soon as posib....
thanks
Is it possible to automaticly download xml files from one server to another server on a daily basis with PHP?
The goal is to create a webapplication in CakePHP which makes use of an xml report that comes from a online accountingserver.
Is it possible to automaticly download xml files from one server to another server on a daily basis with PHP?
The goal is to create a webapplication in CakePHP which makes use of an xml report that comes from a online accountingserver.
So it can be done using a cronjob? But is cron supported with PHP?
Where can i configure that cronjob?
What kind of code should i write to get the file from the accountingserver in the first place?
I am trying to manage seasonal prices for hotel rooms.
The only way that I can think of doing it would be to use:
| DayDate |EndDate | A | B
-----------------------------------------------
| 2010/07/1 |2010/07/2 | 200 | 40
| 2010/07/3 |2010/07/4 | 150 | 40
| 2010/07/5 |2010/07/5 | 150 | 50
| 2010/07/6 |2010/07/7 | 200 | 50
| 2010/07/8 |2010/07/9 | 100 | 60
etc.. (table taken from another question).
The problem is: I don't want my seasons to be year specific.
Seasons for rooms shouldn't change year on year. I don't want my users to have to enter the seasonal information several times.
I am also going to have thousands of rooms, so I don't know a way to make this easily manageable.
I'm using mysql and php.