Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 05-24-2005, 06:09 AM   #1 (permalink)
Phantek
Registered User
 
Join Date: May 2005
Posts: 5
Phantek is on a distinguished road
Unhappy Row Adding Problems

Got another problem with my program.

I have a mySQL database, and setup a table with the values of id (auto_increment), username, password, and email.

I have used the following code to try and add a user through a PHP program:

PHP Code:
$sqlquery "INSERT INTO $table VALUES ('',$username,$password,$email)";
mysql_query($sqlquery); 
Everything looked okay, until I realized a problem. It turns out that this will ONLY work if the values being entered are numbers. I found this out by accident while I was testing it out. If I enter text information for ANY of the fields, it will not create the new row. But if I just enter any numbers, even decimals, it will write the new row no problem.

The username, password, and email fields all are created as CHAR. Anyone able to help me out? Thanks.
Phantek is offline   Reply With Quote
Old 05-24-2005, 07:06 AM   #2 (permalink)
teknomage1
Jack of all trades
 
teknomage1's Avatar
 
Join Date: Feb 2005
Location: Los Angeles
Posts: 596
teknomage1 is on a distinguished road
Send a message via AIM to teknomage1
you need to quote the fields just like you would in the sql client.
Code:
$sqlquery = "INSERT INTO $table VALUES ('','$username','$password','$email')";
mysql_query($sqlquery);
__________________
Stop intellectual property from infringing on me
teknomage1 is offline   Reply With Quote
Old 05-24-2005, 07:13 AM   #3 (permalink)
Phantek
Registered User
 
Join Date: May 2005
Posts: 5
Phantek is on a distinguished road
Oh, wow. That was so noobish of me! lol

Thanks a lot for your help. Works perfect now.
Phantek is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Row Decrement Phantek Everything SQL ( MySQL, MSSQL, DB2, Postgre, Oracle, etc...) 6 05-20-2005 10:59 AM
code problems Timber Standard C, C++ 11 03-21-2005 06:55 AM
Table problems prendo HTML, XML, Javascript, AJAX 12 04-06-2003 05:38 AM
no dial tone problems fabiopao Linux / BSD / OS X 4 02-23-2003 10:51 AM
I have problems... anon Lounge 4 01-12-2003 07:47 PM


All times are GMT -8. The time now is 07:34 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting