LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-19-2004, 05:23 AM   #1
jimieee
Member
 
Registered: Aug 2003
Location: London, UK
Distribution: Debian and Fedora for play and RHEL + Solaris for work
Posts: 172

Rep: Reputation: 15
PHP - mysql_query won't work - no feedback!


Hi,

I'm trying to get a little bit of code working to basically insert data into my database using a loop. For some reason it isn't working, but it doesn't give me an error message, all I can get it to tell me is whether it updated the row or not:

Code:
    foreach( $infoArray['infostream']['class_description'] as $k ) 
    {

        mysql_query( [INSERT INTO blah ( id, name, class_id) VALUES ('', '".$k['name']."', '".$new_class_id."')] );
        echo mysql_affected_rows()." atttributes inserted.\n";
     }
Which gives me an output of:

-1 atttributes inserted.
-1 atttributes inserted.
-1 atttributes inserted.
-1 atttributes inserted.

Is there anyway to get more information about what's going on? I replaced mysql_query with echo and my queries appear to be correct, but there's absolutely no error messages!

Can anyone lend some friendly advice?

Thanks,

James
 
Old 05-19-2004, 05:29 AM   #2
jimieee
Member
 
Registered: Aug 2003
Location: London, UK
Distribution: Debian and Fedora for play and RHEL + Solaris for work
Posts: 172

Original Poster
Rep: Reputation: 15
Ah! Got it! Needed to add:

echo(mysql_error());
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't Get php to work? ahsiii Linux - Software 3 11-29-2005 06:02 AM
php5 apache2 mysql4 don't work, php does not seem to read php.ini atom Linux - Software 5 03-24-2005 11:05 AM
getting PHP to work...please help! rudini Linux - Software 12 03-24-2005 05:44 AM
PHP mysql_query not processing nro Programming 1 09-19-2004 09:43 PM
mysql_query() Error ghight Programming 2 07-29-2004 02:20 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:25 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration