소셜 네트워크를 쓰고 있습니다. 소식이 뉴스 피드에 표시되면 프로필 사진과 작가 이름이 표시되지 않습니다. 여기 내 코드 :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!');
?>
이 설정을 포함하는 라인을 게시하시기 바랍니다 범위를 좁히는 데 도움이됩니다 .inc 파일을 원래의 PHP 스크립트에 저장하십시오. – kjones