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
The error-Warning: sqlite_query() [function.sqlite-query]: attempt to write a readonly database is coming whenever i try to insert values into a sqllite 1.1 database thru php program.
php version is 5.2.
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.
how do I get all the records for latest date. The date filed in my db is called recordEntryDate and it is in this form 2010-01-26 13:28:35
Lang: php
DB: mysql
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
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'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?
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
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.
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'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?
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 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.
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?
I use Aptana Studio for my PHP projects. I have not learned it but just used with what I was able to do in it. Many features I still don't know how to use in it.
At present, I have a HTML form and I want to write a .php script for the SEND button that it has. It is a submission script for the contact form.
I want a simple PHP IDE with which I can execute a single PHP file or work with at least two or three files easily, without much mess.
Please suggest a simple alternative to Aptana.
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)?
Hi all
I'm trying to write a function that could receive it's second arg a name of a function.
In order to validate function's name (that will be used in an eval statement) I use function_exists such as:
if(function_exists($type)){
$toEval= $type.'(\''.$file.'\');';
}else{
But if the arg sent is include or require (with 'once' variations) this code fails (function_exists returns false).
How could this be fixed?
Thanks,
Alex
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
I am trying to insert some Arabic Language data into MySQL using PHP and an HTML form. When I insert the data in to MYSQL table, the table field represents data as Ù…Ø±ØØ¨Ø§ العالم.
But when I access the same data with PHP and show it in my webpage, it shows the correct data. I am using:
http-equiv="Content-Type" content="text/html; charset=utf-8"
meta tag in my web page to show Arabic data. My question is why my data looks like this: Ù…Ø±ØØ¨Ø§ العالم in MySQL table, and how should I correct it.
I've done a lot of googling around this, and practically all of the answers I find are pre 2011, and are answered in the usual, here are the 5 most popular frameworks... So I'd like to update this topic for 2012,
I'm going to build a web application with a pretty complex back-end system driving it, and I'd like to use a framework so I don't have to reinvent the wheel. My application will be hugely user based, so I would appreciate a built in authentication/validation system. (When this is missing it takes me a good 2 weeks of intense and frivolous research to try to pick the "best" one (I don't want to roll my own, I don't think I'd do a better job than what's out there). I've looked into a tried a few, so I'll give you what I like and don't like, but I don't want to bias answers too much.
I don't like:
Frameworks that auto-generate bloated code. If they have the feature,
fine, but if I have to use it, I get frustrated.
Backwards compatibility with php4, eww. I don't need backwards compatibility at all.
I like:
Getting up and running quickly (but without all the auto-generation bogus), what I mean by this is that all the essentials are there, so I don't have to come to a grinding halt to research what the best 3rd party plugin is to get the feature I need.
Thorough documentation, good tutorials. Good presentation of these materials.
Please explain why your framework suggestion is good, don't just give the name of a framework without any justification. 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.
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?
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.