사용자가 사진을 업로드하고 방금 만든 이벤트 페이지에만 업로드 한 사진을 표시 할 수 있습니다. 이를 위해 모든 이벤트가 생성 된 PHP 데이터베이스를 만들었습니다. 각 이벤트에는 고유하게 만들기 위해 25 자의 임의의 키가 있습니다.특정 페이지에 그림 표시
내 문제는 올바른 이벤트를 무작위 키 («MomentEvent»)로 사용하여 그림을 업로드하려고하지만 항상 목록의 첫 번째 이벤트 인 하나의 이벤트에서만 업데이트된다는 것입니다.
MomentEvent 키를 사용하여 올바른 이벤트에서 사진을 어떻게 업로드 할 수 있습니까?
다음 페이지는 그림이 축소판 그림으로 변형되어 표에서 업데이트되고 두 번째 페이지가 그림이 나타나는 위치입니다.
ajax_image.php
<?php
include('db.php');
session_start();
$session_id=$_SESSION['id']; // Or Session ID
$session_MomentEvent=$_SESSION['MomentEvent']; // Or Session ID
$actual_image_names = time().substr($txt, 9).".".$ext;
$t_width = 450; // Maximum thumbnail width
$t_height = 150; // Maximum thumbnail height
$new_name = "$actual_image_names".$session_MomentEvent.".jpg"; // Thumbnail image name
$path = "images/";
if(isset($_GET['t']) and $_GET['t'] == "ajax"){
extract($_GET);
$ratio = ($t_width/$w);
$nw = ceil($w * $ratio);
$nh = ceil($h * $ratio);
$nimg = imagecreatetruecolor($nw,$nh);
$im_src = imagecreatefromjpeg($path.$img);
imagecopyresampled($nimg,$im_src,0,0,$x1,$y1,$nw,$nh,$w,$h);
imagejpeg($nimg,$path.$new_name,90);
mysql_query("UPDATE users_event SET image_small='$new_name' WHERE MomentEvent='$session_MomentEvent'");
echo $new_name."?".time();
exit();
}
?>
show_picture.php는
<?php
include('base.php');
//We check if the users ID is defined
if(isset($_GET['MomentEvent']))
{
$MomentEvent = $_GET['MomentEvent'];
//We check if the user exists
$sql = "select ID, TitreEvent, DescriptionEvent, LieuEvent, image_small from users_event where MomentEvent='$MomentEvent'";
$dn = mysql_query($sql);
if(mysql_num_rows($dn)>0)
{
$dnn = mysql_fetch_array($dn);
//We display the user datas
{ // <---- EDITOR: WHAT IS THAT ? You wanted to put a closing brace (}) ??
echo "<div class='container';><img src=http://www.*******.com/images/".$dnn ['image_small'] ." HEIGHT='150px' WIDTH='450px'></div> <br>";
}
} //<-- EDITOR: THIS closing braces were missing
} // <-- EDITOR: THIS one too
?>
$ txt 및 $ text ..는 무엇인가요? –
- 전반적으로 논리가 보인다, 당신은 var_dump() MomentEvent해야합니다, 거기에 문제가있을 수 있다고 생각합니다. - SQL 인젝션에는 mysql_ 함수를 사용하지 않는 것이 좋습니다. 사용하지 않는 것이 좋습니다. mysqli_ 함수 나 더 나은 PDO를 살펴보십시오. - 미래에는 스스로 추출물을 사용하지 않는 것이 좋습니다. 그렇지 않으면 변수가 어디서 왔는지 모르기 때문에 코드를 혼란스럽게하는 사람이있을 수 있습니다 (일부 사람들에게는 나쁜 습관으로 여겨짐). 가 - 당신은 이상한 표 - 보내고 내가 본 XDD의 멋진을 가지고 있지만 그것을 읽고 혼란 : @freddy, 난 그냥 쉽게 읽을 수 있도록 코드를 편집하고/이상한 중괄호를 놓치게 한 헤이 P – aleation
({) 모든 이상 if 및 mysql_query (ajax_image.php에서)가 반환하는 것을 저장하는 경우 true 또는 false, 특히 디버깅하는 경우. – aleation