19. juli 2007 - 14:31
Der er
3 kommentarer og
1 løsning
UPDATE mysql lille fejl. Lidt hjælp
Hej jeg har et lille problem når jeg vil update min mysql
Får denne besked:
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
$mypic=$_POST['thumb$thename'];
mysql_query("UPDATE b_users set photo='".$_POST['$mypic']."' where username=".$_POST['$user']."") OR DIE(mysql_error());
Meningen er at den skal indsætte $mypic i photo inde i b_users når man har brugernavn $user
Hej igen rettede lige lidt i koden, men får stadig en fejl
$user=$_SESSION['user'];
$mypic=$_POST['thumb$thename'];
mysql_query("UPDATE b_users set photo='['$mypic']' where username=['$user']") OR DIE(mysql_error());
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 '['username']' at line 1
Ok lige endnu et problem den skulle gerne vise navnet på billedet inde i "photo" men der står ingenting? jeg får ikke længere nogen mysql fejl..
<?php
session_start();
include "../connect.php";
include "../admin/var.php";
?>
<?php
if(isset($_POST['submit']))
{
$new_height=100;
$new_width=100;
$allowed_types = array(
'image/pjpeg',
'image/gif',
'image/png',
'image/jpeg');
if(in_array($_FILES['thefile']['type'], $allowed_types))
{
copy ($_FILES['thefile']['tmp_name'], $_FILES['thefile']['name']) or die ("Could not copy");
echo "Name: ".$_FILES['thefile']['name']."";
echo "Size: ".$_FILES['thefile']['size']."";
echo "Type: ".$_FILES['thefile']['type']."";
$imagefile=$_FILES['thefile']['name'];
list($width, $height) = getimagesize($_FILES['thefile']['name']);
$image_p = imagecreatetruecolor($new_width,$new_height);
if ($_FILES['thefile']['type'] == "image/gif")
{
$img = @imagecreatefromgif($imagefile);
imagecopyresampled($image_p, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
$thename=$_FILES['thefile']['name'];
$thenames="thumb$thename";
$location="$thenames";
imagegif($image_p,$location, 100);
}
else
{
$img = @imagecreatefromjpeg($imagefile);
imagecopyresampled($image_p, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
$thename=$_FILES['thefile']['name'];
$thenames="thumb$thename";
$location="$thenames";
imagejpeg($image_p,$location, 100);
$user=$_SESSION['user'];
$mypic=$_POST['name'];
mysql_query("UPDATE b_users set photo='".$mypic."' where username='".$user."'") OR DIE(mysql_error());
}
}
else
{
print "<br>Kun jpg og gif er tilladt";
}
}
?>