...

View Full Version : wots wrong here?



matthew_haworth
07-12-2005, 04:52 PM
itll run just not send it to the databse




<html>

<head>
<title>New Page 1</title>
<?
// connect to dudey database!
mysql_connect ( 'localhost', '***_*******', '*******' );
mysql_select_db ( 'paper1_project' );
// find thingy
if ($_POST['name']) {
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];

mysql_query ( "INSERT INTO shoutbox ( '', '$name', '$email', '$message')" );
}
else
{
mysql_close();
}
?>
</head>

<body bgcolor="#000000">

<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="165" id="AutoNumber1" height="272">
<tr>
<td height="219" width="165" valign="top">
<?
mysql_connect ( 'localhost', '*_**', '*******' );
mysql_select_db ( 'paper1_project' );
$shouts_result = mysql_query ( "SELECT 'name', 'email', message FROM 'shoutbox' ORDER BY 'id' DESC LIMIT 5" );

while ( $row = @mysql_fetch_array ( $shouts_result ) ) {

extract ( $row );

echo "<font color='#FFFFFF'><a href='mailto:$email'>$name</a><br/>$message</font><br/>";

}
mysql_close();
?>
</td>
</tr>
<tr>
<td height="53" width="165">
<fieldset>

<form action="<?$PHP_SELF?>" method="post">
<p align="center" style="margin-top: 0; margin-bottom: 0"><font color="#FFFFFF"><b><font face="Verdana">Name: <input type="text" name="name" size="20"></font></b></font></p>

<p align="center" style="margin-top: 0; margin-bottom: 0"><b><font color="#FFFFFF" face="Verdana">Email:</font></b><font face="Verdana"><b><input type="text" name="email" size="20"></b></font></p>

<p align="center" style="margin-top: 0; margin-bottom: 0"><font color="#FFFFFF"><b><font face="Verdana">
Message:</font></b></font><font face="Verdana"><b> <input type="text" name="message" size="20"></b></font><b><font face="Verdana"> </font>
</b></p>

<p align="center" style="margin-top: 0; margin-bottom: 0"><font face="Verdana"><b>
<input type="submit" value="Post"> </b></font></p>

</form>
</fieldset>
</td>
</tr>
</table>

</body>

</html>


goto the site here (http://project.feelmybass.com/shoutbox.php)

Brandoe85
07-12-2005, 04:56 PM
mysql_query ( "INSERT INTO shoutbox values ( '', '$name', '$email', '$message')" );

You can use: or die(mysql_error()) also to help you debug...

matthew_haworth
07-12-2005, 05:00 PM
where wud i put the

or die(mysql_error())

Brandoe85
07-12-2005, 05:02 PM
After your mysql_query:


mysql_query ( "INSERT INTO shoutbox values ( '', '$name', '$email', '$message')" ) or die(mysql_error());

matthew_haworth
07-12-2005, 05:08 PM
still a no go, current code is



<html>

<head>
<title>New Page 1</title>
<?
// connect to dudey database!
mysql_connect ( 'localhost', '******_*******', '******' );
mysql_select_db ( '******_project' );
// find thingy
if ($_POST['name']) {
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];

mysql_query ( "INSERT INTO shoutbox values ( '', '$name', '$email', '$message')" ) or die(mysql_error());
}
else
{
mysql_close();
}
?>
</head>

<body bgcolor="#000000">

<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="165" id="AutoNumber1" height="272">
<tr>
<td height="219" width="165" valign="top">
<?
mysql_connect ( 'localhost', '******_*******', '******' );
mysql_select_db ( '******_project' );
$shouts_result = mysql_query ( "SELECT 'name', 'email', message FROM 'shoutbox' ORDER BY 'id' DESC LIMIT 5" );

while ( $row = @mysql_fetch_array ( $shouts_result ) ) {

extract ( $row );

echo "<font color='#FFFFFF'><a href='mailto:$email'>$name</a><br/>$message</font><br/>";

}
mysql_close();
?>
</td>
</tr>
<tr>
<td height="53" width="165">
<fieldset>

<form action="<?$PHP_SELF?>" method="post">
<p align="center" style="margin-top: 0; margin-bottom: 0"><font color="#FFFFFF"><b><font face="Verdana">Name: <input type="text" name="name" size="20"></font></b></font></p>

<p align="center" style="margin-top: 0; margin-bottom: 0"><b><font color="#FFFFFF" face="Verdana">Email:</font></b><font face="Verdana"><b><input type="text" name="email" size="20"></b></font></p>

<p align="center" style="margin-top: 0; margin-bottom: 0"><font color="#FFFFFF"><b><font face="Verdana">
Message:</font></b></font><font face="Verdana"><b> <input type="text" name="message" size="20"></b></font><b><font face="Verdana"> </font>
</b></p>

<p align="center" style="margin-top: 0; margin-bottom: 0"><font face="Verdana"><b>
<input type="submit" value="Post"> </b></font></p>

</form>
</fieldset>
</td>
</tr>
</table>

</body>

</html>



its a twat when no one knows

it may be this :



mysql_connect ( 'localhost', 'database username?', 'database password?' );
mysql_select_db ( 'database?' );

Brandoe85
07-12-2005, 05:34 PM
Again, use mysql error to check if you actually make a connection to the database, use the example off of php.net:
http://us2.php.net/mysql_connect

matthew_haworth
07-12-2005, 05:59 PM
tis is going to the database now, just not coming out

FROM 'shoutbox' ORDER BY 'id' DESC LIMIT 5

it says its near there



You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ''shoutbox' ORDER BY 'id' DESC LIMIT 5' at line 1

Brandoe85
07-12-2005, 06:29 PM
You're using single quotes around your field names?? Did you mean to use backticks? '`'? Anyrate, take out the single quotes and give it a go:


$shouts_result = mysql_query ( "SELECT name, email, message FROM shoutbox ORDER BY id DESC LIMIT 5" );

Spookster
07-13-2005, 12:52 AM
You need to read our posting guidelines before creating any more threads.

http://www.codingforums.com/postguide.htm

Pay special attention to number 2



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum