Page 3 of 5

Posted: Fri Mar 04, 2005 9:08 pm
by Smackie
There was no error messages when i submitted it....

there are 2 fields and they are username and poem

Posted: Fri Mar 04, 2005 9:10 pm
by smpdawg
Which fixed line did you use? The first or the second one that I posted? It should have been the second since it only had two paramenters in the INSERT.

Posted: Fri Mar 04, 2005 9:11 pm
by Smackie
i used the second one

Posted: Fri Mar 04, 2005 9:19 pm
by smpdawg
Do this after you make the INSERT statement but before the query is executed and show me what you get.

Code: Select all

echo $add_all;

Posted: Sat Mar 05, 2005 12:24 am
by Smackie
well it still doing it the same way not adding it and stuff dont know whats the matter

Posted: Sat Mar 05, 2005 12:31 am
by smpdawg
Did you do what I asked in my last post? I want to see the query that was passed to the database...

Posted: Sat Mar 05, 2005 12:52 am
by Smackie
yes i did that but still did the same thing until i messed up on how you wanted me to do it here is what the scripts looks like now after i inserted that code you gave me..

Code: Select all

<?
if(isset($_GET&#1111;'commented']))
&#123; 

// Tell the user it has been submitted (optional) 
echo('Your comment has been posted.');

// Set Mysql Variables
$host = 'localhost'; 
$user = 'smackie';
$pass = 'deketazz';
$db = 'haunted_poetry';
$table = 'dbpoems'; 

// Set global variables to easier names
$username = $_GET&#1111;'uname']; 
$poem = $_GET&#1111;'poem']; 

// Connect to Mysql, select the correct database, and run teh query which adds the data gathered from the form into the database
mysql_connect($host,$user,$pass) or die(mysql_error());
mysql_select_db($db) or die(mysql_error());
echo $add_all = "INSERT INTO $table values("$username","$poem")";
mysql_query($add_all) or die(mysql_error());
&#125;
else
&#123;
echo $add_all;
// If the form has not been submitted, display it!
?>
<form method='get' action='<? echo $PHP_SELF; ?>'>
Username: <input type='text' name='username'><br><br>
Poem: <input type='text' name='poem'><br><br>
<input type='submit' value='Post your poems'>
</form> 
<?
&#125;
?>

Posted: Sat Mar 05, 2005 12:56 am
by smpdawg
Actually I meant like this

Code: Select all

$add_all = "INSERT INTO $table values("$username","$poem")";
echo $add_all;
mysql_query($add_all) or die(mysql_error());

Posted: Sat Mar 05, 2005 1:00 am
by Smackie
alright did that and it returns to the same page and on the address box it says

Posted: Sat Mar 05, 2005 1:10 am
by smpdawg
How about the page that is generated? Do you see a message on there that shows the SQL statement?

Posted: Sat Mar 05, 2005 1:11 am
by Smackie
there is nothing :-S

Posted: Sat Mar 05, 2005 1:17 am
by smpdawg
If I had looked up toward the top of your code I would have probably seen the problem earlier....

Change this

Code: Select all

if(isset($_GET&#1111;'commented']))
&#123;
To

Code: Select all

if ((isset($_GET&#1111;'username']) == true) && (isset($_GET&#1111;'poem']) == true))
&#123;

Posted: Sat Mar 05, 2005 1:20 am
by Smackie
i am still getting the same thing as last time :(

Posted: Sat Mar 05, 2005 1:25 am
by smpdawg
Another problem that I noticed is that you send in a variable called username but you refer to it as uname. You need to change each uname to username including the part that I just had you change because it also used the wrong name.

Posted: Sat Mar 05, 2005 1:28 am
by Smackie
errr still the same :cry: either i do it all by hand or i find someone with a script that i need :?