List Info

Thread: Newbie - Parse error




Newbie - Parse error
country flaguser name
United States
2007-05-30 06:17:38
Hi all

I am using a PHP script from Codewalkers.com to work with a
database
of images (or image filename).  The code is as follows:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php
// index.php - by Hermawan Haryanto &lt;hermawancodewalkers.com&gt;
// Example PHP Script, demonstrating Storing Image in
Database
// Detailed Information can be found at http://www.codewalkers.com

// database connection $conn =
mysql_connect("localhost", "username",
"password")   OR DIE (mysql_error());
mysql_select_db ("testimages", $conn) OR
DIE (mysql_error());
// Do this process if user has browse the
// file and click the submit button
if ($_FILES) {
$image_types = Array ("image/bmp",
					  "image/jpeg",
					  "image/pjpeg",
					  "image/gif",
					  "image/x-png");
if (is_uploaded_file
($_FILES["userfile"]["tmp_name"])) {
	$userfile  = addslashes (fread                  (fopen
($_FILES["userfile"]["tmp_name"],
"r"),                  filesize
($_FILES["userfile"]["tmp_name"])));
	$file_name =
$_FILES["userfile"]["name"];
	$file_size =
$_FILES["userfile"]["size"];
	$file_type =
$_FILES["userfile"]["type"];

if (in_array (strtolower ($file_type), $image_types)) {
	$sql = "INSERT INTO image "              .
"(image_type, image,
image_size, image_name, image_date) ";
	$sql.= "VALUES (";
	$sql.= "'{$file_type}', '{$userfile}',
'{$file_size}',
"              . "'{$file_name}', NOW())";
mysql_query ($sql, $conn);
Header("Location:".$_SERVER["PHP_SELF"])
;
exit();
}
}
}
// Do this process if user has clicked
// a file name to view or remove
if ($_GET) {
$iid = $_GET["iid"];
$act = $_GET["act"];
switch ($act) {
case rem:
	$sql = "DELETE FROM image WHERE image_id=$iid";
	mysql_query ($sql, $conn);
	Header("Location:./index.php");
	exit();
	break;
	default:
	print "&lt;img src= "image.php?iid=$iid
"&gt;";
	break;   } }
?>

<html>
<head>
<title>Storing Images in DB</title>
</head>

<body>
<form method="post"
enctype="multipart/form-data">Select Image
File:
  	<input type="file" name="userfile"
 size="40" />
	<input type="submit"
value="submit">
</form>

<?php
 $sql = "SELECT * FROM image ORDER BY image_date
DESC";
 $result = mysql_query ($sql, $conn);
 if (mysql_num_rows($result)&gt;0) {
 while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
 	$i++;
	$str .= $i.". ";
	$str .= "<a
href='index.php?iid=".$row["image_id"]."
'>"
		. $row["image_name"]."</a> ";
	$str .= "[".$row["image_date"]."]
";
	$str .= "[".$row["image_size"]."]
";
	$str .= "[<a
href='index.php?act=rem&amp;iid=".
$row["image_id"]
		 . "'>Remove</a>]<br>";
}
print $str;
}
?>
</body>
</html>

When running this script I get the following error message:

Parse error: parse error, unexpected ';' in
C:htdocsPhotosindex.php
on line 63

FYI in DW line 63 is:   if
(mysql_num_rows($result)&gt;0) {

I do not find the reason for this error on lines 62 or 63. 
Can anyone
help me out?

Thanx in advance.

Plato


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "PHP & MySQL" group.
To post to this group, send email to phpmysqlgooglegroups.com
To unsubscribe from this group, send email to
phpmysql-unsubscribegooglegroups.com
For more options, visit this group at http://
groups.google.com/group/phpmysql?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Newbie - Parse error
country flaguser name
United States
2007-06-08 09:13:48
On that line, &gt; should be >

-AS


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "PHP & MySQL" group.
To post to this group, send email to phpmysqlgooglegroups.com
To unsubscribe from this group, send email to
phpmysql-unsubscribegooglegroups.com
For more options, visit this group at http://
groups.google.com/group/phpmysql?hl=en
-~----------~----~----~----~------~----~------~--~---


xml too big
country flaguser name
Germany
2007-06-08 12:03:45
hello to you all,

I am just trying to get an xml-file into a database. the
file is about
75 mb big and my provider does not allow to read files by
this size.
so I cannot read it by "filesize". when I try to
read it in parts of
4096 bytes I get an error that the document were "not
well formed".
using 1024 bytes gives back "xml declaration not at
start of external
entity".

splitting the file by hand is not
practical because my computer seems not capable even I have
2 GB of
memory.

I would prefer to a solution working on the webspace.

what would you suppose to do please ?

thx in advance,

 ;)di
 



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "PHP & MySQL" group.
To post to this group, send email to phpmysqlgooglegroups.com
To unsubscribe from this group, send email to
phpmysql-unsubscribegooglegroups.com
For more options, visit this group at http://
groups.google.com/group/phpmysql?hl=en
-~----------~----~----~----~------~----~------~--~---


[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )