2012-04-13 3 views
-2

소셜 네트워크를 쓰고 있습니다. 소식이 뉴스 피드에 표시되면 프로필 사진과 작가 이름이 표시되지 않습니다. 여기 내 코드 :MYSQL 코드 풀링 정보가 없습니다.

$owner_id=mysql_result($result,$i,"post_owner_id"); //Post writer's user ID 
$content=mysql_result($result,$i,"content"); //Content of the post 
$date=mysql_result($result,$i,"date"); //Date 
$time=mysql_result($result,$i,"time"); //Time 
$poi_query=mysql_query("SELECT firstname, lastname, profile_picture FROM users WHERE id = '" . $owner_id . "'"); //MYSQL query to get the information of the post writer using user ID 
$post_firstname=mysql_result($poi_query, 0, "firstname"); //Writer's first name 
$post_lastname=mysql_result($poi_query, 0, "lastname"); //Writer's Last name 
$post_profile_picture=mysql_result($poi_query, 0, "profile_picture"); //Writer's profile picture 
?> 

     <div class="post"> 
     <h1 class="post-title"><a href="profile.php?user=<?php echo $owner_id; ?>"> <?php echo $post_firstname; ?> <?php echo $post_lastname; ?></a></h1> 
     <p class="content"><?php echo $content; ?></p> 
     <p class="details"><?php echo $date; ?> at <?php echo $time; ?></p> 
     <br/><hr/><br/> 
     </div> 

다른 모든 것은 이름과 그림 외에도 완벽하게 작동합니다. 어떤 도움이 필요합니까? 나는 거의 poi_query와 관련이있다. ... 그리고 사용자 ID를 수동으로 입력하면 모든 코드가 제대로 작동한다.

Config.inc :

<?php 

$hostname = 'localhost';  // Your MySQL hostname. Usualy named as 'localhost', so you're NOT necessary to change this even this script has already online on the internet. 
$dbname = 'social-network'; // Your database name. 
$username = 'root';    // Your database username. 
$password = '********';     // Your database password. If your database has no password, leave it empty. 

// Let's connect to host 
mysql_connect($hostname, $username, $password) or DIE('Connection to host is failed, perhaps the service is down!'); 
// Select the database 
mysql_select_db($dbname) or DIE('Database name is not available!'); 

?> 
+0

이 설정을 포함하는 라인을 게시하시기 바랍니다 범위를 좁히는 데 도움이됩니다 .inc 파일을 원래의 PHP 스크립트에 저장하십시오. – kjones

답변

0

변경이 라인 :

$poi_query=mysql_query("SELECT firstname, lastname, profile_picture FROM users WHERE id = '" . $owner_id . "'");

에 : 당신은 MySQL의에서 쿼리에 대한 오류 메시지를 수신하는 경우

$poi_query=mysql_query("SELECT firstname, lastname, profile_picture FROM users WHERE id = '" . $owner_id . "'") or die(mysql_error());

볼 수 있습니다.

편집 :

문제는 여기에 $poi_query 할당을 방해 한 전화 mysql_close(); 인 결말.

0

내가 볼 수있는 유일한 것은, 어쩌면 OWNER_ID에서 따옴표를 제거한다?

$poi_query=mysql_query("SELECT firstname, lastname, profile_picture FROM users WHERE id = " . $owner_id); 
+0

Nope. 일하지 않았어. –

+1

$ owner_id를 반향 출력하지 않으려 고 시도 했습니까? –

+0

@CassieCarter 또한 좋은 생각인데,'$ owner_id'가 쿼리 문에 입력 될 때 기대하는 값인지 확인해야합니다. – kjones

-1

$poi_query=mysql_query("SELECT firstname, lastname, profile_picture FROM users WHERE id = " . $owner_id) or die(mysql_error()); 

을 시도하거나 그 제공을 확인하려면 변수를 덤프하려고

var_dump($poi_query); 

이것은 당신이 문제