Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 06-15-2005, 08:39 AM Empty page?
feraira's Avatar
BeTheBand!

Posts: 350
Trades: 0
OK, I am coding a shoutbox, if there is nothing in the databse it says so, and if there is, it shows it with a form underneath to reply!
BUT it shows nothing on the page when I try see it
PHP Code:
<?

$date 
"blah";

// Make the form
$form "
<form action=\"
$_SERVER[PHP_SELF]\" method=\"post\">
Your name:<br>
<input name=\"name\" id=\"name\">
<br><br>
<input name=\"date\" id=\"date\" value=\"
$date\" type=\"hidden\">
Your message:<br>
<textarea name=\"message\" cols=\"27\" rows=\"8\"></textarea>
<br><br>
<input type=\"submit\" name=\"submit\" value=\"Shout it out!\">
"
;

// Connect to the DB
include("connect.php");

// Select the database
$result=mysql_query("SELECT * FROM shoutbox");
$num mysql_num_rows($result);
while(
$row=mysql_fetch_array($result)) {

// Pull out the needed information
$id $row['id'];
$name $row['name'];
$email $row['email'];
$message $row['message'];
$date $row['date'];

// Get rid of the dirty slashes!
$message stripslashes($message);

// If the form is submitted
if (!isset($submit)) {

// Retrieve the information
$name $_POST['name'];
$email $_POST['email'];
$message $_POST['message'];
$date $_POST['date'];

// Check the information
if(!$name) {
exit(
"You have not entered a valid name, please enter a name!");
}
if(!
$email) {
exit(
"You have not entered an E-Mail, please enter an email!");
}

// Add the slashes so quotes work
$message addslashes($message);

// Insert the information
$query "INSERT INTO shoutbox VALUES ('','$name','$message','$email','$date')"
mysql_query($query) or die("Could not insert information because: ".mysql_error());

} else {

// Show the shouts!
if($num == "0") {
echo(
"Sorry, there has been no shouts yet. Check back some other time");
} else {
echo(
"<a href=\"mailto:".$email."\">$name - $date</a>");
echo(
"<br>");
echo(
"$message");
echo(
"<br><br>");
echo(
"$form");
}
}

mysql_close();
}
?>
Anyone help?

Last edited by feraira; 06-15-2005 at 09:02 AM..
feraira is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-15-2005, 01:18 PM
stoot98's Avatar
Ultra Talker

Posts: 427
Name: Stuart
Location: Glasgow, Scotland
Trades: 0
Im not sure if this will affect the whole page but the INSERT bit of code won't work because you need to tell it which fields to put those values in - so it should be.

PHP Code:
$query "INSERT INTO table( field1, field2, field3)
                    values( '
$field1, '$field2, '$field3')"
Other than that I cant spot the error just now. Is it turning up blank when there IS data in the database?
stoot98 is offline
Reply With Quote
View Public Profile
 
Old 06-15-2005, 05:31 PM
feraira's Avatar
BeTheBand!

Posts: 350
Trades: 0
I managed to get it work, so to speak! It works where theres no information in the database saying "Sorry..." i fixed this by checking the if(!isset ... function I used.. I needed to take away the ! . That solved that problem, now all the lies is that nothing gets inserted to the database when submit is done...
feraira is offline
Reply With Quote
View Public Profile
 
Old 06-16-2005, 05:55 AM
stoot98's Avatar
Ultra Talker

Posts: 427
Name: Stuart
Location: Glasgow, Scotland
Trades: 0
Check my last reply - that should sort it.
stoot98 is offline
Reply With Quote
View Public Profile
 
Old 06-16-2005, 07:26 AM
rungss's Avatar
Skilled Talker

Posts: 67
Name: Bijay Rungta
Location: Mumbai, India
Trades: 0
I think it should be if (isset($submit)) instead of !$submit
rungss is offline
Reply With Quote
View Public Profile Visit rungss's homepage!
 
Reply     « Reply to Empty page?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.69981 seconds with 12 queries