Jump to content

Comment Box Problems


inkzoid

Recommended Posts

I've got a comment box that connects to a MySQL database. I've got this error message here when I use the PHP include function to call on this script on my main page http://www.inkzoid.com/index.php ...

 

<?php

 

// calling session_start() the function which starts our authentication session

session_start();

 

// connecting to mysql server

$l = mysql_connect  ( "999.999.999.999" , "inkzoid" , "999) or die("Error connecting:<BR><BR>".mysql_error());

mysql_select_db( "inkzoid" ) or die("Error getting db:<BR><BR>".mysql_error());

 

// defining getShouts() which is our function that gets all of our shouts

function getShouts()

{

 

echo '<div align="center">

<table width="150" border="0" cellspacing="0" cellpadding="0">

  <tr>

<td>

';

 

$query = mysql_query("SELECT * FROM shouts ORDER BY id DESC LIMIT 10") or die(mysql_error());

while ($row = mysql_fetch_array($query) )

{

 

$name = stripslashes($row['Name']);

$contact = stripslashes($row['Contact']);

$shout = stripslashes($row['Shout']);

 

if(empty($contact))

{

 

echo '<p><span class="author">'.$name.'</span> - <span class="shout">'.$shout.'</span></p>';

 

} else {

 

echo '<p><span class="author"><a href="'.$contact.'" target="_blank">'.$name.'</a></span> - <span class="shout">'.$shout.'</span></p>';

 

} // if empty contact

 

} // while row mysqlfetcharray query

 

echo '<br><br>';

 

echo '

</td>

  </tr>

  <tr>

<td height="10"> </td>

<form name="shout" method="post" action="shout.php">

  <div align="center">

<input name="name" type="text" id="name" value="Name" size="25" maxlength="10"><br>

<input name="contact" type="text" id="contact" value="http://" size="25"><br>

<input name="message" type="text" id="message" value="Message" size="25"><br>

<input name="shout" type="submit" id="shout" value="Shout!">

  </div>

</form>

</td>

  </tr>

  </table>

  </div>

';

 

} // function getshouts

 

 

// our processing if control statement

if ( isset ( $_POST['shout'] ) )

{

 

$name = addslashes($_POST['name']);

$contact = addslashes($_POST['contact']);

$message =  $_POST['message'];

 

if ( ( isset($name) ) && ( isset($message) ) )

{

 

// getting smilie list

$smilies = mysql_query("SELECT * FROM smilies") or die(mysql_error());

while($get = mysql_fetch_array ($smilies))

{

 

$alt = $get['Alt'];

$smilie = $get['URL'];

 

$message = str_replace( $get['Symbol'] , '<img src="smilies/'.$smilie.'" border="0" width="15" height="15" alt="'.$alt.'">' , $message);

$themessage = addslashes($message);

 

// replacing all smilies

 

}

 

mysql_query("INSERT INTO shouts (Name, Contact, Shout) VALUES ( '$name' , '$contact' , '$message' )") or die(mysql_error());

$_SESSION['has_posted'] = 'yes';

header("Location: shout.php");

 

// if required fields aren't empty, process into database

 

} else {

 

echo '<script>alert("Some fields were not filled out!");</script>';

header("Location: shout.php");

 

// if required fields were left empty, show an error dialog

 

}

 

}/* else {

 

echo '<script>alert("Please follow the form to this page.");</script>';

header("Location: shout.php");

 

// if they weren't even referred from the form, show error dialog and redirect

 

} // if isset post shout

 

/* STARTING THE MAIN SCRIPT NOW */

 

// starting the table

 

//displaying the shouts

getShouts();

 

 

mysql_close($l);

 

 

?>

 

I was told that I should put ob_start(); at the top of my page and ob_end_clear(); at the end of my page, but should that code go on the shout.php file or my index.php file (index.php is where I want my comment box to go)? I was using session_start(); but I got some error messsages about headers already being sent because I had originally used the php include function at the top of index.php to include shout.php. After reading up on it I found out that the error was caused by not having session_start(); being the first line of code. So my problem was that I wanted the comment box to be somewhere other than at the top of the page. Not sure how to move it.

 

Anyways I'm pretty confused right now and if someone could give me some advice it would be appreciated.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.