Program prints an extra row with value 10 after each input
I've got this simple program:
#include <stdio.h>
int main()
{
int c;
while ( ( c = getchar()) != EOF)
printf("%d %c\n", c, c);
return 1;
}
However for some reason when executing i get an extra value ten at the end:
a
97 a
10
b
98 b
10
abc
97 a
98 b
99 c
10
What is the value 10 and where does it come from? How do I stop it from
occurring?
Thursday, 19 September 2013
Tomcat Server permission issue
Tomcat Server permission issue
I'm trying to deploy a simple Spring MVC app on a tomcat-hosting site. The
problem is that when I try to start the application I get the following
error:
19-set-2013 11.44.55 org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Allocate exception for servlet dispatcher
java.security.AccessControlException: access denied
(java.util.PropertyPermission * read,write)
at
java.security.AccessControlContext.checkPermission(AccessControlContext.java:374)
at java.security.AccessController.checkPermission(AccessController.java:546)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
at java.lang.SecurityManager.checkPropertiesAccess(SecurityManager.java:1252)
at java.lang.System.getProperties(System.java:580)
at
org.springframework.context.support.AbstractApplicationContext.prepareBeanFactory(AbstractApplicationContext.java:467)
at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
at
org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:427)
at
org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:341)
at
org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:307)
at
org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127)
at javax.servlet.GenericServlet.init(GenericServlet.java:212)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:270)
at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:269)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:302)
at
org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:163)
at
org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:117)
at
org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1200)
at
org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:827)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:129)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at it.ilz.hostingjava.valves.AccessLogValve.invoke(AccessLogValve.java:531)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at
com.googlecode.psiprobe.Tomcat60AgentValve.invoke(Tomcat60AgentValve.java:30)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at
it.ilz.hostingjava.valves.StartContextValve.invoke(StartContextValve.java:163)
at it.ilz.hostingjava.valves.DBLogValve.invoke(DBLogValve.java:84)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.ajp.AjpAprProcessor.process(AjpAprProcessor.java:448)
at
org.apache.coyote.ajp.AjpAprProtocol$AjpConnectionHandler.process(AjpAprProtocol.java:399)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1675)
at java.lang.Thread.run(Thread.java:662)
I know it's due to the policy restrictions imposed by the hosting service,
but I don't know how to solve this, how to modify the application (it's a
sample Spring MVC app you can download here) to work correctly.
Here are the permissions granted by the hosting file. Tomcat version is 6.
grant codebase "file:/home/hostingjava.it/" {
permission java.util.PropertyPermission "*", "read";
permission java.lang.RuntimePermission "getAttribute";
permission java.io.FilePermission "/home/hostingjava.it//-",
"read,write,delete";
permission java.lang.RuntimePermission
"accessClassInPackage.org.apache.tomcat.util.*";
}
Any idea?
I'm trying to deploy a simple Spring MVC app on a tomcat-hosting site. The
problem is that when I try to start the application I get the following
error:
19-set-2013 11.44.55 org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Allocate exception for servlet dispatcher
java.security.AccessControlException: access denied
(java.util.PropertyPermission * read,write)
at
java.security.AccessControlContext.checkPermission(AccessControlContext.java:374)
at java.security.AccessController.checkPermission(AccessController.java:546)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
at java.lang.SecurityManager.checkPropertiesAccess(SecurityManager.java:1252)
at java.lang.System.getProperties(System.java:580)
at
org.springframework.context.support.AbstractApplicationContext.prepareBeanFactory(AbstractApplicationContext.java:467)
at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
at
org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:427)
at
org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:341)
at
org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:307)
at
org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127)
at javax.servlet.GenericServlet.init(GenericServlet.java:212)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:270)
at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:269)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:302)
at
org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:163)
at
org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:117)
at
org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1200)
at
org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:827)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:129)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at it.ilz.hostingjava.valves.AccessLogValve.invoke(AccessLogValve.java:531)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at
com.googlecode.psiprobe.Tomcat60AgentValve.invoke(Tomcat60AgentValve.java:30)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at
it.ilz.hostingjava.valves.StartContextValve.invoke(StartContextValve.java:163)
at it.ilz.hostingjava.valves.DBLogValve.invoke(DBLogValve.java:84)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.ajp.AjpAprProcessor.process(AjpAprProcessor.java:448)
at
org.apache.coyote.ajp.AjpAprProtocol$AjpConnectionHandler.process(AjpAprProtocol.java:399)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1675)
at java.lang.Thread.run(Thread.java:662)
I know it's due to the policy restrictions imposed by the hosting service,
but I don't know how to solve this, how to modify the application (it's a
sample Spring MVC app you can download here) to work correctly.
Here are the permissions granted by the hosting file. Tomcat version is 6.
grant codebase "file:/home/hostingjava.it/" {
permission java.util.PropertyPermission "*", "read";
permission java.lang.RuntimePermission "getAttribute";
permission java.io.FilePermission "/home/hostingjava.it//-",
"read,write,delete";
permission java.lang.RuntimePermission
"accessClassInPackage.org.apache.tomcat.util.*";
}
Any idea?
Simple application to read username, password from mysql and displaying the next activity after verification
Simple application to read username, password from mysql and displaying
the next activity after verification
" In android i'm trying to read username and password from mysql database
and displaying the next window using the 'intent' " There are two
activities, the main activity and the userpage.class the first one will
verify the username and password and using the 'intent' it will call the
second 'userpage'
import package com.example.loginform;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.protocol.HTTP;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
public class MainActivity extends Activity implements OnClickListener {
Button login;
EditText username,password;
TextView status;
HttpPost httppost;
StringBuffer buffer;
HttpResponse response;
HttpClient httpclient;
TextView tv;
List<NameValuePair> nameValuePairs;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setup();
}
private void setup() {
// TODO Auto-generated method stub
username = (EditText) findViewById(R.id.username);
password = (EditText) findViewById(R.id.password);
login = (Button)findViewById(R.id.login);
status = (TextView)findViewById(R.id.tvstatus);
tv = (TextView)findViewById(R.id.editText1);
login.setOnClickListener(this);
}
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
switch(arg0.getId())
{
case R.id.login:
login();
break;
}
}
private void login() {
// TODO Auto-generated method stub
try{
httpclient = new DefaultHttpClient();
httppost = new HttpPost("localhost/android/index.php");
nameValuePairs = new ArrayList<NameValuePair>(1);
nameValuePairs.add(new
BasicNameValuePair("username",username.getText().toString().trim()));
nameValuePairs.add(new
BasicNameValuePair("password",password.getText().toString().trim()));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
response = httpclient.execute(httppost);
ResponseHandler<String>responseHandler = new
BasicResponseHandler();
final String response =
httpclient.execute(httppost,responseHandler);
tv.setText(""+response);
if(response.equalsIgnoreCase("User Found"))
{
startActivity(new Intent(this,UserPage.class));
}
}catch(Exception e)
{
e.printStackTrace();
Toast.makeText(getBaseContext(),"Sorry error in the
connection!!",Toast.LENGTH_SHORT).show();
}
}
}
Error log:
09-19 12:59:11.367: E/Trace(2634): error opening trace file: No such file
or directory (2)
the next activity after verification
" In android i'm trying to read username and password from mysql database
and displaying the next window using the 'intent' " There are two
activities, the main activity and the userpage.class the first one will
verify the username and password and using the 'intent' it will call the
second 'userpage'
import package com.example.loginform;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.protocol.HTTP;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
public class MainActivity extends Activity implements OnClickListener {
Button login;
EditText username,password;
TextView status;
HttpPost httppost;
StringBuffer buffer;
HttpResponse response;
HttpClient httpclient;
TextView tv;
List<NameValuePair> nameValuePairs;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setup();
}
private void setup() {
// TODO Auto-generated method stub
username = (EditText) findViewById(R.id.username);
password = (EditText) findViewById(R.id.password);
login = (Button)findViewById(R.id.login);
status = (TextView)findViewById(R.id.tvstatus);
tv = (TextView)findViewById(R.id.editText1);
login.setOnClickListener(this);
}
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
switch(arg0.getId())
{
case R.id.login:
login();
break;
}
}
private void login() {
// TODO Auto-generated method stub
try{
httpclient = new DefaultHttpClient();
httppost = new HttpPost("localhost/android/index.php");
nameValuePairs = new ArrayList<NameValuePair>(1);
nameValuePairs.add(new
BasicNameValuePair("username",username.getText().toString().trim()));
nameValuePairs.add(new
BasicNameValuePair("password",password.getText().toString().trim()));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
response = httpclient.execute(httppost);
ResponseHandler<String>responseHandler = new
BasicResponseHandler();
final String response =
httpclient.execute(httppost,responseHandler);
tv.setText(""+response);
if(response.equalsIgnoreCase("User Found"))
{
startActivity(new Intent(this,UserPage.class));
}
}catch(Exception e)
{
e.printStackTrace();
Toast.makeText(getBaseContext(),"Sorry error in the
connection!!",Toast.LENGTH_SHORT).show();
}
}
}
Error log:
09-19 12:59:11.367: E/Trace(2634): error opening trace file: No such file
or directory (2)
Wednesday, 18 September 2013
Generate WSDL from WCF DataService implementing OData
Generate WSDL from WCF DataService implementing OData
I am currently creating WCF Dataservice by implementing OData. I am trying
to generate the WSDl file not working.
i have tried this one: http://dbn:80/Product.svc?wsdl
and i tried using wsdl.exe http://dbn:80/Product.svc got the error: The
document at http://dbn:80/Product.svc?wsdl was not recognised as a known
document type
Thank you
I am currently creating WCF Dataservice by implementing OData. I am trying
to generate the WSDl file not working.
i have tried this one: http://dbn:80/Product.svc?wsdl
and i tried using wsdl.exe http://dbn:80/Product.svc got the error: The
document at http://dbn:80/Product.svc?wsdl was not recognised as a known
document type
Thank you
Moving Around A Canvas Without Using Scrollbars
Moving Around A Canvas Without Using Scrollbars
Background:
I have a program using Tkinter as the basis of the GUI. The program has a
canvas which is populated with a large number of objects. Currently, in
order to move all objects on the screen I am simply binding a movement
function to the tag 'all' which of course moves all objects on the screen.
However, it is vital for me to keep track of all canvas object positions-
i.e. after every move I log the new position, which seems unnecessarily
complicated.
Question:
What is the best way to effectively scroll/drag around the whole canvas
(several times the size of the screen) using only the mouse (not using
scrollbars)?
My Attempts:
Apologies if this is a trivial question, I have implemented scrollbars and
found several guides to setting up scrollbars, but none that deal with
this particular requirement.
Thank you for any help!
Example of disused scrollbar method:
from Tkinter import *
class Canvas_On:
def __init__(self, master):
self.master=master
self.master.title( "Example")
self.c=Canvas(self.master, width=find_res_width-20,
height=find_res_height, bg='black', scrollregion=(0,0,5000,5000))
horizontalbar=Scrollbar(self.master,orient=HORIZONTAL)
horizontalbar.pack(side=BOTTOM,fill=X)
horizontalbar.config(command=self.c.xview)
verticalbar=Scrollbar(self.master,orient=VERTICAL)
verticalbar.pack(side=RIGHT,fill=Y)
verticalbar.config(command=self.c.yview)
self.c.config(xscrollcommand=horizontalbar.set,
yscrollcommand=verticalbar.set)
self.c.pack(side=LEFT,expand=True,fill=BOTH)
draw=Drawing_Utility(self.c)
draw.drawer(self.c)
class Drawing_Utility:
def __init__(self, canvas):
self.canvas=canvas
self.canvas.focus_set()
def drawer(self, canvas):
self.canvas.create_oval(50,50,150,150, fill='orange')
self.canvas.create_oval(1000,1000,1100,1100, fill='orange')
root=Tk()
find_res_width=root.winfo_screenwidth()
find_res_height=root.winfo_screenheight()
run_it=Canvas_On(root)
root.mainloop()
Background:
I have a program using Tkinter as the basis of the GUI. The program has a
canvas which is populated with a large number of objects. Currently, in
order to move all objects on the screen I am simply binding a movement
function to the tag 'all' which of course moves all objects on the screen.
However, it is vital for me to keep track of all canvas object positions-
i.e. after every move I log the new position, which seems unnecessarily
complicated.
Question:
What is the best way to effectively scroll/drag around the whole canvas
(several times the size of the screen) using only the mouse (not using
scrollbars)?
My Attempts:
Apologies if this is a trivial question, I have implemented scrollbars and
found several guides to setting up scrollbars, but none that deal with
this particular requirement.
Thank you for any help!
Example of disused scrollbar method:
from Tkinter import *
class Canvas_On:
def __init__(self, master):
self.master=master
self.master.title( "Example")
self.c=Canvas(self.master, width=find_res_width-20,
height=find_res_height, bg='black', scrollregion=(0,0,5000,5000))
horizontalbar=Scrollbar(self.master,orient=HORIZONTAL)
horizontalbar.pack(side=BOTTOM,fill=X)
horizontalbar.config(command=self.c.xview)
verticalbar=Scrollbar(self.master,orient=VERTICAL)
verticalbar.pack(side=RIGHT,fill=Y)
verticalbar.config(command=self.c.yview)
self.c.config(xscrollcommand=horizontalbar.set,
yscrollcommand=verticalbar.set)
self.c.pack(side=LEFT,expand=True,fill=BOTH)
draw=Drawing_Utility(self.c)
draw.drawer(self.c)
class Drawing_Utility:
def __init__(self, canvas):
self.canvas=canvas
self.canvas.focus_set()
def drawer(self, canvas):
self.canvas.create_oval(50,50,150,150, fill='orange')
self.canvas.create_oval(1000,1000,1100,1100, fill='orange')
root=Tk()
find_res_width=root.winfo_screenwidth()
find_res_height=root.winfo_screenheight()
run_it=Canvas_On(root)
root.mainloop()
Can I use AngularJS 'ng-view' in TideSDK 1.3.1beta?
Can I use AngularJS 'ng-view' in TideSDK 1.3.1beta?
I've got a simple TideSDK application going, using AngularJS. Works nicely.
Recently as I started adding features, I replaced my single ng-include
with ng-view and Angular routing. It works great in Chrome, but errors
galore in TideSDK.
Is it possible to use ng-view in an application built with TideSDK 1.3.1beta?
I've got a simple TideSDK application going, using AngularJS. Works nicely.
Recently as I started adding features, I replaced my single ng-include
with ng-view and Angular routing. It works great in Chrome, but errors
galore in TideSDK.
Is it possible to use ng-view in an application built with TideSDK 1.3.1beta?
Attach CSV created with fputcsv to email
Attach CSV created with fputcsv to email
I have a function that compiles a custom CSV file using fputcsv. I also
have it email to an address submitted through a prior form via POST. I'm
sending headers so that way when the function is called, it just downloads
the CSV, but I'm unsure how to have it email AND attach the CSV, then
download the CSV.
Here is the entire function -
//SEND EMAIL
$emailTo = $_POST['$submitemail'];
$mailHeader = "From: **********r\n";
$mailHeader .= "Reply-To: ***********\r\n";
$mailHeader .= "MIME-Version: 1.0" . "\r\n";
$mailHeader .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$message = "Here is an email.... attach CSV too!";
$subject = "Email with text and CSV";
mail($emailTo, $subject, $message, $mailHeader);
//GATHER DATA
$user_ID = $id;
$query = "SELECT * FROM hours WHERE user_ID = '$user_ID' ORDER BY date ASC";
$query2 = "SELECT * FROM users WHERE ID = '$user_ID'";
$result = $db->query($query);
$result2 = $db->query($query2);
$row2 = $result2->fetch_object();
$full_name = $row2->full_name;
$organization = $row2->organization;
$importantstuff = array('Hours for - ' . $full_name, 'Site - ' .
$organization);
if (!$result) die('Couldn\'t fetch records');
$headers = $result->fetch_fields();
foreach($headers as $header) {
$head[] = ucfirst($header->name);
}
//START GENERATING CSV
$fp = fopen('php://output', 'w');
if ($fp && $result) {
header('Content-Type: text/csv');
header('Content-Disposition: attachment; filename="report-'.
$full_name .'.csv"');
header('Pragma: no-cache');
header('Expires: 0');
fputcsv($fp, array_values($importantstuff));
fputcsv($fp, array_values($head));
while ($row = $result->fetch_array(MYSQLI_NUM)) {
$row[1] = $full_name;
fputcsv($fp, array_values($row));
}
die;
}
So, this is where I get a little lost because I am sending the headers
before I actually have the entire CSV created, hence I can't attach them
to an email before everything is done. I'm not sure how I would accomplish
both in the same function. Can I?
I have a function that compiles a custom CSV file using fputcsv. I also
have it email to an address submitted through a prior form via POST. I'm
sending headers so that way when the function is called, it just downloads
the CSV, but I'm unsure how to have it email AND attach the CSV, then
download the CSV.
Here is the entire function -
//SEND EMAIL
$emailTo = $_POST['$submitemail'];
$mailHeader = "From: **********r\n";
$mailHeader .= "Reply-To: ***********\r\n";
$mailHeader .= "MIME-Version: 1.0" . "\r\n";
$mailHeader .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$message = "Here is an email.... attach CSV too!";
$subject = "Email with text and CSV";
mail($emailTo, $subject, $message, $mailHeader);
//GATHER DATA
$user_ID = $id;
$query = "SELECT * FROM hours WHERE user_ID = '$user_ID' ORDER BY date ASC";
$query2 = "SELECT * FROM users WHERE ID = '$user_ID'";
$result = $db->query($query);
$result2 = $db->query($query2);
$row2 = $result2->fetch_object();
$full_name = $row2->full_name;
$organization = $row2->organization;
$importantstuff = array('Hours for - ' . $full_name, 'Site - ' .
$organization);
if (!$result) die('Couldn\'t fetch records');
$headers = $result->fetch_fields();
foreach($headers as $header) {
$head[] = ucfirst($header->name);
}
//START GENERATING CSV
$fp = fopen('php://output', 'w');
if ($fp && $result) {
header('Content-Type: text/csv');
header('Content-Disposition: attachment; filename="report-'.
$full_name .'.csv"');
header('Pragma: no-cache');
header('Expires: 0');
fputcsv($fp, array_values($importantstuff));
fputcsv($fp, array_values($head));
while ($row = $result->fetch_array(MYSQLI_NUM)) {
$row[1] = $full_name;
fputcsv($fp, array_values($row));
}
die;
}
So, this is where I get a little lost because I am sending the headers
before I actually have the entire CSV created, hence I can't attach them
to an email before everything is done. I'm not sure how I would accomplish
both in the same function. Can I?
Subscribe to:
Posts (Atom)