|
I bought a book at Barnes & Noble, the store, not online, but you could start here: Learning advanced PHP[^].
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
Hi All
Now Iam In A Problem Is it possible to upload file to a windows server?
i used this code for uploading file i got this code from w3schools.com
<form action="upload_file.php" method="post"
enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file" />
<br />
<input type="submit" name="submit" value="Submit" />
</form>
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 20000))
{
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "<br />";
echo "Type: " . $_FILES["file"]["type"] . "<br />";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
if (file_exists("upload/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"upload/" . $_FILES["file"]["name"]);
echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
}
}
}
else
{
echo "Invalid file";
}
This Script is Working Good On My Local wamp server and also working fine in my linux server
i checked phpinfo() of my windows server
fileupload is on
and max_upload size is 32 mb
Thease Are My Server informations
OS/Hosting Type: Windows / 4GH Web Hosting
Hosting Configuration:
.Net Runtime Version: ASP.Net 2.0/3.0/3.5
PHP Version: PHP 5.3
IIS Version: IIS 7.0
Please Help Me To Do This
Arunkumar.T
modified on Thursday, August 4, 2011 7:02 AM
|
|
|
|
|
use this to make sure the file is posting the data to the server.
<?php
echo "<pre>";
print_r($_POST);
print_r($_FILES);
echo " ";
?>
place that at the top of the script you are posting to (upload_file.php) and run it. If your post and files are getting to the server then look at your file permissions of the target directory and of the upload_file.php and make sure they are permitted to do what you want them to do.
Chris J
www.redash.org
|
|
|
|
|
Thank you For Helping me cjoki
I Done What you Said Igot this message
i got message like this
Array
(
[submit] => Submit
)
Array
(
[file] => Array
(
[name] => Water lilies.jpg
[type] => image/jpeg
[tmp_name] => D:\Temp\php\php9B61.tmp
[error] => 0
[size] => 83794
)
)
I Thing It Seems Ok But The File Uploading Is Failed
Can you Tell Me Why This Happen ?
Please Help Me?
Arunkumar.T
|
|
|
|
|
Your file upload did not fail...but looking at your echoed $_FILES data and your code snip the issue looks to be in this area...can you see it?
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 20000))
compare this to your last post.
Chris J
www.redash.org
|
|
|
|
|
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 20000))
Yes I Removed These Statements From My Code Now Uploading is working fine but how can i validate file type and file errors ? is there any other way to do this?
Thankyou
Arunkumar.T
|
|
|
|
|
Hello friends,
I have to implement web services in one of project.The choices are php inbuilt soap vs nusoap.
Can you tell pros and cons of the two.I just came to know that recent php soap extension is newer and faster.
Some people however say that nusoap is better,but I have also came to know that it is pretty buggy.
Thanks to all
|
|
|
|
|
Hello friends,
I am new to Web services and SOAP.
I am trying to connect to the demo API link using SOAP.
But it gives me the following msg.
<pre lang="PHP">stdClass Object
(
[ProcessTransactionResult]
Failed
69601
Invalid Credentials - 221.135.137.184
)</pre>
$params = array(parameters);
$request = new Apisoap();
$response = $request->ProcessTransaction($params);
print_r($response);</pre>
Am I wrong somewhere writing class for SoapClient?
Please help me to solve the problem.
Thank you.
|
|
|
|
|
Hi,
Can someone please tell me how I can control user logins using session?
for expample, when the user logouts from the account, he is redirected back to the home page. but, if he clicks back the account is displayed again. this means the session was not ended. how can i get over this problem?
thnks in advance
|
|
|
|
|
You are forgetting to terminate the session on logout, or at least clear out the session variables that you are using to detect if someone is logged in.
Because it is so hard to Google for how to terminate a session, here is the link http://www.php.net/manual/en/function.session-destroy.php[^]
|
|
|
|
|
On the logout.php you need to set up this
session_unset() ;
session_destroy() ;
www.malorgio.it
|
|
|
|
|
You can also store sessions to database it is a good way to manage user sessions.
Arunkumar
|
|
|
|
|
what is the regex to replace only the last comma, using preg_replace? Thanks
|
|
|
|
|
It goes something like /,[^,]*$/ Fire up expresso and try it. The logic is "comma, any number of non-commas, end" So all but the last comma will fail the second part.
Cheers,
Peter
ps There is a regex forum here. Next time...
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
hello there
i want to update multiple rows which comes from a dynamic table in Dreamweaver CS5 (a loop in php) here is my Mysql table :
CREATE TABLE `register`.`s_lessons` (<br />
`lid` int( 5 ) NOT NULL ,<br />
`sid` int( 9 ) NOT NULL ,<br />
`term` int( 5 ) NOT NULL ,<br />
`tid` int( 5 ) NOT NULL ,<br />
`point` double NOT NULL DEFAULT '0',<br />
PRIMARY KEY ( `lid` , `sid` , `term` ) ,<br />
KEY `tid` ( `tid` ) ,<br />
KEY `point` ( `point` )<br />
) ENGINE = MYISAM DEFAULT CHARSET = utf8 COLLATE = utf8_persian_ci;
and this is my page source code:
<?php require_once('../Connections/register.php'); ?><br />
<?php<br />
session_start();<br />
if (!function_exists("GetSQLValueString")) {<br />
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") <br />
{<br />
if (PHP_VERSION < 6) {<br />
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;<br />
}<br />
<br />
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);<br />
<br />
switch ($theType) {<br />
case "text":<br />
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";<br />
break; <br />
case "long":<br />
case "int":<br />
$theValue = ($theValue != "") ? intval($theValue) : "NULL";<br />
break;<br />
case "double":<br />
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";<br />
break;<br />
case "date":<br />
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";<br />
break;<br />
case "defined":<br />
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;<br />
break;<br />
}<br />
return $theValue;<br />
}<br />
}<br />
<br />
$colname1_rs1 = "-1";<br />
if (isset($_GET['term'])) {<br />
$colname1_rs1 = $_GET['term'];<br />
}<br />
$colname_rs1 = "-1";<br />
if (isset($_GET['lid'])) {<br />
$colname_rs1 = $_GET['lid'];<br />
}<br />
$colname2_rs1 = "-1";<br />
if (isset($_SESSION['tid'])) {<br />
$colname2_rs1 = $_SESSION['tid'];<br />
}<br />
mysql_select_db($database_register, $register);<br />
$query_rs1 = sprintf("SELECT s_lessons.sid, s_lessons.lid, s_lessons.term, s_lessons.tid, s_lessons.point FROM s_lessons WHERE s_lessons.lid = %s AND s_lessons.term = %s AND s_lessons.tid = %s", GetSQLValueString($colname_rs1, "int"),GetSQLValueString($colname1_rs1, "int"),GetSQLValueString($colname2_rs1, "int"));<br />
$rs1 = mysql_query($query_rs1, $register) or die(mysql_error());<br />
$row_rs1 = mysql_fetch_assoc($rs1);<br />
$totalRows_rs1 = mysql_num_rows($rs1);<br />
$count=mysql_num_rows($rs1);<br />
<br />
<br />
<br />
$editFormAction = $_SERVER['PHP_SELF'];<br />
if (isset($_SERVER['QUERY_STRING'])) {<br />
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);<br />
}<br />
<br />
for ($j = 0, $len = count($_POST['lid']); $j < $len; $j++) {<br />
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {<br />
$updateSQL = sprintf("UPDATE s_lessons SET point=%s WHERE tid=%s, lid=%s, sid=%s, term=%s",<br />
GetSQLValueString($_POST['point'] [$j], "double"),<br />
GetSQLValueString($_SESSION['tid'], "int"),<br />
GetSQLValueString($_POST['lid'] [$j], "int"),<br />
GetSQLValueString($_POST['sid'] [$j], "int"),<br />
GetSQLValueString($_POST['term'] [$j], "int"));<br />
<br />
mysql_select_db($database_register, $register);<br />
$Result1 = mysql_query($updateSQL, $register) or die(mysql_error());<br />
}<br />
$updateGoTo = "student_lists.php";<br />
if (isset($_SERVER['QUERY_STRING'])) {<br />
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";<br />
$updateGoTo .= $_SERVER['QUERY_STRING'];<br />
}<br />
header(sprintf("Location: %s", $updateGoTo));<br />
}<br />
<br />
?><br />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><br />
<html xmlns="http://www.w3.org/1999/xhtml"><br />
<head><br />
<meta name="keywords" content="" /><br />
<meta name="description" content="" /><br />
<meta http-equiv="content-type" content="text/html; charset=utf-8" /><br />
<title>r</title><br />
<link href="styles/style.css" rel="stylesheet" type="text/css" media="screen" /><br />
<link href="styles/in_styles.css" rel="stylesheet" type="text/css" media="screen" /><br />
</head><br />
<body><br />
<div id="wrapper"><br />
<div id="header-wrapper"><br />
<br />
</div><br />
<!-- end #header --><br />
<div id="page"><br />
<div id="page-bgtop"><br />
<div id="page-bgbtm"><br />
<div id="content"><br />
<div class="post"><br />
<div style="clear: both;"><br />
<form name="form1" id="form1" method="post" action="<?php echo $editFormAction; ?>"><br />
<table border="1" align="center"><br />
<tr><br />
<th>Student ID</th><br />
<th>Lesson ID</th><br />
<th>Semester</th><br />
<th>Point</th><br />
<br />
</tr><br />
<?php do { ?><br />
<tr><br />
<td class="data"><label for="sid[]"></label><br />
<input name="sid[]" type="text" id="sid[]" value="<?php echo $row_rs1['sid']; ?>" size="9" readonly="readonly" /></td><br />
<td class="data"><label for="lid[]"></label><br />
<input name="lid[]" type="text" id="lid[]" value="<?php echo $row_rs1['lid']; ?>" size="5" readonly="readonly" /></td><br />
<td class="data"><label for="term[]"></label><br />
<input name="term[]" type="text" id="term[]" value="<?php echo $row_rs1['term']; ?>" size="4" readonly="readonly" /></td><br />
<td><label for="point[]"></label><br />
<input name="point[]" type="text" id="point[]" value="<?php echo $row_rs1['point']; ?>" size="4" /> <br />
</tr><br />
<br />
<?php } while ($row_rs1 = mysql_fetch_assoc($rs1)); ?><br />
</table><br />
<p><br />
<input type="submit" name="Submit" id="Submit" value="Submit" /><br />
<input type="hidden" name="MM_update" value="form1" /><br />
</p><br />
</form><br />
</div><br />
</div><br />
<div style="clear: both;"><br />
</div><br />
</div><br />
<!-- end #content --><br />
<br />
<!-- end #sidebar --><br />
<div style="clear: both;"> </div><br />
</div><br />
</div><br />
</div><br />
<!-- end #page --><br />
</div><br />
<!-- end #footer --><br />
</body><br />
</html><br />
<?php<br />
mysql_free_result($rs1);<br />
?>
All i want is that when users click on SUBMIT button values of point column in s_lessons(database table) be updated by new entries from user.
i did my best and result with that code is :
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 ' lid=888, sid=860935422, term=902' at line 1
I would appreciate any idea.
with prior thanks
|
|
|
|
|
Your problem is in the Query you are using to update the record:
UPDATE s_lessons SET point=%s WHERE tid=%s, lid=%s, sid=%s, term=%s
Is not valid Sql, and should be something like
UPDATE s_lessons SET point=%s WHERE tid=%s and lid=%s and sid=%s and term=%s
You might wanna read up a bit on the SQL update syntax[^]
|
|
|
|
|
what a silly mistake!
you are right.i changed it and the problem solved!
thank you very much.
|
|
|
|
|
Does anyone know if samba has certain supported/preferred file systems? ...or does it not matter?
I'll be accessing the share with:
- Ubuntu Lucid
- Windows XP, Vista, 7
|
|
|
|
|
Went with ext4, doesn't seem to really matter since samba doesn't really allow for direct access... Windows machines seem to be ok with it...
|
|
|
|
|
Samba operates through the VFS (virtual file system), so anything you can use in Linux, Samba will be able to use and share it.
--
Kein Mitleid Für Die Mehrheit
|
|
|
|
|
What I'm trying to do should be simple but for some reason it's not. All I want right now is to display one of my session variables on the page (this way I know it's what I think it is).
I have <td><input name="myusername" type="text" id="myusername" style="width:150px"></td> on the first form to get the value and then session_register("myusername"); on the next page to assign the value to the session variable.
I then have (this is the very top of the page (page 3))
<?php
session_start();
if (!session_is_registered(myusername)) {
header("location:login.php");
}
?>
Test
<?php
$test = $_SESSION["myusername"];
echo $test;
?>
On the "last" page... the page isn't redirecting so I know the value is "good" but for some reason I can't get it to display. It's just displaying 'Test'...
|
|
|
|
|
5.1.6
However stupid here realized that he forgot to actually assign the session variable a value. I guess the important thing is I figured it out
|
|
|
|
|
Thanks for the FYI, I'll account for it now before I forget about it.
|
|
|
|
|
I figured out my problem... as usual forgot the most simple aspect of programming $_SESSION['myusername'] = $myusername;
I really does help to actually assign a value to something... Hopefully this will help someone else that finds them self in the same lack of sleep state.
|
|
|
|
|
Even though you seem to have found a solution, I have actually found some web hosting to be quite a pain if you are using Sessions. Depends on the provider though. With my current provider it was becoming way to complicated to set up properly so I used another method
|
|
|
|