SitePoint Sponsor |
|
User Tag List
Results 1 to 3 of 3
-
Feb 10, 2005, 16:59 #1
- Join Date
- Feb 2005
- Posts
- 3
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
php/mysql - unwanted blank row...
hello there,
i've been trying to get this to work properly for hours now, but even after reducing the code to the bare minimum, i can't find what's wrong... maybe someone here can help me...
i'm working with php and mysql. i have a page that is supposed to insert a row of text into the database from a form, which it happily does. the problem is that everytime TWO rows are inserted of which the first one is blank. here is the code:
<?
$username="username";
$password="password";
$database="database_name";
$ins_content=$_POST['ins_content'];
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query = "INSERT INTO content (content_text) VALUES ('$ins_content')";
mysql_query($query);
mysql_close();
echo "'$ins_content' written to database";
?>
any ideas? please let me know.
-
Feb 10, 2005, 17:24 #2
- Join Date
- Jul 2002
- Location
- Toronto, Canada
- Posts
- 39,347
- Mentioned
- 63 Post(s)
- Tagged
- 3 Thread(s)
sounds like a php problem, not a mysql problem
well, except for the fact that if you really are inserting "blank rows" then you have failed to declare the table properly
-
Feb 11, 2005, 04:47 #3
- Join Date
- Feb 2005
- Posts
- 3
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
you're right...
thanks for your reply. sometimes one is just looking in all the wrong places... like you said it was the php not mysql. the blank row got inserted when the page loaded. all it needed was a little if(){} statement... doh!
cheers again - kabe243
Bookmarks