I need to take a file and move it to a windows machine on a specific folder where it is then to be printed automatically. How would I accomplish something like this? Is it possible with PHP?
Hey,
I want to include a file to be accessible to any method/function in a PHP class. The file just contains a base-64 encoded variable. How do I do this?
Thanks.
Not sure if this is possible..basically a server forwards/bridges an incoming connection
Client - Server - Destination
Now, rather than a normal proxy script on the server(or a simple redirect),
1) the Destination sees the incoming connection as from the CLIENT (not from the SERVER).. aka masking the server
2) the Server in the middle streams the data back to the client(without downloading it first, then passing it)
Anyone know how to do this or something like it in PHP ?
Hi,
I'm having a bit of trouble exporting a csv file that is created from one of my mysql tables using php.
The code I'm using prints the correct data, but I can't see how to download this data in a csv file, providing a download link to the created file. I thought the browser was supposed to automatically provide the file for download, but it doesn't. (Could it be because the below code is called using ajax?)
Any help greatly appreciated - code below, S.
include('../config/config.php'); //db connection settings
$query = "SELECT * FROM isregistered";
$export = mysql_query ($query ) or die ( "Sql error : " . mysql_error( ) );
$fields = mysql_num_fields ( $export );
for ( $i = 0; $i < $fields; $i++ )
{
$header .= mysql_field_name( $export , $i ) . "\t";
}
while( $row = mysql_fetch_row( $export ) )
{
$line = '';
foreach( $row as $value )
{
if ( ( !isset( $value ) ) || ( $value == "" ) )
{
$value = "\t";
}
else
{
$value = str_replace( '"' , '""' , $value );
$value = '"' . $value . '"' . "\t";
}
$line .= $value;
}
$data .= trim( $line ) . "\n";
}
$data = str_replace( "\r" , "" , $data );
if ( $data == "" )
{
$data = "\n(0) Records Found!\n";
}
//header("Content-type: application/octet-stream"); //have tried all of these at sometime
//header("Content-type: text/x-csv");
header("Content-type: text/csv");
//header("Content-type: application/csv");
header("Content-Disposition: attachment; filename=export.csv");
//header("Content-Disposition: attachment; filename=export.xls");
header("Pragma: no-cache");
header("Expires: 0");
echo '<a href="">Download Exported Data</a>'; //want my link to go in here...
print "$header\n$data";
For a few days now I'm using NetBeans 6.8 for doing PHP work.
But even if a class-file is included and the methods are public and there's phpDoc used, NetBeans everytime shows "No Suggestions" in the window.
E.g. I type
$user->
and press CTRL+Space, I do expect all the methods and variables but there aren't shown any. ideas?
I'm currently researching the best way to approach building a javascript widget someone can embed on their site, which would retrieve and display information from an external MySQL database.
The gist of the widget would mimic the needs/functionality of Twitter's widget (http://twitter.com/about/resources/widgets), where it uses some combination of JS, PHP and/or AJAX and retrieves information from a MySQL DB with secure (or at least somewhat safe) cross-browser access. Thoughts or ideas on the best and most reliable way to approach something like this?
It's actually a combination of php and bash:
exec(sprintf("%s > %s 2>&1 & echo $! >> %s", $cmd, $outputfile, $pidfile));
I don't understand what 2>&1 & echo $! is there for?
excuse my English I speak Spanish
I'm trying to display multiple php and mysql registration, after that the show in an iframe
the problem is that apparently in the iframe shows me errors accents and other characters for example: for example (?D?nde cuesta menos y se consume m?s?")
this is what shows (?)
In the original query or first does not show me that, but in the iframe shows me that error
and probe with http-equiv = "content-type" and I worked
What else I can do?
What should I do?
regards
What are the advantages and disadvantages of storing an image as a blob in the database vs storing just the file name in the database.
I'm using PHP(CodeIgniter) with MySQL.
I know this question is subjective but a client asked me this question and I couldn't give a good answer.
hi all,
I want to know that is there any way to know after which page an user is leaving the website.
So that I can track that page and work to improve the content of that page.
I am using PHP as backend code.
I have a dynamic php website which index only has around 800 errors according to the w3 validator online.
I have tried checking major websites like ebay, stackoverflow and others also, all with around 400 errors.
So my first thought is, what good is that validator when it always displays errors?
Secondly, will the errors affect my SERP ranking? ie, will me fixing these errors as good as I can increase my Google search position?
Thanks
// if login is ok then we add a cookie
$_POST['user_name'] = stripslashes($_POST['user_name']);
$hour = time() + 3600;
setcookie(ID_my_site, $_POST['user_name'], $hour);
setcookie(Key_my_site, $_POST['password'], $hour);
Is this a right way to set cookies? Its been causing me serious redirect errors. See here: PHP Redirect problem with subdomain
How would I write a SQLite query to select all records from a specific month?
My dates are stored as Unix timestamps. PHP code is allowed in your solution if it's required. SQLite2-compatible queries only, please. :)
Hi there,
I am developing an iPhone app, which now can update Twitter account with GPS coordinates in real-time, by the Twitter API link: http://username:[email protected]/statuses/update.xml , and I am looking at how to make my own database to accept updates from iPhone, via a similar API page.
It seems a .php page can serve as the API, and MySQL can serve as the database.
What are the good ways of doing it? Any template code and tutorial please?
I start to learn class in PHP. According to my experience with other language, i can tell class is different then function. So, how we spot if our class start to be too much and too important and how we minimize its impact ?
Hi,
I am developing pages in php dynamically i.e data gets filled up from mysql DB. how do i assign a proper meta data and description for these dynamic pages so that google recognises it properly.
What needs to be passed in page so that google takes description properly. when i search a page in google. it takes the data in page as description not description tag contents
Hi,
I'm wondering how facebook extracts the right picture of the article from a link? they ignore any icons, ads images, or other not related images, & they gives you the right image?
What technique/method they use? because i've tried to extract all images using a php regex but how to find the right one?
Thanks
I cant seem to get any consistent info on this. Different sources appear to say different things and trhe venerable php.net iteslf (appears) not to explicitly state this - although I must admit, I only had a quick look.
In cases where I am passing around 'heavy' objects, I need to pass by reference, but I dont want to keep typing:
function foo(TypeName& $obj)
if I can get away with simply,
function foo(TypeName $obj)
So what does the standard say?
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?
i am trying to display the latest speed in mysql database on guage chart. i have tried so many things but gauge is not display plz any can help me...my code is attached and php part shows the correct value but dont know why guage is not display
<?php
$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="mysql"; // Database name
$tbl_name="gpsdb"; // Table name
// Connect to server and select database.
$con=mysql_connect("$host", "$username")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$data = mysql_query("SELECT speed FROM gpsdb WHERE DeviceId=1234 ORDER BY TIME DESC LIMIT 1")
or die(mysql_error());
while ($nt = mysql_fetch_assoc($data))
{
$speed = $nt['speed'];
$jsonTable = json_encode($speed);
echo $jsonTable;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>
Google Visualization API Sample
</title>
<script type="text/javascript" src="//www.google.com/jsapi"></script>
<script type="text/javascript">
google.load('visualization', '1', {packages: ['gauge']});
</script>
<script type="text/javascript">
function drawVisualization() {
// Create and populate the data table.
var data = new google.visualization.DataTable(<?=$speed?>);
// Create and draw the visualization.
new google.visualization.Gauge(document.getElementById('visualization')).
draw(data);
}
google.setOnLoadCallback(drawVisualization);
</script>
</head>
<body style="font-family: Arial;border: 0 none;">
<div id="visualization" style="width: 600px; height: 300px;"></div>
</body>
</html>
Hi there, my name is Tal,
Im working on a PHP Application the should have lots and lots of records, what DB should I use, and are there guides on the web that explains how to build efficient dbs and tables?
Tnx!
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.
Hai frnds i am new to php actually i am facing following problems in coding please can anyone give the solution?
Actually i am having one audio player and i am displaying some word dcoument
if i click word document corresponding audio file should play
actually when i click doc file it should pop ip with save as and open with for that i am using some header code
also i am passing query string in the browser
query string is not working if i use header
can anyone give me a solution for it below is my code i am attaching
<?php
$f_name = $_POST["fn"];
$id = $_POST["id1"];
echo $id;
//echo "../public_html/sites/default/files/ourfiles/$f_name";
$res2=db_query("select * from mt_files where id='".$id."' ");
$row2=db_fetch_array($res2);
$job_audio=$row2["audio_name"];
//echo $job_audio;
//$job_audi=explode("/",$job_audio);
//$job_audio=$job_audi[8];
$job_audio= "C:/xampp/htdocs/med/sites/default/files/audio/$job_audio";
//$job_audio= "C:/Documents and Settings/swuser/My Documents/$job_audio";
//echo $job_audio;
echo "<object data='$job_audio' type='application/x-mplayer2' width='150' height='45'>
<param name='src' value='$job_audio'>
<param name='autoplay' value='true'>
<param name='autoStart' value='1'>
</object> ";
$file = "../mts/sites/default/files/docs/$f_name";
if (file_exists($file)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
ob_clean();
flush();
readfile($file);
exit;
}
//The download table query goes here put the $f_name in insert into with the //time varible
?>
PHP's str_replace() was intended only for ANSI strings and as such can mangle UTF-8 strings. However, given that it's binary-safe would it work properly if it was only given valid UTF-8 strings as arguments?
Edit: I'm not looking for a replacement function, I would just like to know if this hypothesis is correct.