Saturday, May 4, 2024
 Popular · Latest · Hot · Upcoming
0
rated 0 times [  0] [ 0]  / answers: 1 / hits: 9638  / 1 Year ago, sun, may 7, 2023, 7:01:00

I am new to PHP in Ubuntu 13.10. But I am pretty much able to handle Ubuntu. However
my question is that I can't add any data to phpmyadmin through a PHP code, though my code is perfect. Because I have the same code in WAMP server, and it worked perfectly. But in Ubuntu I just can't add any data to the database. Below seen is the the code of php file;



<?php
$db_name="mydb";
$table_name="student";
$con=@mysql_connect("localhost",root);
$db=@mysql_select_db($db_name,$con);
$sql="insert into $table_name (name,course,mobile,address)"."values ('$_POST[n1]','$_POST[n2]',$_POST[n3],'$_POST[n4]')";
$r=@mysql_query($sql,$con);
echo "----Insert successfull----,<br><br><hr/>";
echo "<a href=index.html>Back</a>";
?>


Please tell me whether I am wrong or is there is any bug/problem in phpmyadmin.


More From » mysql

 Answers
3

in deed that was my fault,when i was trying to input data in the database,in mysql table i typed "First Name","Last Name" but after a certain time i thought the database may not be take spaces in variable name and i type "First_Name","Last_name" and it worked.and i was trying to execute the php file directly as i told before.now i have solved it the file have to execute by localhost.
anyways thank you guys,


[#26456] Sunday, May 7, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
brasiplacar

Total Points: 314
Total Questions: 124
Total Answers: 97

Location: Dominican Republic
Member since Wed, Mar 17, 2021
3 Years ago
;