Latest PHP Questions
Google Search
Hey there ,
I am new over here and have started with PHP.
I now have a login script (Which I haven't made myself)
and an easy script of a small game.
now I have a row in my mySQL database which says "money"
and in the game script I want to import the "money" of a certain user.
What could I use best ?
the Session
a Query
etc.
If you have any tips or questions about this please give them / ask !
Greetz
Feiko
Asked by: Feiko On Sunday 1st of April 2012 09:14:42 AM
Total Answers: 0
I have $details='f1=33&f2=Designer-Stuhl Rot&f3=179.0000&f4=2.0000|f1=34&f2=Designer-Couch Rot&f3=299.0000&f4=1.0000|';
I am getting that from the $_GET['report']
Each group (divided by the | character) needs to be inserted to the database. Not every time does the $report have multiple groups. It could be only one group (ending in | character).
How do I?
1.) Recognize that it is more than one group
2.) Break the groups up into separate $key = $value pairs
Thanks guy.
Asked by: Tiffany On Thursday 15th of March 2012 02:13:42 PM
Total Answers: 1
Got it!
$orderDetails = explode("|", $report); // split them
$orderDetails = array_filter($orderDetails, 'strlen'); // get rid of the blank
Thanks anyway
Answered by: Tiffany On Thursday 15th of March 2012 05:55:55 PM
I am trying to get all invoices where the sum of the payments is less than the sum of the items in the invoice. But some of the items are tax exempt with a field called taxexepmt using 1 and 0 to decide here is my query.
$result = mysql_query("SELECT
tbl_quotes.title AS title
,(SUM(IF(taxExempt=0),tbl_quotesItems.price,0) * ((tbl_quotes.tax + tbl_quotes.tax2)+1)) + SUM(IF(taxExempt=1),tbl_quotesItems.price,0) AS total
,SUM(tbl_payments.amount) AS amount
,tbl_quotes.id AS id
FROM tbl_quotes
INNER JOIN tbl_sites ON tbl_quotes.site = tbl_sites.id
INNER JOIN tbl_companies ON tbl_sites.companyId = tbl_companies.id
INNER JOIN tbl_quotesItems ON tbl_quotesItems.quoteId = tbl_quotes.id
INNER JOIN tbl_payments ON tbl_payments.quoteId = tbl_quotes.id
WHERE
tbl_quotes.overall_company = $logincompany
AND tbl_companies.id = $company
AND typeOfReport = 'invoice'
GROUP BY tbl_quotes.id
HAVING (SUM(IF(taxExempt=0),tbl_quotesItems.price,0) * ((tbl_quotes.tax + tbl_quotes.tax2)+1)) + SUM(IF(taxExempt=1),tbl_quotesItems.price,0) > SUM(tbl_payments.amount)
") or die(mysql_error());
Asked by: Iisdan On Saturday 24th of December 2011 04:45:36 PM
Total Answers: 0
<?php
session_start();
ob_start();
include('conn.php');
if(isset($_COOKIE['cookname']) && isset($_COOKIE['cookpass']))
{
$_SESSION['usr'] = $_COOKIE['cookname'];
$_SESSION['password']= $_COOKIE['cookpass'];
$username=$_SESSION['usr'];
$password=$_SESSION['password'];
$qry=mysql_query("select * from info where `name`='".$username."'&& `password`='".$password."'");
$row1=mysql_fetch_array($qry);
if(($row1['name']==$username) && ($row1['password']==$password))
{
header("Location:login.php");
}
else
{
echo "invalid username and password";
}
}
else
{
?>
<html>
<body>
<table>
<form name="form" action="" method="post">
<tr>
<td>User Name</td>
<td><input type="text" name="uname" value=""></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" name="pass" value=""></td>
</tr>
<tr>
<td>Remeber Me</td>
<td><input type="checkbox" name="remeber" value=""></td>
</tr>
<tr>
<td><input type="submit" name="submit" value="submit"></td>
</tr>
</form>
</table>
</body>
</html
<?php
}
if(isset($_POST['submit']))
{
$uname=$_POST['uname'];
$pass=$_POST['pass'];
$sql=mysql_query("select * from info where `name`='".$uname."' && `password`='".$pass."'");
$row=mysql_fetch_array($sql);
if(($row['name']== $uname) && ($row['password']== $pass) )
{
$_SESSION['usr']=$uname;
$_SESSION['password']=$pass;
$_SESSION['start'] = time();
$_SESSION['expire'] = $_SESSION['start'] + (120) ;
if(isset($_POST['remeber']))
{
setcookie('cookname',$_SESSION['usr'],time()+300);
setcookie('cookpass',$_SESSION['password'],time()+300);
}
header("Location:login.php");
}
else
{
//header("Location:login.php");
echo "Invaild username and password";
}
}
?>
in this script how would we add session time out for 10 min
Asked by: Pankaj Sharma On Wednesday 14th of December 2011 09:14:08 AM
Total Answers: 0
Hi!
i send two codes one is loop & second is array .
the aaray code run properly & the loop code not work please check this two codes
Asked by: ZEESHAN On Thursday 24th of November 2011 11:26:32 AM
Total Answers: 0
Hello!
I am new on php.i am doing a program in if else condition .please check the attached file and suggest me
Thanks and Regard
gaurav
Asked by: Gaurav singh On Friday 26th of August 2011 07:47:16 AM
Total Answers: 1
Please check the day short name fri should be Fri , capital F not small f then it will work fine or you can take help http://php.net/manual/en/function.date.php for more
Answered by: Admin On Friday 26th of August 2011 10:39:19 AM
Hi i am new to php.. n i am a beginner.. i knw html very well.. i am currently learning php through online. so i tried some php programs as mentioned as in website. 1) i typed the php program in notepad 2) and i save it in as .php extension 3) then i open that file in firefox using the option openwith command..... but my problem is, it doesnt displaying any answers...but when i tried with html it works.. so is there is any extra software do i wants to install for working with php... n for ur info i am using windows 7 n i have wamp and xamp software... i do knw hw to connect xamp with php files too.. if anyone knws answer for question pls let me knw as soon as possible... thanks
Asked by: Kesavan b On Thursday 18th of August 2011 03:38:37 PM
Total Answers: 0
Kabaddi, Kabaddi, Kabaddi, Kabaddi......PHP?
Log onto www.lookbeyondresumes.com
What Matters IS.....YOU!!!!!
Asked by: Shyamsunder On Friday 22nd of July 2011 10:49:59 AM
Total Answers: 0
Hi Can any one help me with the output of following code.
<?php echo strpos('anna', 'a') ? 'a exists' : 'a doesnt exists'; ?>
Asked by: Daniel On Sunday 19th of June 2011 04:07:32 PM
Total Answers: 1
You should use strstr instead to check this type of string since a comes on the position 0 , echo strpos('anna', 'a') will return 0 that is false in php that's why you are getting the out put a doesnt exists
like in case <?php echo strpos('nna', 'a') ? 'a exists' : 'a doesnt exists'; ?>
you can get the out put a exists
because a is now on position 2
Answered by: Admin On Sunday 3rd of July 2011 04:13:30 PM
I have some data saved in WP postmeta table. Now I need to query those data to use as an input in a function. the query result should be in this formate:
`array(2) {
[0]=>
object(stdClass)#1 (3) {
["ID"]=>
string(1) "2"
["name"]=>
string(18) "cat"
["desc"]=>
string(4) "cc"
}
[1]=>
object(stdClass)#2 (3) {
["ID"]=>
string(1) "1"
["name"]=>
string(19) "dog"
["desc"]=>
string(7) "dd"
}
}`
This is how the postmeta table look like:
`-------------------------------------
post_id | meta_key | meta_value |
-------------------------------------
1 | project_id | 1 |
-------------------------------------
1 | name | cat |
-------------------------------------
1 | desc | cc |
-------------------------------------
2 | project_id | 2 |
-------------------------------------
2 | name | dog |
-------------------------------------
2 | desc | dd |`
How to write this query?
Asked by: Jenny.s On Monday 30th of May 2011 06:29:57 AM
Total Answers: 0
PHP Questions and Answers








Chat with Me


