Hey all, I am currently using modx to build a blog and I’m struggling with the dbapi for inserting rows. I have successfully written some ’form>ajax>php’ code that creates a row and inserts what I want.
Can someone show me how I would put the following code into the modx dbapi?
$user = ’root’;
$pass = ’root’;
$dbname = ’modx_blog’;
mysql_connect(localhost, $user, $pass) or die(mysql_error());
mysql_select_db($dbname) or die(mysql_error());
$result=MYSQL_QUERY("INSERT INTO modx_comments (blog_id,name,email,website,comment)".
"VALUES (’$blog_id’, ’$name’, ’$email’, ’$website’, ’$comment’)");
Any help is greatly appreciated!
Ash
-
MODX Staff
- 10,725 Posts
Why does everyone bypass MODx for Ajax requests? You have a db connection, you have the ability to use chunks and snippets and plugins, and you don’t have to open additional potentially insecure access points (php files) into your site to implement them.
So I write my query inside a snippet i dont need to open a new connection?