Jump to content

smidgen11

Members
  • Posts

    17
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

smidgen11's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. my work around was to run a bash script to execute instead of generating a new connection id to mysql via php. Im using flush tables with read lock and putting mysql to sleep so that nothing can write only read. NOTE: i have this at a global level because i am not using the box for anything else. all other tables and databases will lock up as well. here is what I ended up doing. lock button: exec("bash /var/www/html/path/mysqllock.sh"); bash for mysqllock: #! /bin/bash /usr/bin/mysql -u root -pX -e "FLUSH TABLES WITH READ LOCK; SELECT SLEEP(86400)" Unlock: include("sqlconnect.php"); //Query the mysql processlist and kill all process ids found including the sleep process id $result = mysql_query("SHOW FULL PROCESSLIST"); while ($row=mysql_fetch_array($result)) { $process_id=$row["Id"]; if ($row["Time"] > 2 ) { $sql="KILL $process_id"; mysql_query($sql); } echo "<meta http-equiv=\"refresh\" content=\"0;URL=index.php\">"; } Im not saying this is the proper way to do it, but this is a very simple way to accomplish what I needed, which was to prevent users from writing to the db when i hit lock and allow when i hit unlock.
  2. Thanks that is exactly what is happening. I was hoping it just plain unlocks the table for good until unlocked. To unlock the table I was going to write a script with an html form action button to simply run the UNLOCK TABLES query. Is there anyway to do a simple lock the database/unlock the database that does not get affected but sessions? If not, Im trying to think of another way to simply stop my php mysql scripts from executing if a user attempts to run them when the lock button is pushed. Maybe changing to password variable in my sqlconnect file or something.
  3. I did see that site and have followed the correct syntax to get it to work from inside my other php sql files. I cant figure out why FLUSH TABLES WITH READ LOCK will not work on its own. Does mysql_query("FLUSH TABLES WITH READ LOCK") prevent proceeding mysql queries from running or something?
  4. Hi, Im trying write a simple command to lock my database but Im having some trouble. Im using [code=php:0] include("sqlconnect.php"); mysql_query("FLUSH TABLES WITH READ LOCK"); echo "db is locked"; [/code] This is not working however. I can run "FLUSH TABLES WITH READ LOCK" from the mysql cli directly and get it to work but not from a form action html that calls my file. Just to test my syntax I threw mysql_query("FLUSH TABLES WITH READ LOCK"); in front of one of my insert mysql queries and the database DOES lock. I cant figure out why I cant get this to work on its own from a single file. Any ideas?
  5. Hi, I am trying write the contents of a php file's output, which echos out a small output of text based on variables and calulations, to a single file. I have tried fwrite and file_get_contents. When I run my code I get the file to create but the file it creates only outputs "1". Here is a look at my code: fwrite version: $text= include '$Site-2851.php'; $file = fopen("myfile.txt","w"); echo fwrite($file, $text); fclose($file); file_get_contents version: $text= include '$Site-2851.php'; $file = 'myfile.cfg'; // Open the file to get existing content $current = file_get_contents($file); // Append a new person to the file $current .= $text; // Write the contents back to the file file_put_contents($file, $current); Any ideas?
  6. HI, I have some code that saves a zip file to a directory that contains a csv file. The code I currently have, successfully creates a zip file containing the csv file I want to create. The issue is, the only record that gets written to the csv file inside the ZIP is the last record of the array. I know this is probably something very simple but I am having some trouble with it. Ive been google'ing but to no avail. Here is my code: <?php include("sqlconnect.php");?> <?php $sql="select Username as 'ALIAS', Extension as 'DTMF_ACCESS_ID' from $tbl_entering"; $result=mysql_query($sql); $filename = 'entering.VMAIL'; $filename = $filename."_".date("Y-m-d_H-i",time()); $header="ALIAS,DTMF_ACCESS_ID\n"; while($rows=mysql_fetch_array($result)) { $data="$rows[0],$rows[1]\n"; } $csvdata= $header.$data; $zipname = 'Batch_'.date("Y-m-d_H",time()); $zip = new ZipArchive; $res = $zip->open("./batch/$zipname.zip", ZipArchive::CREATE); if ($res === TRUE) { $zip->addFromString("$filename.csv", $csvdata); $zip->close(); echo 'ok'; } else { echo 'failed'; } ?> Thanks for the help.
  7. finally...SOLVED. all i had to do was add "php" to this line. BEFORE <td><input name="Selected" type="radio" id="radio[]" value="<? echo $rows['Mac']; ?>"></td> AFTER <td><input name="Selected" type="radio" id="radio[]" value="<?php echo $rows['Mac']; ?>"></td> thanks guys
  8. just to add a more descriptive answer to what my issue is. When I try to echo $del_id on undoentering.php I get: <? echo $rows['Mac']; ?> Which is the text written in my radio button's value.
  9. Hopefully this will make sense. So a number of records are queried and output into the table: <?php echo "<td>"; echo $rows['Location']; echo "</td>"; echo "<td>"; echo $rows['FirstName']; echo "</td>"; echo "<td>"; echo $rows['LastName']; echo "</td>"; echo "<td>"; echo $rows['UserName']; echo "</td>"; echo "<td>"; echo $rows['Extension']; echo "</td>"; echo "<td>"; echo $rows['Mac']; echo "</td>"; echo "<td>"; echo $rows['Type']; echo "</td></tr>"; ?> From this table, each record has a radio button next to hit. When the radio button selects a row the Undo (submit button) is clicked and the "Mac" field of the selected record should post so that my next php file (undoentering.php) will be able to echo the value. Undoentering.php: $del_id = ( $_POST['Selected'] ); echo $del_id;
  10. Hi, I have a sql query at the top that runs and echos the result to the page. Each row in the table has a radio but to select and then a submit button at the bottom of the table which should run the form's action which is another php script. Here is what I have for the table portion: <form name="form1" method="post" action="undoentering.php"> <?php echo "<table>"; echo "<thead>"; echo "<tr>"; echo "<td>Select</td>"; echo "<td>Location</td>"; echo "<td>First Name</td>"; echo "<td>Last Name</td>"; echo "<td>User Name</td>"; echo "<td>Extension</td>"; echo "<td>Mac</td>"; echo "<td>Type</td>"; echo "</tr>"; echo "</thead>"; ?> <?php while($rows=mysql_fetch_array($result)){ ?> <?php echo "<tr>"; ?> <td><input name="Selected" type="radio" id="radio[]" value="<? echo $rows['Mac']; ?>"></td> <?php echo "<td>"; echo $rows['Location']; echo "</td>"; echo "<td>"; echo $rows['FirstName']; echo "</td>"; echo "<td>"; echo $rows['LastName']; echo "</td>"; echo "<td>"; echo $rows['UserName']; echo "</td>"; echo "<td>"; echo $rows['Extension']; echo "</td>"; echo "<td>"; echo $rows['Mac']; echo "</td>"; echo "<td>"; echo $rows['Type']; echo "</td></tr>"; ?> <?php } ?> <td colspan="8" align="center"><input name="delete" type="submit" id="delete" value="Undo"></td> My issue is that nothing POSTs to the next page. When doing it like this the record show empty boxes yet the correct number of empty rows is output: <table> <form name="form1" method="post" action="undoexiting.php"> <thead> <tr> <td>Select</td> <td>Location</td> <td>First Name</td> <td>Last Name</td> <td>User Name</td> <td>Extension</td> <td>Mac</td> <td>Type</td> </tr> </thead> <?php while($rows=mysql_fetch_array($result)){ ?> <tr> <td><input name="Selected" type="radio" id="radio[]" value="<? echo $rows['Mac']; ?>"></td> <td><? echo $rows['Location']; ?></td> <td><? echo $rows['FirstName']; ?></td> <td><? echo $rows['LastName']; ?></td> <td><? echo $rows['UserName']; ?></td> <td><? echo $rows['Extension']; ?></td> <td><? echo $rows['Mac']; ?></td> <td><? echo $rows['Type']; ?></td> </tr> <?php } ?> <tr> <td colspan="8" align="center"><input name="Undo" type="submit" id="undo" value="Undo"></td> </tr> </html> Can anyone lend some knowledge on what I may be doing wrong on the first script. And yes, I did and still am using google. Thanks
  11. awsome.....that did it... thanks a lot
  12. I know this is probably something very dumb but I am having trouble with my if else. I have a sql query that looks for a record and if nothing is found it echos a warning. <?php $sql7="SELECT * FROM `$tbl_name2` WHERE Mac = '$Mac' AND Type = '$Type'"; $result7=mysql_query($sql7); if($result7) { while($row=mysql_fetch_array($result7)) echo "The phone you are using with mac $row[0] $row[1] is a Cisco IP Phone! <br>" ; } else { echo "<img src=\"stop.png\"/> The phone you are trying to use with mac $row[0] $row[1] is not a correct Mac\Type. <br> Please confirm the mac and type again."; } ?> I believe my syntax is correct as my if echo works fine. However, when no records are found I do not see my last else echo. Any input?
  13. Unfortunately, due to the potential of needed more (than 2) reports from one table in the future, I think the zip option is going to be the way to go. Ive been google'ing the zip option for days but cant seem to get anywhere. Do you know of an example of this somewhere on the web?
×
×
  • 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.