PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old February 1st, 2005, 08:00 AM
rvause rvause is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 1 rvause User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 m 37 sec
Reputation Power: 0
INSERT not working in PHP4

Hi, I have been trying to insert records into the database using the following bit of code.

PHP Code:
 $sql "INSERT INTO news (`post_title`,`post_body`,`post_date`,`post_aid`) VALUES ('" $_POST['title'] . "','" $_POST['sub_news'] . "','" date("l dS of F Y",time()) . "','" $_SESSION['logged_in'] . "')";
   echo 
$sql "<br />";
   
$result mysql_result($sql) or die(mysql_error()); 


as you can see i 'echo' the sql query to check it is ok and has all the information from the variables in.

This works fine and the query ends up looking something like this.
PHP Code:
 INSERT INTO news (`post_title`,`post_body`,`post_date`,`post_aid`) VALUES ('test','test','Tuesday 01st of February 2005','1'


I ran the query manually using the mysql command line and it inserted the record fine.

Why could this not be working in PHP. I have been using SELECT queries in PHP and they are working fine.

the mysql_error() in the code above returns nothing.

Reply With Quote
  #2  
Old February 1st, 2005, 08:16 AM
mattp23 mattp23 is offline
Moderated
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: UK
Posts: 82 mattp23 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 43 m 44 sec
Reputation Power: 6
try using mysql_query insetead of mysql_result, see if that helps.

find them both on the php site mysql result and mysql_query
__________________
http://www.phptutorials.cjb.net. go on, give it a click!

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > INSERT not working in PHP4


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 3 hosted by Hostway
Stay green...Green IT