Jump to content

Table Helps!!!


june_c21

Recommended Posts

$month = $_POST ['month'];

$gf = $_POST ['gf'];

$equipment = $_Get ['equipment'];

 

 

 

$query= "INSERT INTO report( month,gf,equipment) VALUES ('$month','1','$equipment') ";

$result = mysql_query($query,$dblink);

 

 

my problem is the month & gf are insert by users to report table but equipment is taken from different table and want to insert into report table. how to write the code?

 

thanks

Link to comment
Share on other sites

SQL query: 

 

SELECT equipment

FROM equipment

WHERE equipment = $_GET[ 'equipment']

INSERT INTO report(

MONTH , gf, equipment, viscosity, water, tan, oil, wear, remarks )

VALUES (

 

'$month', '1', '$equipment', '$viscosity', '$water', '$tan', '$oil', '$wear', '$remarks'

)

LIMIT 0 , 30

 

MySQL said: 

 

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '[ 'equipment' ]  INSERT INTO report ( month , gf , equipment , viscosity , water' at line 1

 

 

Link to comment
Share on other sites

We know that month and gf come from user input.

 

SELECT equipment

FROM equipment

WHERE equipment = $_GET[ 'equipment']

 

Why GET when other data is POST?

 

If $_GET['equipment'] contains "widget" then all that does is return "widget" - waste of time.

 

Where do these come from - '$viscosity', '$water', '$tan', '$oil', '$wear', '$remarks' ?

 

What does the equipment table look like?

Is the value for equipment same in every record in report table or do you need to select various valeues of equipment from the equipment table - if so what are the selection criteria?

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.