|
they are referenced in a different variable...$_FILES.
But you need to have an input element of the type files in your post form first. So someething like
<form action='' method='post' enctype='application/x-www-form-urlencoded'>
Name: <input type='text' name='user'>
Img: <input type='file' name='pict'>
<input type='submit' name='action' value='Upload'>
</form>
You would access the form elements with...
$_POST['action'] for the submit button
$_POST['user'] for the user field
$_FILES['pict'] for the pict field. Keep in mind this is an array and has a number addition values. You can read more about that here http://www.php.net/manual/en/features.file-upload.php[^]
|
|
|
|
|
|
I've tried putting
header('Location: http://www.google.com/');
at the end of one of my scripts, but it won't redirect. If It's just
< ?php
header('Location: http://www.google.com/');
?>
it works fine. I need to be able to run some stuff before it redirects the page.
|
|
|
|
|
In the PHP documentation[^] it actually quotes:
php.net wrote: Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP.
Two solutions:
- Have it (the header) at the top of the page before you output anything to the browser.
- Use Output Buffering[^] to hold the output before it is sent to the browser.
If at first you don't succeed, you're not Chuck Norris.
|
|
|
|
|
One other option is to echo a document.write to add a javascript redirect..its a bit of a hack, but works....provided someone does not turn off js in their browser.
|
|
|
|
|
You can run stuffs before that but make sure you dont echo anything else before giving this redirect. For e.g. validation of usernames, or anything which should be done before any HTML tags or echo is done..
- Jay.
|
|
|
|
|
Hello !
I want to hire a coder for my site. I am making a site of family trees for everyone. For that I need a coder. Anyone interested in please leave a message.
Thank you!
|
|
|
|
|
Don't give up do you?
Re-read what you have previously been told in other threads in this forum and the Collaboration forum. And stop asking the same question as the answer will not change.
modified 1-Aug-19 21:02pm.
|
|
|
|
|
I know what I got ; no one will make it for you better to hire.
RIGHT ?
And I am paying for that not getting free .....
modified on Sunday, November 7, 2010 6:05 PM
|
|
|
|
|
Try Freelancer websites please.
The best I know is vworker.com. You will surely find many coders looking for such opportunities. Its not that we dont welcome being paid, but just this website is not meant for that.
Thanks.
- Jay.
|
|
|
|
|
what's your budget mate ?
|
|
|
|
|
I'm trying to create a php file that always returns a json as response. The problem is, it looks like it's returning a valid JSON, but jquery.ajax always says "invalid json." I copied and pasted the response and stuck it in jsonlint.com and it says it's valid json.
Can anyone point out what I'm doing wrong here? Why can't jquery (and other json parser) parse this even it's a valid json?
header('Content-type: application/json');
include("database.php");
require_once "../lib/JSON.php";
$json = new Services_JSON();
$method = strtolower($_SERVER['REQUEST_METHOD']);
$value = array();
$DB = new DBConnect();
$DB->NewConnection("localhost", "db_name", "db_role", "db_pw" );
if ($method == "get"){
$value = getEmployees();
}
else if ($method == "post"){
}
else if ($method == "put"){
}
else {
echo "Error - unknown http request method";
}
echo $_GET['callback'] . '(' . $json->encode($value) . ');';
|
|
|
|
|
It seems that everything is fine. Probably, the code segment is going on the last else statement, and so, it prints an invalid Json line there.
Try debugging that particular location, and you probably would be able to find it.
|
|
|
|
|
what is the response?
what does firebug say?
|
|
|
|
|
Hi all,
Is there any script for converting a PDF file to HTML in php ?
Thanks in advance.
|
|
|
|
|
|
You have posted the same question on 4 different forums; please, don't do it!
The best when asking something is to choose the forum that better matches your subject, and post a unique question explaining as better as possible what is your problem.
Thank you!
|
|
|
|
|
You'd better put your fireproof overalls on right now. Posting the same question in multiple forums (where the question doesn't fit in any of them) is only going to get you flamed out of here.
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
I think it's time they started a Powershell forum
|
|
|
|
|
Hi
Thanks in advance for helping me. I have this mySQL query that fails i have no idea why i. Below is the code I left some space for readability
$lines=file("somefile5640.001");
$headerTable=explodeX(Array(",","\n"),$lines[0]);
$table ="HeaderRecord";
WriteArrayToHeaderDatabase($headerTable,$table);
function WriteArrayToHeaderDatabase($headerTable,$table)//Pass which table am i writing to
{
//I do the connecting to database here which is fine the problem is below
$query = "INSERT INTO ".$table."(FileIdentifier, Version, ReceiverIdentifier, Date, Time, FileGenerationNumber) VALUES";
for($i = 0, $c = count($headerTable); $i < $c; $i += 6) {
// Add the next batch of values to the query string
$query.= "('".$headerTable[$i]."','".$headerTable[$i+1]."','".$headerTable[$i+2]."','".$headerTable[$i+3]."','".$headerTable[$i+4]."','".$headerTable[$i+5]."')";
//$query .= "(".$headerTable[$i].",".$headerTable[$i+1].",".$headerTable[$i+2].",".$headerTable[$i+3].",".$headerTable[$i+4].",".$headerTable[$i+5].")";
echo "Query is failing";
// Add a comma is this is not the last batch
if($i + 1 < $c) {
//$query .= "";
$query .=",";
}
echo $query;
$result = mysql_query($query);
if (!$result) {
die('Query failed: ' . mysql_error());
}
}
return true;
// When i echo the query and run the code i get what shown below
Query is failingINSERT INTO HeaderRecord(FileIdentifier, Version, ReceiverIdentifier, Date, Time, FileGenerationNumber) VALUES('SOF','1','1500','19970519','112904','1 '),Query failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
|
|
|
|
|
Firstly, let me state that I'm no MYSQL expert. However, assuming the the INSERT INTO query works in the same way as it does in SQL Server, your problem is that you are trying to create multiple records using a single INSERT INTO query. You can only add one record at a time.
|
|
|
|
|
Yes and no, MySql supports multiple inserts in one query just like was coded in the example.
That being said PHP does not support multiple queries in one mysql_query call, as is documented on PHP documentation.
|
|
|
|
|
Thanks for the response. I am trying to create one record but the query is repeated more than once. I don't know where in my code do i repeat the query.
|
|
|
|
|
The problem is in your for loop. You start building up your insert just above it and then append the values in the loop. This might not seem like a problem, but when you look at what it does it is something like this:
q="insert into blaat(col1, col2) values"
Run 1:
q="insert into blaat(col1, col2) values('1','2'),"
mysql_query($q)
Run 2:
q="insert into blaat(col1, col2) values('1','2'),('3','4'),"
mysql_query($q)
Run 3:
q="insert into blaat(col1, col2) values('1','2'),('3','4'),('5','6'),"
mysql_query($q)
So the problem is probably two things. First you are appending to the q variable every time you loop through the for. This type of insert will work in a console MySQL client app, but I doubt that PHP supports it. Then there is a second issue with this, inside the loop you are running the mysql_query. So every single time you loop you are running the query over and over again.
The second issue is that you instantly add the ',' in the for loop. Since $i + 1 < $c is valid as soon as there is even one row to be inserted.
|
|
|
|
|
I honestly do not understand why it has to run(iterate) more than once as $i += 6 will make $i < $c false just after a single iteration. I'm pulling my hair here, i really need this sorted as in yersterday.
|
|
|
|