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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why is this not working?

Status
Not open for further replies.

frankalbers

Programmer
Jan 3, 2002
3
0
0
DE
Can somebody tell me why this does not put data in mySQL table?
<?php

$db = mysql_connect(&quot;db.cupbase.f2s.com:3306&quot;,&quot;username&quot;,&quot;password&quot;)
or die (&quot;Could not connect to database&quot;);

mysql_select_db (&quot;nameofdatabase&quot;,$db);

$link = mysql_db_query (&quot;INSERT INTO bird (sales_id, bird_id, status, purchase_id, vet_id, weight_id, skingrade) values ('$textfield2', '$textfield3', '$textfield4', '$textfield5', '$textfield6', '$textfield7', '$textfield8')&quot;,$db);

mysql_close ($db);

?>

Thanx.
(Sory if this will appear twice.)
 
I think you didn;t select a database. Select it in first argment of mysql_connect Ion Filipski
1c.bmp


filipski@excite.com
 
I think your concepts are a little confused:

Try:
[tt]
if( $Cx = mysql_connect( &quot;server:port&quot;, &quot;user&quot;, &quot;password&quot; ) )
{
// Cx is a connection pointer
mysql_select_db( &quot;database_name&quot; );
if( $Res = mysql_query( &quot;INSERT INTO TableName (col1, col2) VALUES ( 'TextValue1', 'TextValue2' )&quot;, $Cx ) )
{
// $Res is a result code and a resource pointer
echo( &quot;Values inserted&quot; );
}
else
{
echo( &quot;Values NOT inserted&quot; );
}
mysql_close( $Cx ); // Close the connection
}
[/tt]
I hope it works...
Unix was made by and for smart people.
 
I use
$dc = mysql_connect(&quot;ServerName&quot;,&quot;userid&quot;,&quot;password&quot;)
or die (&quot;Could not connect to server&quot;);
//without any :ports
mysql_select_db(&quot;database name&quot;)
or die (&quot;Could not connect&quot;);
Ion Filipski
1c.bmp


filipski@excite.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top