forumnz Posted January 16, 2007 Share Posted January 16, 2007 Heres the code...And yes i didnt write this script but i cant figure it out..[code]<?php// database functions :: MySQLfunction db_connect($host,$user,$pass) //create connection{ $r = mysql_connect($host,$user,$pass); if(preg_match('/^5\./',mysql_get_server_info($r)))db_query('SET SESSION sql_mode=0'); return $r;}function db_select_db($name) //select database{ return mysql_select_db($name);}function db_query($s) //database query{ return mysql_query($s);}function db_fetch_row($q) //row fetching{ return mysql_fetch_row($q);}function db_insert_id(){ return mysql_insert_id();}function db_error() //database error message{ return mysql_error();}?>[/code] Quote Link to comment Share on other sites More sharing options...
Psycho Posted January 16, 2007 Share Posted January 16, 2007 Those are just functions for working with the database. You need to have code that calls those functrions. Quote Link to comment Share on other sites More sharing options...
forumnz Posted January 16, 2007 Author Share Posted January 16, 2007 Ok, if I can write that code how would I link it to the page? Would I put it in the page or would I include it? Am i making sense? Quote Link to comment Share on other sites More sharing options...
diode Posted January 16, 2007 Share Posted January 16, 2007 This is what I use:$con = mysql_connect('localaddress', 'account@server', 'password') or die('Could not connect: ' . mysql_error());mysql_select_db('test', $con) or die('Could not select database');Try making it like that, but of course replace what is in single quotes to fit your computer.Hope it helps :),diode Quote Link to comment Share on other sites More sharing options...
Tandem Posted January 16, 2007 Share Posted January 16, 2007 That code is defining functions, not calling them. And since those functions are already reserved by php i don't think that can be done anyway.Do this:[code]$conn = mysql_connect("localhost", "user", "password") or die(mysql_error());mysql_select_db('db_name', $conn) or die(mysql_error());[/code]but of course replace the information with your own. Quote Link to comment Share on other sites More sharing options...
dgiberson Posted January 16, 2007 Share Posted January 16, 2007 you need to set $host, $user and $pass in order to connect.This manner will allow you to use an almost persistent connection as opposed to writing out the connection statement on every page. Quote Link to comment Share on other sites More sharing options...
forumnz Posted January 16, 2007 Author Share Posted January 16, 2007 Ok thanks but how do I make the password link to $pass and the db name link to $name? etc. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.