jmr3460 Posted April 10, 2009 Share Posted April 10, 2009 I am trying to get an address book working and I am getting a fatal error that looks like this: Fatal error: Call to undefined function doDB() in C:\wamp\www\contact\delentry.php on line 4 This is a few of the lines in the file that is giving my this error. I am using WAMP 2.0 It had php/mysql 5.?: <?php include("include.php"); doDB(); if (!$_POST) { //haven't seen the selection form, so show it $display_block = "<h1>Select an Entry</h1>"; //get parts of records $get_list_sql = "SELECT id, CONCAT_WS(', ', l_name, f_name) AS display_name FROM master_name ORDER BY l_name, f_name"; $get_list_res = mysqli_query($mysqli, $get_list_sql) or die(mysqli_error($mysqli)); if (mysqli_num_rows($get_list_res) < 1) { //no records $display_block .= "<p><em>Sorry, no records to select!</em></p>"; } else { //has records, so get results and print in a form $display_block .= " <form method=\"post\" action=\"".$_SERVER["PHP_SELF"]."\"> <p><strong>Select a Record to Delete:</strong><br/> <select name=\"sel_id\"> <option value=\"\">-- Select One --</option>"; while ($recs = mysqli_fetch_array($get_list_res)) { $id = $recs['id']; $display_name = stripslashes($recs['display_name']); $display_block .= "<option value=\"".$id."\">".$display_name."</option>"; } $display_block .= " </select> <p><input type=\"submit\" name=\"submit\" value=\"Delete Selected Entry\"></p> </form>"; What makes this function undefined? Link to comment https://forums.phpfreaks.com/topic/153567-solved-undefined-function-dodb/ Share on other sites More sharing options...
PFMaBiSmAd Posted April 11, 2009 Share Posted April 11, 2009 Your include statement is probably failing. Are you developing and debugging your code on a system with error_reporting set to E_ALL so that you get immediate feedback for problems php finds? Link to comment https://forums.phpfreaks.com/topic/153567-solved-undefined-function-dodb/#findComment-806945 Share on other sites More sharing options...
jmr3460 Posted April 11, 2009 Author Share Posted April 11, 2009 This is possible my include file is what gets me into my database. I will look at this. I have not tested that yet. I am reading sams all in one php, mysql and apache. I have installed wamp 2.0 I have found that some of the code does not work and it takes a little experimenting and error reading. this is my include file: <? //set up a couple of functions for use by scripts in ch20 function doDB() { global $mysqli; //connect to server and select database; you may need it $mysqli = mysqli_connect("localhost", "root", "password", "contacts"); //if connection fails, stop script execution if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } } ?> Some of the database connects I have done did not include the localhost part. I will experiment. Link to comment https://forums.phpfreaks.com/topic/153567-solved-undefined-function-dodb/#findComment-806984 Share on other sites More sharing options...
jmr3460 Posted April 11, 2009 Author Share Posted April 11, 2009 I am very lost. I have tried creating variables. I have tried (I don't know how many different things.) I am lost. Someone told me that maybe my include file is failing. This is where I have been looking. I have made a folder maned includes my include folder on my environment machine. I have moved the file to that folder. I have tried opening the file directly with a print statement notifying me if I got in. White screen only. Not even an error to work with. The only time I get an error is when I try opening the include file from another file. I think that I am going to load files on my paid for server where I have had more success in my coding efforts. I will return. Link to comment https://forums.phpfreaks.com/topic/153567-solved-undefined-function-dodb/#findComment-807349 Share on other sites More sharing options...
alphanumetrix Posted April 11, 2009 Share Posted April 11, 2009 Since your include.php is so small, why don't you just copy the function to the top of the script to see if it works that way; then play around with getting the include to work. Link to comment https://forums.phpfreaks.com/topic/153567-solved-undefined-function-dodb/#findComment-807359 Share on other sites More sharing options...
jmr3460 Posted April 12, 2009 Author Share Posted April 12, 2009 I got my include working. I am working on warnings and notices now. I got about 75% of the scripts working. It is just a little address book. It seems that there is some of differences in php4 and php5. The book I am studying has some issues with is but I think that will make me a better coder finding these differences. Also I am still learning and don't understand everything I am doing right now but I have faith that that knowledge will come as long as I keep plugging along. I am going to mark this topic as solved. Thanks for everybody's help. Link to comment https://forums.phpfreaks.com/topic/153567-solved-undefined-function-dodb/#findComment-808112 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.