urtrivedi 276 Nearly a Posting Virtuoso

post your table structure here (both tables)
have you tried adding rows directly through phpmyadmin, same error occurs there also?

urtrivedi 276 Nearly a Posting Virtuoso

I THINK YOUR ORIGINAL QUESTION HAS NOTHING TO DO WITH SESSIONS.

Any how You must set and use session variables there is no link between post and session.


logincheck.php

<?php
session_start();
if($validuser) //check login details if valid then set session variables
{
   $_SESSION['username']=$loggeduser;//logged user may be userid, email or whatever you like to set.
   $_SESSION['on']="1";
   $_SESSION['xyz']="pqr";
}
?>

anyfile.php

<?php
session_start()
if(!$_SESSION['on'])  //if user not logged then send to login page
{
   header('location:login.php');
   exit;
}

echo "welcome {$_SESSION['username']}";
?>
urtrivedi 276 Nearly a Posting Virtuoso

add one more parameter to following function call

$pdf->Output("myfile.pdf",'D');

THIS WILL AUTOMATICALLY ASK USER TO SAVE/OPEN

urtrivedi 276 Nearly a Posting Virtuoso

I do not know how you want payretdate in query so I have not used it

urtrivedi 276 Nearly a Posting Virtuoso

check this query

SELECT  `SRNo` ,  `InvAmount` ,  `SubPayDate` ,  `PayRetDate` ,  `ResubPayDate` , 
CASE WHEN  `ResubPayDate` =  '0000-00-00'
THEN TO_DAYS( NOW( ) ) - TO_DAYS(  `SubPayDate` ) 
ELSE TO_DAYS( NOW( ) ) - TO_DAYS(  `ResubPayDate` ) 
END Days
FROM  `invmain` 
WHERE  `Status` =  'SENT TO PAYABLE'
AND  `SubPayDate` <>  '0000-00-00'
urtrivedi 276 Nearly a Posting Virtuoso

post your table structure, sample data and expected result from that data, do no post query.

urtrivedi 276 Nearly a Posting Virtuoso

whats new in your code akash

urtrivedi 276 Nearly a Posting Virtuoso

Search on excutescalar function.

.
.
.
.

qry1 = "select count (*) from mytable where mycolumn='myvalue'";
                SqlCommand cmd2 = new SqlCommand(qry1, cn);
               value= cmd2.ExecuteScalar();

' now repalce your ?????? with value below

.
.
.
.
.

qry = "insert into General values(@Gno,@GRno,@Fname,@Mname,@Lname,@Sex,@Bdate,@Pass,@Mono,@OtherNo,@Photo,@Role,@GCID)";

SqlCommand cmd2 = new SqlCommand(qry, cn);
cmd.Parameters.AddWithValue("@Gno",value );
cmd.Parameters.AddWithValue("@GRno", TxtAddress.Text);
cmd.Parameters.AddWithValue("@Fname", RadioButtonList1.SelectedItem.Text);
cmd.Parameters.AddWithValue("@Mname", DrpDwnDD.SelectedItem.Text);
cmd.Parameters.AddWithValue("@Lname", DrpDwnMM.SelectedItem.Text);
cmd.Parameters.AddWithValue("@Sex", DrpDwnYY.SelectedItem.Text);
cmd.Parameters.AddWithValue("@Bdate", TxtUserName.Text);
cmd.Parameters.AddWithValue("@Pass", TxtPassword.Text);
cmd.Parameters.AddWithValue("@Mono", TxtEmail.Text);
cmd.Parameters.AddWithValue("@OtherNo", DrpDwnCountry.SelectedItem.Text);
cmd.Parameters.AddWithValue("@Photo", "~/Photo/" + FileUpload1.FileName);
cmd.Parameters.AddWithValue("@Role", DroDpwnPerque.SelectedItem.Text);
cmd.Parameters.AddWithValue("@GCID", TxtAns.Text);
FileUpload1.SaveAs(Server.MapPath("~/Photo/" + FileUpload1.FileName));
cmd.ExecuteNonQuery();

urtrivedi 276 Nearly a Posting Virtuoso

you must pass database name also

$conn=oci_connect("sysdba", "hammad90", $databasename);

urtrivedi 276 Nearly a Posting Virtuoso

open phpmyadmin->database->sql

paste only TRIGGER CODE NOT DELIMITER LINES in sql textarea

CREATE TRIGGER grade_change AFTER UPDATE on takesFOR EACH ROW BEGINIF (OLD.grade='F' OR OLD.grade IS NULL) AND NEW.grade != 'F' AND NEW.grade IS NOT NULL THEN  BEGIN    SET @c=(SELECT credits FROM course WHERE course.course_id=NEW.course_id);    UPDATE student SET tot_cred=tot_cred+@c WHERE student.id=NEW.id;  END;END IF;END$$

at the bottom of sql textarea you will find delmiter field, there repalce ; with $$

then execute.

urtrivedi 276 Nearly a Posting Virtuoso

Its strange

urtrivedi 276 Nearly a Posting Virtuoso

after generating file, set its permission to 777 (just to check whether permission issue or not).

urtrivedi 276 Nearly a Posting Virtuoso

select * from table_name order by posting_date desc

urtrivedi 276 Nearly a Posting Virtuoso
<?php

$result=mysql_query("SELECT transtech, blkidfp00,SUM(g.pop) popsum, SUM(g.hu) sumhu, SUM(g.busfirms) sumbusfirms FROM wi_allbcdata g 
			WHERE g.fips='$countyfips' 
			AND (g.transtech=10 OR g.transtech=30 )
			GROUP BY transtech, blkidfp00");
?>
urtrivedi 276 Nearly a Posting Virtuoso

I am posting simplest code here to send mail. It does not require to use any class

<?php

	$headers= "MIME-Version: 1.0\n";
	$headers.="Content-type: text/html; charset=iso-8859-1\n";
	$headers.="Cc: abc@yahoo.com,pqr@gmail.com\n";	
	$headers.="Bcc: a1234@yahoo.com,xyz@gmail.com\n";	
	$subject = "sample mail";
	$message="<br><b>this is just a sample</b>.";
	
	$message.="<br><br>This is system generated message. Please do not reply.";						
         $sendmail = mail("toemail@yahoo.com", $subject, "<html><body>".$message."</body></html>", $headers);
		

?>
urtrivedi 276 Nearly a Posting Virtuoso

you continue with
php only, do not give any parameter,

then completing creating task, right cick on it and open properties

you will find RUN BOX "C:\Program Files\PHP\php.exe"

CHANGE IT TO (give appropriate path)

"C:\Program Files\PHP\php.exe" "C:\WEBROOT\YOURFOLDER\YOURREPORT\report1.php"

urtrivedi 276 Nearly a Posting Virtuoso

post or attach you code here

urtrivedi 276 Nearly a Posting Virtuoso

you need two pages
1 one your main page which code you have posted above(only remove the upload logic that i mentioned from main page)
2 another page will contain upload logic i posted name that page as index_web_page2.php (because you mentioned that name in action attribute of form element)

No third page required

urtrivedi 276 Nearly a Posting Virtuoso

you must create another php file called index_web_page2.php

<?php
 -- here proper connection parameter are required
$pic=$_file["timesheet"]["tmp_name"];$destination='\xampp\htdocs\new'.'\\'.$dbname.'\images'.'\\'.$_files["timesheet"]["tmp_name"];move_uploaded_file($pic,$destination); /* key code */
$query="insert into img_table(img_name) values('".$pic."')";  


header("location:main_file_name.php");

?>

remove this code from your main file.

urtrivedi 276 Nearly a Posting Virtuoso

Kindly try on phpmailer forum, I am not sure about the error.

urtrivedi 276 Nearly a Posting Virtuoso

For cc on your own you may try

$mail->addCustomHeader("Cc: {$yourccmailid1},{$yourccmailid2}");

urtrivedi 276 Nearly a Posting Virtuoso

give whole path of your script

php c:\mywebroot\myfolder\myreport\report1.php

urtrivedi 276 Nearly a Posting Virtuoso

You need to understand the sequence of execution.

1) You php preprocess formats ouput for the client browser at server. Now php stops executing

2) That preprocessed code is sent to browser as html/javascript code. Where javacript code is executed, and html is rendered.

3) if you change any javascript variable, it is just changed at client browser and server(php) can not access it. IF you want to process some client action in php. the you must submit html form to server. then php can process submitted form and again give certain output.

urtrivedi 276 Nearly a Posting Virtuoso

For cc on your own you may try

$mail->addCustomHeader("Cc: {$yourccmailid1},{$yourccmailid2}");

urtrivedi 276 Nearly a Posting Virtuoso

I am not sure about the ADD CC Function. Because I directly send mail, means I do not use class.

Now about automation of mail
So I explained in my post that on widows server, You can add scedule task.
Search microsoft site for details.

Cron are genrally utility for linux server cron (linux), schedule task (windows).
Cron commands will not work on windows.

Now you use file search facility of windows. in xamapp folder there might be php folder where you can find php.exe, locate php exe in your computer, I am sure you will find it.

urtrivedi 276 Nearly a Posting Virtuoso

if you have access to windows server.
You can create schedule task.
Accessories->system tools->schedule task
create new task
When it ask for application.
1) browse to php folder and select php.exe
2) then give space and give full path of report1.php
3) set time

repeat 1-3 steps for other reports.

urtrivedi 276 Nearly a Posting Virtuoso

<?php
<img src='<?php echo "http://".$_SERVER["HTTP_HOST"]."/yourfolder/images/phpmailer.gif" ?>' style='height: 90px; width: 340px'>

?>

urtrivedi 276 Nearly a Posting Virtuoso

file_get_contents('contents.php'); will only read php file it will not execute php code.

urtrivedi 276 Nearly a Posting Virtuoso

Try with php_curl
You must enable php_curl on your server.

then write following function in your smtpauth.php

<?php
function my_curl($url,$rethdr=0)
{
	$ch = curl_init();
	curl_setopt ($ch, CURLOPT_URL, $url);
	curl_setopt ($ch, CURLOPT_HEADER, $rethdr);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	$res=curl_exec($ch);	
	return $res;
}
?>

$body=my_curl('http://localhost/yourfolder/contents.php',1);

I hope this will work

urtrivedi 276 Nearly a Posting Virtuoso

What output you are getting

urtrivedi 276 Nearly a Posting Virtuoso

CHANGE MY LINE NO 21 OF PREVIOUS POST LIKE GIVEN BeLOW, remove or then write AND

$operator=" and ";

urtrivedi 276 Nearly a Posting Virtuoso
<?php 		

$_POST['keywords']="aaa    ccc";

for($i=0;$i<10;$i++)
	$_POST['keywords']=str_replace("  "," ",$_POST['keywords']);

$arrkey=explode(" ",trim($_POST['keywords']));	


$query="select * from product where somecol='somevalue' ";

$keycount=count($arrkey);
if($keycount>0 and trim($_POST['keywords'])!="")
{
	$query.=" and (";
	$operator="";
	for($i=0;$i<$keycount;$i++)
	{
		$query.=$operator."(product_name like '%{$arrkey[$i]}%')";
		$operator=" or ";		
	}
	$query.=")";
}
echo $query;

?>
urtrivedi 276 Nearly a Posting Virtuoso

I think ajax would be better option for you.
You may try xajax libraries for easy integration.

urtrivedi 276 Nearly a Posting Virtuoso

no need to union

select * from dbo.T_JOBS where (STATUS = 'Failed' or ENDDATEANDTIME = NULL)
urtrivedi 276 Nearly a Posting Virtuoso

problem is line no 7, that is ur query either ur table name is wrong or column name is wrong. You try to run this query in phpmyadmin then find out the syntax error.

urtrivedi 276 Nearly a Posting Virtuoso

It is not error its just a warning. if this is displayed on your browser then you need to modify your php.ini
find

display_errors = On
set it to
display_errors = Off

restart apache.

urtrivedi 276 Nearly a Posting Virtuoso

for particular date

select date,sum(amount) as val from table_name where date='2010-06-16' group by date

for particular date and name

select name,date,sum(amount) as val from table_name where date='2010-06-16' and name ='myname' group by name,date
urtrivedi 276 Nearly a Posting Virtuoso

what do you mean by not working, what exact problem you are facing?
what is there in db, because i dont see any relation between your db code and final code.

urtrivedi 276 Nearly a Posting Virtuoso

query with where will sumup only those rows which are displayed, it will not sum up rows filtered by where condition. you have to take care in your php code.

urtrivedi 276 Nearly a Posting Virtuoso
SELECT YEAR, SUM(profit) profit FROM sales 
where year>2000
GROUP BY YEAR WITH ROLLUP
urtrivedi 276 Nearly a Posting Virtuoso

I am not able to understand your requirement, though you have tried your best to explain.
So I am giving one mysql syntax (found in mysql manual) that will add the sum at the end with null description.

SELECT year, SUM(profit) profit FROM sales GROUP BY year WITH ROLLUP;

year, profit
-------------
2001,60000
2002,50000
null,110000

I hope this is what you are looking for.

urtrivedi 276 Nearly a Posting Virtuoso

ipradip Have u read my first post.

urtrivedi 276 Nearly a Posting Virtuoso

following queries gives difference in days.

select sysdate-to_date('03-jun-2010') from dual;

or

here date1,date2 are fields of date datatype.

select date2-date1 from sometable;

urtrivedi 276 Nearly a Posting Virtuoso

sample
select concat('A',lpad(MAX(substr('A0001',2))+1,4,'0')) new_number

from table here pkcolname is your primary key of table with first is letter and rest 4 are numbers.
select concat('A',lpad(MAX(substr(pkcolname,2))+1,4,'0')) new_number FROM TABLENAME

urtrivedi 276 Nearly a Posting Virtuoso

this is the final one.

select a.id, a.username, a.id_status,sum(a.won) won, sum(a.void) void, sum(a.lost) lost
from (
select Users.id, Users.Username, User_status.id_status,
case when Analysis.status_name='Won' then 1 else 0 end won,
case when Analysis.status_name='Void' then 1 else 0 end void,
case when Analysis.status_name='Lost' then 1 else 0 end lost,
@row := case when @prevuser=Users.Username then @row + 1 else 1 end as rownum,
@prevuser:=Users.Username FROM Users left outer join (SELECT @row := 0, @prevuser:=null ) r on @row=@row
INNER JOIN User_status ON Users.User_status_name=User_status.user_status
left outer JOIN Analysis ON Users.Username=Analysis.Tipster
WHERE User_status.id_status>=3
order by Users.Username, Analysis.date
)  a where a.rownum <=20 GROUP BY a.id, a.Username, a.id_status;
urtrivedi 276 Nearly a Posting Virtuoso

I was expecting sql script not a pdf file. so that i can create same environment as you are having. to find the syntax error. also send 3rd tables that u use in your query.

urtrivedi 276 Nearly a Posting Virtuoso
<?php
$string="your string";
$arr=explode(",",$string)
$newstr="";
$total=count($arr);
for($i=0;$i<$total;$i++)
{
    $newstr.=$arr[$i];
    if($i%2==0)
       $newstr.="<br/>";
    elseif($i<($total-1));
       $newstr.=",";
}
echo $string;
echo $newstr;
?>
urtrivedi 276 Nearly a Posting Virtuoso

what is difference between deal and current deal what is suggest for many oraganisation for one deal, the following solution, forget deal and currentdeal

deal_hdr (dealid, dealdescr,begindate,enddate)
deal_dtl (dealid (fk from deal_hdr),organiztionid,lawyerid)

here if there is only one lawyer for each deal then you may take layter to deal_hdr,
Now your one deal is having multiple organization.

urtrivedi 276 Nearly a Posting Virtuoso

I have no clue about xampp. what i used to do was
I opened my php.ini file enabled curl by adding following line with other extension, save the file

extension=php_curl.dll

Then i ensured that this file is there in php/extensions/ folder
restarted apache
and thats it

But as i told u in my previous post, even after writing a code you will not able to access that website, because they are not allowing.

urtrivedi 276 Nearly a Posting Virtuoso

try to run internal query first and have a look. make syntax correct, then try whole query. if you still not able to run then attacht script of database and data for thest two tables i will run it here.

select Users.id, Users.Username, User_status.id_status,
 case when Analysis.status_name='Won' then 1 else 0 end won,
case when Analysis.status_name='Void' then 1 else 0 end void,
case when Analysis.status_name='Lost' then 1 else 0 end lost,
@row := case when @prevuser=Users.Username then @row + 1 else 1 end as rownum,
@prevuser:=Users.Username 
FROM Users,(SELECT @row := 0, @prevuser:=null ) r  
INNER JOIN User_status ON Users.User_status_name=User_status.user_status
left outer JOIN Analysis ON Users.Username=Analysis.Tipster 
WHERE User_status.id_status>=3
order by Users.Username, Analysis.Tipster date

(SELECT @row := 0, @prevuser:=null ) r
this is used to initialise two variables @row and @prevuser


@row := case when @prevuser=Users.Username then @row + 1 else 1 end as rownum
with every row i m trying to generate sr no for each user of if. its a first row compare my prevauser variable with username in table if both are same then add one to srno. if username in prev row and current row is different then reset srno to 1 for new user.

@prevuser:=Users.Username
save current username to our prevuser variable to compare in next row.

result of inner query will be like following

id, username, id_status, won, void, lost, rownum
1, abc, xyz, 1,0,0, 1
1, abc, xyz, 0,1,0, 2
1, abc, xyz, …