[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 525
  • Last Modified:

PHP mysql insert sentence

I have a referans table named RT_REFERANS
I have columns in that table named rt_name, rt_id, rt_value

I try to use a couple of row insert sentence but it gives an error code like
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in ... in the line of  mysql_query($sql,$con);

$sql="INSERT INTO RT_REFERANS(rt_name,rt_id,rt_value) VALUES ('rt_sehir',1,'Adana');
INSERT INTO RT_REFERANS(rt_name,rt_id,rt_value) VALUES ('rt_sehir',2,'Adiyaman');
";

mysql_query($sql,$con);
0
Braveheartli
Asked:
Braveheartli
  • 2
  • 2
  • 2
  • +1
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
that error means that $con is not a connection object identifier (as returned by mysql_connect())

0
 
collins23Commented:
Your settings for connecting to the database are not correct.
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
note that with MySQL, you can insert several rows "at once":
$sql="INSERT INTO RT_REFERANS(rt_name,rt_id,rt_value) VALUES ('rt_sehir',1,'Adana'), ('rt_sehir',2,'Adiyaman')
";

Open in new window

0
NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

 
shobinsunCommented:
HI,

Look at this:

http://www.petefreitag.com/item/379.cfm

The error is because of the error in your sql.
0
 
shobinsunCommented:
0
 
BraveheartliMarketingAuthor Commented:
thank you all
0
 
BraveheartliMarketingAuthor Commented:
Dear angelll,
you are also right,
I should have given you some of the points..
next time..
0

Featured Post

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

  • 2
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now