Click here to Skip to main content
14,696,609 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
the problem is that data inserted doesnt show on my mysql database on localserver its important thank you.

another problem is i want to receive a message on my mysql database n when i swap a rfid card its tag number is shown on my localhost how can i do that please please help thank you once again.

What I have tried:

<?php

include_once ("connect.php");

$write =("INSERT INTO id,name_rf,user_rf,point_rf,time  VALUES ('','MAAZ','908802','HU-45','NOW()')");



$res = mysql_query("SELECT name_rf,user_rf from myrfidtable1");


$data = mysql_fetch_assoc($res);
echo "data inserted into database";

//('id','name_rf','user_rf','point_rf','time')
?>
Posted
Updated 6-Jul-20 0:06am
v2
Comments
Richard MacCutchan 7-Sep-17 2:27am
   
You never check the results of your database calls, so how can you display the success message?
markkuk 7-Sep-17 2:39am
   
Your INSERT statement syntax is incorrect, and you aren't actually executing the INSERT anywhere. No wonder that nothing gets added to the DB.

You create the SQL command string, but you don't do anything with it: PHP does not magically "know" that SQL code needs to sent to MySQL as a query ...
See here: PHP Insert Data Into MySQL[^] and check the responses as Richard has said!
   
Comments
Member 13083242 7-Sep-17 3:42am
   
can you show me how to post php code so that it shows on my MySQL server
I'm no php programmer, but:
1. you don't identify which table you are inserting to;
2. you don't check for errors; and
3. as Richard mentions, you don't check the success of the SQL INSERT. HOW do you know if it was successful or not?
   
Comments
Member 13083242 7-Sep-17 3:43am
   
this is my actual code

[code removed]
Graeme_Grant 7-Sep-17 3:45am
   
Did you read the very first line in my answer?
Member 13083242 7-Sep-17 3:49am
   
the one telling me to show the result??
Graeme_Grant 7-Sep-17 4:19am
   
"I'm no php programmer"
Member 13083242 7-Sep-17 3:51am
   
can you tell me how to code that!!
Graeme_Grant 7-Sep-17 4:20am
   
Here is how you code an SQL INSERT: SQL INSERT INTO Statement[^]
Member 13083242 7-Sep-17 5:10am
   
i did this exact method dude but it isnt working
Graeme_Grant 7-Sep-17 5:12am
   
Part of programming is debugging... Figuring out how to solve problems and bugs. We have all given you valid help. It is now up to you to implement it. We won't write your code for you.
sorry sorry my bad i was tying a experiment by doing this kinda code

the actual code is

<?php

include_once ("connect.php");

$write =("INSERT INTO myrfidtable1 ('id','name_rf','user_rf','point_rf','time') VALUES ('','MAAZ','908802','HU-45','NOW()')");



$res = mysql_query("SELECT name_rf,user_rf from myrfidtable1");


//$data = mysql_fetch_assoc($res);
echo "data inserted into database";

//('id','name_rf','user_rf','point_rf','time')
?>
   
Comments
Graeme_Grant 7-Sep-17 3:46am
   
DON't post updates to questions as solutions. Press the "Improve question" widget instead.
Member 13083242 7-Sep-17 3:54am
   
m new here so dont know where is the improve question widget is
Graeme_Grant 7-Sep-17 4:18am
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900