Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function db_connect(){
- $connection = mysql_connect("localhost","root","");
- if(!$connection){
- echo mysql_error();
- exit;
- }
- if(!$row = mysql_select_db("test")){
- echo mysql_error();
- exit;
- }
- return $connection;
- }
- function add_post($tresc){
- db_connect();
- $query = sprintf("INSERT INTO posts VALUES (NULL, '".$tresc."')");
- $result = mysql_query($query);
- $row = mysql_fetch_assoc($result);
- return $row;
- }
- add_post('test');
- ?>
Add Comment
Please, Sign In to add comment