Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old January 29th, 2003, 07:21 PM
Dr. Styles Dr. Styles is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 37 Dr. Styles User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Help--why cant i write

using PHP/mysql in windows

can read from database but can't write (i.e insert).

i am using root as user
here is my code..


$db = mysql_connect("localhost", $dbuser, $dbpass);

$dbb =mysql_select_db("database03",$db);
$query = "INSERT INTO employees VALUES($num,$first,$last)";
$result = mysql_query("SELECT * FROM employees",$db);

printf("First Name: %s
n", @ mysql_result($result,2,"first"));

printf("Last Name: %s
n", @ mysql_result($result,2,"last"));

Reply With Quote
  #2  
Old January 30th, 2003, 09:03 AM
xs0 xs0 is offline
Codewalkers Novice (500 - 999 posts)
 
Join Date: Apr 2007
Location: Ljubljana, Slovenia
Posts: 760 xs0 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: Help--why cant i write

Try using mysql_error after your INSERT statement, to see what the problem is...
php Code:
Original - php Code
  1.  
  2. //...
  3. mysql_query("INSERT into ....");

Reply With Quote
  #3  
Old January 30th, 2003, 05:13 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: Help--why cant i write

Check your query for inserting. Does your table only have 3 columns? I think you're missing declaring which columns your data matches with and you might want to single quote the data. For example:
FROM
$query = "INSERT INTO employees () VALUES($num,$first,$last)";

TO
$query = "INSERT INTO employees (empnum, firstname, lastname)VALUES('$num', '$first', '$last')";

Here I assume your column names are empnum, firstname and lastname.

HTH

-bcyde

Reply With Quote
  #4  
Old January 30th, 2003, 05:15 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: Help--why cant i write

Just looked at the code again,
it also doesn't look like you're actually doing a mysql_query($query) after initializing your query.

-bcyde

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > Help--why cant i write


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway