Web Hosting Talk







View Full Version : [vBulletin,MySql,PHP] Help with intergrating


Twinky
03-09-2006, 04:12 AM
Ive made a little script just to practise making hacks for vBulletin.

Its a little chat/shoutout box where the user can submit some text and will display the text on the page.



There was no problem intergrating it with the style but a little problem to get it to insert the text into the database or view the text on the page. when i try nothing happens, no error messages. i Also inserted values with phpmyadmin manually but it will not show.



here is the code, could someone please tell me whats wrong with it.



<?php

// ######################## SET PHP ENVIRONMENT ###########################

error_reporting(E_ALL & ~E_NOTICE);

// ##################### DEFINE IMPORTANT CONSTANTS #######################

// change the line below to the actual filename without ".php" extention.

// the reason for using actual filename without extention as a value of this constant is to ensure uniqueness of the value throughout every PHP file of any given vBulletin installation.

define('THIS_SCRIPT', 'chat');

// #################### PRE-CACHE TEMPLATES AND DATA ######################

// get special phrase groups

$phrasegroups = array();

// get special data templates from the datastore

$specialtemplates = array();

// pre-cache templates used by all actions

$globaltemplates = array(

// change the lines below to the list of actual templates used in the script

'mychat',

);

// pre-cache templates used by specific actions

$actiontemplates = array();

// ########################## REQUIRE BACK-END ############################

require_once('./global.php');

// #################### HARD CODE JAVASCRIPT PATHS ########################

$headinclude = str_replace('clientscript', $vbulletin->options['bburl'] . '/clientscript', $headinclude);

// ########################################################################

// ######################### START MAIN SCRIPT ############################

// ########################################################################

$navbits = array();

// change the line below to contain whatever you want to show in the navbar (title of your custom page)

$navbits[$parent] = 'Test Page';

$navbits = construct_navbits($navbits);

eval('$navbar = "' . fetch_template('navbar') . '";');

// change the line below to contain the name of the actual main output template used in your script

eval('print_output("' . fetch_template('mychat') . '");');

$message=$_POST['message'];

$query="INSERT INTO " . TABLE_PREFIX . "mychat VALUES ('$message')";

mysql_query($query);

or die(mysql_error());

$query2="SELECT * FROM " . TABLE_PREFIX . "mychat";

$result=mysql_query($query2);

$num=mysql_numrows($result);

echo "<b><center>Chat history</center></b><br><br>";

$i=0;

while ($i < $num) {

$message=mysql_result($result,$i,"message");

echo "<b>Message: $message</b><br />";

$i++;

}



?>

Burhan
03-09-2006, 05:35 AM
Remove the or before your die(mysql_error()); lines, and run the script again. or only works if its on the same line, as it need something on the left to compare.