💬
Logga in
Fuska.se

Hjälp Med Php Kod

6 svar · startad

Trådstartare #1

Behöver hjälp med ett kommentarsfält jag gjorde efter en guide i datormagazin nr 11 -09

här är koden:

 

<?php

class comment extends mode1

{

function get_commets ($video_id)

{

// Hämta kommentare till angivet videoklipp

$this->db->select ( `author, coment, date, id´) ->from (`comments´)->where (`video´, $video_id->order_by"date, id", "desc");

 

$query = $this->db->get();

 

return $query->result_array();

}

 

function get_latest_comment()

{

//hämta senaste kommentar

$this->db->select(`*´)->from(`video`)->join(`comments´, `comments.video = video.id´, `inner´)->order_by(`comments.date, comments.id`, `desc´)->limit(1, 0;

 

$query = $this->db->get();

 

return $query->row_array();

}

 

function insert_comment($video_id)

{

// spara kommentar

$this->video = $video_id;

$this->author = $_post[`author];

$this->comment = $_post[`comment];

$this->date = date("Y-m-d");

 

$this->db->insert(`comments´,$this);

}

}

?>

är det något fel i koden eller ska man inte klistra in den under body taggen i ett html dokumet?

#2

Du är inte ansluten till någon databas?

7 Nov 2009
Trådstartare #3

WAMP 2 men koden visas som text

#4

Prova att spara som .php

Trådstartare #5

Har provat men problemet kvarstår

#6

Jag såg nu att du hade glömt lite parenteser och citationstecken. Jag har fixat det nu.

<?php
class comment extends mode1
{
function get_commets ($video_id)
{
// Hämta kommentare till angivet videoklipp
$this->db->select('author, coment, date, id')->from('comments')->where('video', $video_id >order_by('date, id', 'desc'));

$query = $this->db->get();

return $query->result_array();
}

function get_latest_comment()
{
//hämta senaste kommentar
$this->db->select('*')->from('video')->join('comments', 'comments.video = video.id', 'inner')->order_by('comments.date, comments.id', 'desc')->limit(1, 0);

$query = $this->db->get();

return $query->row_array();
}

function insert_comment($video_id)
{
// spara kommentar
$this->video = $video_id;
$this->author = $_post['author'];
$this->comment = $_post['comment'];
$this->date = date("Y-m-d");

$this->db->insert('comments',$this);
}
}
?>

Jag hoppas du vet hur klassen funkar.

Senast ändrad:

18 Nov 2009
#7

Om ni inte löst det själv redan:

Har ni sparat koden i klartext? Om ja så är det WAMP som inte har koll på inställningarna.

Vill du vara med i diskussionen?

Bli medlem Logga in