开发者

Upload files: can some one let me know how to surpass this error?

this is the whole code where in I got a problem

<?php
//get the value of the selected radio value from webpage1.html
$n=$_POST['company'];
$dbhost="localhost";
$dbuser="root";
$dbpass="";
$dbname;
?>
<html><head><title>web page1</title></head><body>
<?php
// logical selection for $n
if($n==1){
echo"You selected Company <font color=red>bhagis portal</font> <br>";
$dbname="bhagis_portal";
}
elseif($n==2){
echo"You selected Company <font color=red>bli portal</font> <br>";
$dbname="bliportal";
}
elseif($n==3){
echo"You selected Company <font color=red>m portal</font> <br>";
$dbname="m_portal";
}
else{
echo"You Selected Company <font color=red>vg portal</font> <br>";
$dbname="vg_portal";
}
$conn=mysql_connect($dbhost,$dbuser,$dbpass)or die("<strong         class="highlight">Error</strong> connecting to MySQL");
mysql_select_db($dbname)or die(mysql_error());
$query="Select * from img_table";
$row=mysql_query($query)or die(mysql_error());
while($result=mysql_fetch_array($row)){
echo $result[0].") ";
echo "<img src=/".$dbname."/images/".$result[1]."><br>";
}
?>
<<strong class="highlight">form</str开发者_运维知识库ong> action="index_web_page2.php" method="post"         enctype="multipart/form-data">
<input name="hiddenField" type="hidden" id="hiddenField" value="999999">
<input type="file" id="timesheet" name="timesheet"><br>
<input type="submit" name="cb_read" id="cb_read" value="Upload Timekeeping File">
<input type=reset  name=reset value=clear></form>

<?php
$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."')";


?>
</body>
</html>

this code has the ability to select 5 database at first... I tried to have an output of images at first that will reveal it's output at the browser... by default it was not uploaded by the user but already in a folder ( only path by image tag inside the while loop statement ). My problem now is, I dunno about how to do this 2 things:

1.) if the user will upload something, it will be automatically transfered to the $destination

2.) the last upload of the user will be shown too like what is done in the while loop statement

I will truly appreciate your explanations and help


One thing is that you appear to have a syntax error here because your string contains a quote which terminates the string too early:

"<strong         class="highlight">Error</strong> connecting to MySQL"

The error is easy to notice due to the incorrect syntax highlighting.

To fix it you can use single-quotes instead of double-quotes to delimit the string:

'<strong         class="highlight">Error</strong> connecting to MySQL'
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜