我一直得到的錯誤是:stripslashes()期望參數1是字符串, 30線上的target.php不斷收到:「stripslashes()期望參數1爲字符串,在30行的/target.php中給出的數組」錯誤
這是我對這個網站的代碼,我是新手,我一直試圖做30分鐘以上。
我很抱歉問這樣一個愚蠢的問題。
<?php
// rnprofile.php
include_once 'rnheader.php';
if (!isset($_SESSION['user']))
die("<br /><br />You need to login to view this page");
$user = $_SESSION['user'];
echo "<h3>Edit your Profile</h3>";
if (isset($_POST['text'])) {
$text = sanitizeString($_POST['text']);
$text = preg_replace('/\s\s+/', ' ', $text);
$query = "SELECT * FROM rnprofiles WHERE user='$user'";
if (queryMysql($query) != false) {
queryMysql("UPDATE rnprofiles SET text='$text'
where user='$user'");
} else {
$query = "INSERT INTO rnprofiles VALUES('$user', '$text')";
queryMysql($query);
}
} else {
$query = "SELECT * FROM rnprofiles WHERE user='$user'";
$result = queryMysql($query);
$sth = $dbh->prepare($query);
$sth->execute();
if (queryMysql($query) != false/* mysql_num_rows($result) */) {
$row = $sth->fetchAll(PDO::FETCH_ASSOC);
//$row = mysql_fetch_row($result);
$text = stripslashes($row[1]);
}
else
$text = "";
}
$text = stripslashes(preg_replace('/\s\s+/', ' ', $text));
if (isset($_FILES['image']['name'])) {
$saveto = "$user.jpg";
move_uploaded_file($_FILES['image']['tmp_name'], $saveto);
$typeok = TRUE;
switch ($_FILES['image']['type']) {
case "image/gif": $src = imagecreatefromgif($saveto);
break;
case "image/jpeg": // Both regular and progressive jpegs
case "image/pjpeg": $src = imagecreatefromjpeg($saveto);
break;
case "image/png": $src = imagecreatefrompng($saveto);
break;
default: $typeok = FALSE;
break;
}
if ($typeok) {
list($w, $h) = getimagesize($saveto);
$max = 100;
$tw = $w;
$th = $h;
if ($w > $h && $max < $w) {
$th = $max/$w * $h;
$tw = $max;
} elseif ($h > $w && $max < $h) {
$tw = $max/$h * $w;
$th = $max;
} elseif ($max < $w) {
$tw = $th = $max;
}
$tmp = imagecreatetruecolor($tw, $th);
imagecopyresampled($tmp, $src, 0, 0, 0, 0, $tw, $th, $w, $h);
imageconvolution($tmp, array(// Sharpen image
array(−1, −1, −1),
array(−1, 16, −1),
array(−1, −1, −1)
), 8, 0);
imagejpeg($tmp, $saveto);
imagedestroy($tmp);
imagedestroy($src);
}
}
showProfile($user);
echo <<<_END
<form method='post' action='rnprofile.php'
enctype='multipart/form-data'>
Enter or edit your details and/or upload an image:<br />
<textarea name='text' cols='40' rows='3'>$text</textarea><br />
Image: <input type='file' name='image' size='14' maxlength='32' />
<input type='submit' value='Save Profile' />
</pre></form>
_END;
?>
以及錯誤說,它的數組不是一個字符串。 – 2012-09-24 20:01:21