Nothing being added to table...

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

Post Reply
Trip1
Forum Newbie
Posts: 23
Joined: Sat Jan 25, 2003 7:36 pm

Nothing being added to table...

Post by Trip1 »

http://tsn.dk/p/?id=1940

Line 55-57.. For some reason everything seems to be working but nothing is added into my table. I tried using a different method:

їphp]
$sql = "INSERT INTO users (username, password, signature, profile, real name, ipaddress) VALUES ('$username', '$password', '$signature', '$profile', '$realname', '$ip')";

ї/php]
and then using
їphp]
mysql_query($sql);
ї/php]

Got the same result, looked like it worked, no errors, but nothing was added into the table. So i echoed out $sql. Looked perfect, i ran it through the SQL thing in phpmyadmin and the record was created successfully with no errors from MYSQL.. I have no idea what's wrong.. any help appreciated, thanks in advance.


?>
toshesh
Forum Commoner
Posts: 33
Joined: Thu Jun 19, 2003 9:32 pm

Post by toshesh »

Not sure but dont you need to receive it when you call mysql_query?
you havent specified a database either.
like
$result = mysql_query($dbconn, $sql);
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

What happens if you try it with:

Code: Select all

<?php

$sql = "INSERT INTO users SET col1='$var1', col2='$var2', etc..";

?>
Last edited by McGruff on Thu Aug 11, 2005 12:09 am, edited 1 time in total.
toshesh
Forum Commoner
Posts: 33
Joined: Thu Jun 19, 2003 9:32 pm

Post by toshesh »

as long as the query works when running on the sql server then php shouldn't have any problems with the query.

But isn't that suppose to use ALTER TABLE command?
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Do you get anything reported if you do:

Code: Select all

$sql = "INSERT INTO users (username, password, signature, profile, real name, ipaddress) VALUES ('$username', '$password', '$signature', '$profile', '$realname', '$ip')"; 

mysql_query($sql) or die(mysql_error().'<p>'.$sql.'</p>');
Mac
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

Twig probably has a better suggestion (adding mysql_error) to help you track down the problem but here's a snippet from the mysql manual (mysql.com):

"The INSERT ... VALUES form with multiple value lists is supported in MySQL Version 3.22.5 or later. The col_name=expression syntax is supported in MySQL Version 3.22.10 or later. "
Post Reply