简体   繁体   English

从php插入数据到MySql

[英]Inserting Data into MySql from php

I'm new to php and have been going through tutorials, and have hit a stump, where I can't seem to find what I'm doing wrong in my code, I welcome any and all assist, the code below is meant to insert data previously collected into a table that has those fields outline, in phpmyadmin: 我是php的新手,并且经历过教程,并且遇到了一个问题,在我的代码中我似乎无法找到我做错了什么,我欢迎任何和所有协助,下面的代码是为了在phpmyadmin中将先前收集的数据插入到具有这些字段轮廓的表中:

$SQL = "INSERT INTO users ( 'username', 'password', 'email_address', 'date_of_birth', 'first_name', 'last_name', 'phone', 'address', 'city', 'userlevel') values ('" + $username + "', '" + $password + "', '" + $email_address + "', '" + $date_of_birth + "', '" + $first_name + "',  '" + $last_name + "', '" + $phone + "', '" + $address + "', '" + $city + "',  '" + $userlevel + "')";

And then to run that code: 然后运行该代码:

 mysql_query($SQL); mysql_close($db_handle); print "Records added to the database";

I'm not 100% sure whether its the layout or not, for inserting variable data into MySql, also their is no errors about connecting to the database, furthermore the print at the end of the function runs, therefore it is not getting an error and stopping before running the code above. 我不是100%肯定它的布局与否,用于将可变数据插入到MySql中,它们也没有关于连接数据库的错误,而且函数末尾的打印运行,因此它没有出错并在运行上面的代码之前停止。

Once again thank you and all assistance is welcome. 再次感谢您,欢迎所有帮助。

php uses . php使用. to connect strings not + 连接字符串而不是+

and all the comments from Dachi and Mister Melancholy apply! 并且Dachi和Mister Melancholy的所有评论都适用!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM