Jump to content

behrk2

Members
  • Posts

    19
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

behrk2's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Ok, thanks. I suppose I can name each function differently, and have each name match its $dir name. Or, what if, within the foreach statement, I call that sdb_setup() function directly (from sdb_script.php), instead of doing it within auto_test.php? I guess I'm trying to do this as efficiently as possible.
  2. Basically, run_auto.php calls a function in auto_test.php, which collects a bunch of directory names into an array. Then, in run_auto.php, I have a for loop that looks like this: foreach ($dir_array AS $dir) { echo("CURRENTLY RUNNING $dir, $count out of ".count($di$ $a_t -> prep($DB, $ode, $sel, $schema, $dir); $a_t -> sdb_script($DB, $ode, $sel, $schema, $d$ $a_t -> pdb_script($DB, $ode, $sel, $schema, $d$ $a_t -> test_script($DB, $ode, $sel, $schema, $$ $err = $a_t -> regress_test($DB, $ode, $sel, $s$ $a_t -> write_dirs($DB, $ode, $sel, $schema, $d$ $clear = exec("clear"); echo "$clear"; $count++; } $a_t is an object of auto_test.php. So, for every $dir, these functions from auto_test.php will run. The one function, sdb_script, will call a function, sdb_setup, which is from a file in each different directory ($dir). And therein lies the error...
  3. Ah, ok. I thought it would be okay to do since sdb_setup is called from a different file every time. Do you have any suggestions as to how I can restructure my classes to achieve what I'm trying to do? I would greatly appreciate it... Thanks!
  4. sdb_setup() is a function that just contains a bunch of postgresql queries. In auto_test.php, there is basically a loop that runs through a collection of $dirs (stored in an array), and for each $dir, sdb_setup() is called. But the sdb_setup called is from a different file each time, even though its the same function name...
  5. Hey guys, so I'm STILL receiving this error, and it's driving me NUTS! It's been really hard to explain, so no one seems to understand it, but I have attached a diagram this time. Here is the error and the diagram. Can anyone see what's going on? Thanks... Fatal error: Cannot redeclare sdb_setup() (previously declared in /home/kevin/projects/hydro4ge/src/sel/tc_add_column/sdb_script.php:9) in /home/kevin/projects/hydro4ge/src/sel/tc_add_column_default/sdb_script.php on line 24
  6. Hm, I tried making a child class of which is called by the parent, but still the same error...
  7. Hey guys, I posted something really confusing before, but have since refactored my code to something much more simple. Anyways, I have the following scripts: run_auto.php auto_test.php I am getting the following error: "Fatal error: Cannot redeclare sdb_setup()", and I'm not sure why. Here are some code segments: run_auto.php: require_once('auto_test.php'); $a_t = new auto_test(); . . . . } else if ($dir == '-regression' && $arg == '') { $count = 1; $dir_array = $a_t -> collect_dirs(); foreach ($dir_array AS $dir) { echo("CURRENTLY RUNNING $dir, $count out of ".count($dir_array)." test cases.\n\n\n"); $a_t -> prep($DB, $ode, $sel, $schema, $dir); $a_t -> sdb_script($DB, $ode, $sel, $schema, $dir); $a_t -> pdb_script($DB, $ode, $sel, $schema, $dir); $a_t -> test_script($DB, $ode, $sel, $schema, $dir); $err = $a_t -> regress_test($DB, $ode, $sel, $schema, $dir); $a_t -> write_dirs($DB, $ode, $sel, $schema, $dir, $err); $clear = exec("clear"); echo "$clear"; $count++; } auto_test.php: public function sdb_script($DB, $ode, $sel, $schema, $dir) { require_once "$dir/sdb_script.php"; try { sdb_setup($DB, $ode, $sel, $schema); } catch (Exception $e) { $file = fopen($dir.'/'.$dir.'-sdb.error', 'w'); fwrite($file, $e->getTraceAsString()); fwrite($file, $e->getMessage()); fclose($file); echo "\n"; echo "...ERROR: See $dir/$dir-sdb.error"; echo "\n"; exit(1); } So, run_auto.php (which requires_once auto_test.php), instantiates an object of auto_test.php, and calls upon multiple functions, one being sdb_script(). The sdb_script() calls the function sdb_setup from another file, which I have require_once INSIDE the sdb_script() function...it has to be that way, I cannot put it outside of that function. Does anyone know how I can fix this? Thanks!
  8. Hey guys, so I am refactoring a bunch of php scripts that I wrote and I am adding classes and functions and what not. Everthing is going well, but I am running into the following snag: I have 3 files: run_auto.php, auto_test.php, and run_all.php. run_auto.php is my main file, which contains if statements that read in arguments from the command line (linux), so for example if I run "$php run_auto.php tc_add_column -regression", then run_auto will see that argv[1] exists, and that it is "tc_add_column". It then passes that argv[1] into my second script, auto_test.php. Now, auto_test.php has two require_once statements, both of which require knowing that argv[1], as it is needed in the require path. Here lies my problem: Let's say I run "$php run_auto.php -regression". argv[1], which is passed to auto_test.php, is now not a valid directory name. So, I surround the require_once statements with an if statement, saying if argv[1] != "-regression", then look at these require statements. BUT, auto_test.php contains a call to a function that needs that require statement in place. So, in run_auto.php, if "-regression" is the first argument (argv[1]), then I don't call auto_test.php. I call run_all.php which then feeds the required directory to the require statements in auto_test.php. That won't happen though because run_auto.php won't even run fully because the compiler sees "require_once('auto_test.php') and it seems it "runs through" that script to make sure everything is kosher, even though I am not calling it, and it will see that those require statements don't have a directory. This is probably all very confusing, but if anyone gets a sense of what I mean and has a suggestion, I would appreciate it! Thanks!
  9. Thanks for the quick responses everyone, I appreciate it. That did it! I feel so stupid...
  10. Hey everyone, So I have two classes, let's call them classA and classB. In classA, I instantiate a new object of classB (I have a require_once of classB.php): $cb = new classB(); Now, I call a series of functions from classB: $cb -> functionA(); $cb -> functionB(); $cb -> functionC(); So, let's say functionC() returns a variable, $err, how can I get that returned variable? I know that I can't just say: echo "$cb"; Does anyone know how I can do it? Thanks!
  11. Hey guys, I will try and explain this as clearly as possible: I have a PHP page that displays the f_name, l_name and status for any person of whom their status = 'Pending'. Basically, I have the page set up with one table. In each cell I have <?php echo $f_name ?>, <?php echo $l_name ?>, and <?php echo $status ?>. So if there is more than one record, another table is automatically generated with the second record. Now, next to each record (in each table) I have a two html form buttons: Approve and Deny. The table is surrounded by a form area. If Deny is pressed, then status has to change to 'Denied'. If Approved is pressed, then status has to change to 'Approved'. Here lies two problems: First, I have NO way of differentiating the records from the first table from the records in any other table that was automatically displayed. Second, the records are not displayed in a form element. They are merely a PHP echo. So I cannot POST any of the records. To get around this, I established hidden fields for each cell where the hidden field is = to the PHP echo. This worked, however again, if there are two records, the hidden field elements are set to the records from the last table. The hidden fields for each table will not hold their own distinct records. ...ah. I hope I explained that well. Does anyone have any ideas!!! Thanks so much!
  12. Hey all, I wanted to run this idea past you. I am looking to create a PHP Calendar with a MySQL Backend. How is this going to work? I have NOOO idea!! Here is what I need it for: I am a resident assistant, and am looking to make a calendar system to schedule duty. Only one person is on duty during the weekdays (Mon, Tues, Wed, Thurs, Sun) and two people are on duty during the Weekends (Fri, Sat). There needs to be an input system where one RA can go in and say that Person A is on duty on Weekday X of Month Y of Year Z or Person A and Person B are on duty on Weekend Day X of Month Y or Year Z. I also want to be able to keep track of how many weekdays/weekend days each person has for each month. I would like to be able to display all of this in a calendar (which can be an html table or whatever). Does anyone have any ideas as to how I can implement this? (sql table columns, dealing with different amounts of days in each month, etc.)? Thanks!
  13. Hey guys, So I have the following html form set up on the page search1.php: <form name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <input name="search" type="text" id="l_name7" size=25 maxlength=25> <select name="select"> <option value="r_num">R Number</option> <option value="f_name">First Name</option> <option value="l_name" selected>Last Name</option> <option value="reg_num">Region #</option> <option value="res_hall">Residence</option> <option value="username">Username</option> </select> <input type="Submit" name="Submit" value="Submit"> </form> So basically there is a text box (search) and a list box (select) containing the categories to search within the MySQL database. Now, in the same page, I have the following PHP Code: <?php $dbhost = "localhost"; $dbname = "hub_info"; $dbuser = "root"; $dbpass = "xxxxxx"; mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error()); mysql_select_db($dbname) or die(mysql_error()); //get the mysql and store in $result $result = mysql_query("SELECT * FROM ra_info WHERE '$select' LIKE '%$search%'"); //grab all the content while($r=mysql_fetch_array($result)) { $f_name=$r["f_name"]; $l_name=$r["l_name"]; //display the row echo "<br>$f_name <br> $l_name <br>"; } ?> Now, I have two problems. First, when I load the page (or submit a search), all of the results in the database are listed. I cannot narrow the results to only what I searched for. Second, the results are shown as soon as the page loads. Is there anyway to hide the PHP code until the search is actually performed? Thank you so much for your help!
  14. Hey all, So I have a search.html with a form which posts to search.php. I am searching for a last name (l_name), and should it find a result, I want the page to display f_name and l_name. I have somewhat accomplished this, except for the fact that search.php displays the f_name, l_name for every user in the database. Here is my code for search.php: <? //connect to mysql mysql_connect("localhost","root","xxxxxx"); //select database mysql_select_db("hub_info"); $search=$_POST["l_name"]; //get the mysql and store in $result $result = mysql_query("SELECT * FROM ra_info WHERE l_name LIKE '%$search%'"); //grab all the content while($r=mysql_fetch_array($result)) { $f_name=$r["f_name"]; $l_name=$r["l_name"]; //display the row echo "<br>$f_name <br> $l_name <br>"; } ?> Any ideas? Thanks!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.