Hi, i am building a "pastbin".
First: I'am norwegian, so iam not so good in english :p
But have a problem to highlight the string.
The strings are being insert to a database first.
index.php
echo highlight_string(include 'vis.php');
vis.php:
<?php
$object = mysql_fetch_object($select_query);
echo $object->kode;
?>
The code wil not be coloring :queasy:
Help ?
Whole index code:
<?php error_reporting(E_ALL); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Pastebin</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<?php
/***************************************
** KONFIGURASJON
***************************************/
// inkluder funksjoner
$func_inc_fil = "func.php";
include_once $func_inc_fil;
// mysql
$tjener = 'localhost';
$brukernavn = 'root';
$passord = '';
$database = 'test';
$tabell = 'pastbin';
$tilkobling = mysql_connect($tjener, $brukernavn, $passord);
$database = mysql_select_db($database);
$errormld_navn = 'error 1';
/***************************************
** START SCRIPT
***************************************/
// Vis tilkoblingen inneholder feil, vis feilmelding
if(!$tilkobling OR !$database) {
print (mysql_error());
die();
}
if(array_key_exists('legg_ode', $_POST))
{
$name = htmlspecialchars($_POST['navn'], ENT_QUOTES);
if(strlen($name) < 3) {
$error = $errormld_navn;
}
else {
$code = htmlspecialchars($_POST['kode_d'], ENT_QUOTES);
$sqlinsert = "INSERT INTO ". $tabell ." VALUES ('', '$name', '$code')";
$query = mysql_query($sqlinsert);
if(!$query) {
print (mysql_query());
}
else {
$insert = true;
}
}
}
if(isset($error)) {
print $error . '<br />';
} else {
if(isset($insert)) {
print 'Din kode er lagt til!';
} }
form();
if($_GET['kode']) {
$id = $_GET['kode'];
$select = "SELECT * FROM ". $tabell ." WHERE id = '". $id ."'";
$select_query = mysql_query($select);
if(!$select_query) {
print (mysql_error());
}
else {
echo highlight_string(include 'vis.php');
}
}
mysql_close($tilkobling);
?>