Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

inserting data to database?

Status
Not open for further replies.

Lynux

MIS
Aug 3, 2001
33
US
Whould anyone have any idea why this is not inserting anything to my database? I am positive the database connection is correct. here is my code.
==========================
<?php
$db = mysql_connect(&quot;localhost&quot;, &quot;root&quot;);
mysql_select_db(&quot;SLIP&quot;,$db);
if (list($key, $val) = each($result))
{
$query .= &quot;mysql_query(\&quot;INSERT INTO user_competencies (com_ID, score) VALUES ($key, $val)\&quot;,$db); &quot;;
}
?>
==============================
when I echo $query I get:
mysql_query(&quot;INSERT INTO user_competencies (com_ID, score) VALUES (81, 0)&quot;,Resource id #1);
mysql_query(&quot;INSERT INTO user_competencies (com_ID, score) VALUES (82, 1)&quot;,Resource id #1);
mysql_query(&quot;INSERT INTO user_competencies (com_ID, score) VALUES (83, 2)&quot;,Resource id #1);
mysql_query(&quot;INSERT INTO user_competencies (com_ID, score) VALUES (84, 3)&quot;,Resource id #1);
mysql_query(&quot;INSERT INTO user_competencies (com_ID, score) VALUES (85, 4)&quot;,Resource id #1);
=============================

Is there something I am not doing?
Any help would be greately appreciated !

Thanks in advance! :)

=================================
Imagination is more important than knowledge.
(A.E.)
 
hi
the problem is, that you are only assigning your code to the variable $query and not running it

this should work
<?php
$db = mysql_connect(&quot;localhost&quot;, &quot;root&quot;);
mysql_select_db(&quot;SLIP&quot;,$db);
if (list($key, $val) = each($result))
{
mysql_query(&quot;INSERT INTO user_competencies (com_ID, score) VALUES ($key, $val)&quot;,$db);
}
?>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top