Alphabetical sorting help....

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Smackie
Forum Contributor
Posts: 302
Joined: Sat Jan 29, 2005 2:33 pm

Post by Smackie »

There was no error messages when i submitted it....

there are 2 fields and they are username and poem
User avatar
smpdawg
Forum Contributor
Posts: 292
Joined: Thu Jan 27, 2005 3:10 pm
Location: Houston, TX
Contact:

Post 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.
Smackie
Forum Contributor
Posts: 302
Joined: Sat Jan 29, 2005 2:33 pm

Post by Smackie »

i used the second one
User avatar
smpdawg
Forum Contributor
Posts: 292
Joined: Thu Jan 27, 2005 3:10 pm
Location: Houston, TX
Contact:

Post 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;
Smackie
Forum Contributor
Posts: 302
Joined: Sat Jan 29, 2005 2:33 pm

Post by Smackie »

well it still doing it the same way not adding it and stuff dont know whats the matter
User avatar
smpdawg
Forum Contributor
Posts: 292
Joined: Thu Jan 27, 2005 3:10 pm
Location: Houston, TX
Contact:

Post by smpdawg »

Did you do what I asked in my last post? I want to see the query that was passed to the database...
Smackie
Forum Contributor
Posts: 302
Joined: Sat Jan 29, 2005 2:33 pm

Post 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;
?>
User avatar
smpdawg
Forum Contributor
Posts: 292
Joined: Thu Jan 27, 2005 3:10 pm
Location: Houston, TX
Contact:

Post 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());
Smackie
Forum Contributor
Posts: 302
Joined: Sat Jan 29, 2005 2:33 pm

Post by Smackie »

alright did that and it returns to the same page and on the address box it says
User avatar
smpdawg
Forum Contributor
Posts: 292
Joined: Thu Jan 27, 2005 3:10 pm
Location: Houston, TX
Contact:

Post by smpdawg »

How about the page that is generated? Do you see a message on there that shows the SQL statement?
Smackie
Forum Contributor
Posts: 302
Joined: Sat Jan 29, 2005 2:33 pm

Post by Smackie »

there is nothing :-S
User avatar
smpdawg
Forum Contributor
Posts: 292
Joined: Thu Jan 27, 2005 3:10 pm
Location: Houston, TX
Contact:

Post 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;
Last edited by smpdawg on Sat Mar 05, 2005 1:24 am, edited 1 time in total.
Smackie
Forum Contributor
Posts: 302
Joined: Sat Jan 29, 2005 2:33 pm

Post by Smackie »

i am still getting the same thing as last time :(
User avatar
smpdawg
Forum Contributor
Posts: 292
Joined: Thu Jan 27, 2005 3:10 pm
Location: Houston, TX
Contact:

Post 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.
Smackie
Forum Contributor
Posts: 302
Joined: Sat Jan 29, 2005 2:33 pm

Post by Smackie »

errr still the same :cry: either i do it all by hand or i find someone with a script that i need :?
Post Reply