PHP - Sql String Testing Tool
So I built a tool for my cms a while back and have decided to share it. The only 2 things that I know of that are similar in nature is phpmyadmin or sql buddy. Now my tool is not nearly as in depth as either of those but what it lets you do is run any query string right from the webpage. But the cool thing that it has over phpmyadmin and sql buddy is that it has buttons for many of the common commands and a ajax select to get the available column names for the selected table. So now you don't have to try and remember what table had what column and "how did I spell that column again".
I use this to test sql strings for syntax and to quickly see if it returns the results I expect without having to edit the code and then save, upload or hit refresh or whatever. Since all the the stuff is done via ajax, it's all quickly displayed and you can change the query immediately and hit the Run Query button again.
I just thought that this could be helpful and useful for others. You can download it here http://amecms.com/ar...ckly-and-Easily
Similar TutorialsHow would I go about making a small feature for my moderators that allows them to select multiple threads while viewing a forum then take action? All I need is an idea of how I would do this. Wouldn't I use the explode() function? Example: http://i490.photobucket.com/albums/rr267/brannenclass/ex.png Ideally just one word authentication and pretty simple, but effective. Preferebly one that does not use Sessions because then the user is unable to press the back button to go back to the original page after submitting the form... I know I could just put a text link there but not all users would click that link... So I am trying to make my life easier at work. I have this idea that I can automate the sales quote via a simple website. I have the entire product list in MySQL and I can query for the individual catagories etc etc and get them to display. The display shows the SKU, Description, Price, and a third field to select quantity. The issue is that once they select a quantity of a paticular line item I need that line item (sku, description, and price fields) to be carried over to the final quote page where the math is done. Not sure how to key the paticular line item fields off the quantity field. Any ideas greatly appreciated... Code: [Select] <?php $query = "SELECT * FROM tbl_prods WHERE cat = 'fruit'"; $target = mysql_query($query); confirm_query($target); while($row = mysql_fetch_assoc($target)) { ?> <form action="quoter.php" method="POST"> <tr> <td><input name="sku" type="text" value="<?php echo $row[sku]; ?>" size="20" /></td> <td><textarea name="desc" cols="150" rows="2"><?php echo $row[desc]; ?></textarea></td> <td><input name="price" type="text" value="<?php echo $row[price]; ?>" size="20" /></td> <td><input name="quantity" type="text" value="0" size="3" maxlength="2" /></td> </tr> <?php } ?> </table> <input type="hidden" name="cust" value="<?php echo $cust; ?>"></p> <input type="hidden" name="reg" value="<?php echo $region; ?>"></p> <input type="submit" name="submit" value="Submit"></p> </form> Hello all, I have a script uploading files on the server. I would like to send a confirmation to user if the file had been uploaded well. Code: [Select] $targetFile = str_replace('//','/',$targetPath) . $filename; move_uploaded_file($tempFile,$targetFile); if (str_replace($_SERVER['DOCUMENT_ROOT'],'',$targetFile)) { mail($to, 'upload notification', "Dear Mr/Mrs $fixedname, the file entitled $filename has been successfully uploaded"); }else { mail($to, ' upload notification', "Dear Mr/Mrs $fixedname, the file entitled $filename has been NOT uploaded"); } I presume I do something wrong because it doesn't work. The successfull email is sent each time. Thank you very much for helping, Eric Can someone give me a simple socket script that I can copy and paste. It can return anything you like. I just want to make sure I have a working socket connection, and if not then you can maybe help me fix it. Hi All,
I have developed a project in PHP, it is a web application.
Now i want to do testing on it,can any one suggest me a free tool by which i can test the php website.
Thanks in advance.
This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=352939.0 Hi, I have a class XMLtool where one of the functions is to output a parameter-passed dom document and then output to the browser screen, so basically: function outputXML($domDocument) { if has attributes print cur nodes attributes for each child, if child is element node outputXML(cur node) else if child is text print text end for each } Please I am not sure what type of unit tests I can perform. I'd appreciate all the help! Hi. I am trying to test to see if a particular record id (int) is included in array. This is the code I am using $sql2 = "SELECT `id` FROM `orderitems` WHERE `orderid` = '" . $orderid . "'"; $orderlist = mysql_query($sql2) or trigger_error(mysql_error() . '<br />Query was:' . $sql2); $orderarray = array(); while ($orderitem = mysql_fetch_array($orderlist)); ( $orderarray[] = $orderitem['id']; ) $prodid=$row['prodid']; if (in_array($prodid, $orderarray)) { echo "<td> In.</td>"; } else { echo "<td> Out.</td>"; } Every case is outputting "Out" even though some should pass. I have verified that the variables are outputting the correct thing, but am not sure about the array. I am just a beginner, so i am hoping there is something really obvious I am doing wrong. Thanks for reading this. I have a part of my code that requires php 5.3+ how can I test to see if the user has 5.3 or greater? At first I thought this would be a good idea, but then I realized that it isn't such as a version: 5.2.10 (not sure if that is an actual version or not). if((int)preg_replace("/\./", "", phpversion()) >= 530){ // Allow functionality } using my code, using 5.2.10 it would allow it, but it shouldn't because it isn't larger than 5.3. what can I do? Just wanted some general advice/guidance, I know there are plenty of articles and tutorials online about unit testing, but I just wanted to get a first hand perspective off of some of you guys... What are some real world examples of actual PHP Unit Testing? Also any unit testing frameworks you can recommend? Apologies if this has been covered before. Hey guys, I'm working on a tool to add to a site that will search by title, author, keyword (3 radio buttons), category(drop-down list),as in a library. I'm working with dreamweaver CS5 with php. I was trying to create recordset with viarables (that display ex. $_POST['category']) and use an if function (if (radioButton1 == checked) { return something } and connect this all to dynamic table. Getting so many errors, I'm asking you for advice how I can do this ? Could you please explain it to me as simple as possible, as I just started using dreamweaver with php. Thanks ! Hi folks! Upon registering, my register script runs an md5 hash on the password. My problem is when the user wants to change passwords. currently I have a very simple profile, and when they edit it, it doesn't rehash the password- it simply replaces the entire hashed old password with the plain, new password. Any way I could get the script to rehash the password? editprofile.php <?php include('config.php'); include('header.php'); if($_SESSION['id']=="") { header("Location: YouMustLogInNotice.html"); } if(isset($_POST['btnedit'])){ $callname = $_POST['callname']; $email = $_POST['email']; $password = $_POST['password']; $sql = mysql_query( "UPDATE users SET callname='".$callname."', email='".$email."', password='".$password."' WHERE id='".$_SESSION['id']."'" ); if($sql){ echo "<script>alert('profile updated');window.location='myprofile.php?id=$userfinal'</script>"; }else{ echo "<script>alert('updating profile failed!');</script>"; } } $sql = mysql_query( "SELECT * FROM users WHERE id='".$_SESSION['id']."'" ); $row = mysql_fetch_array($sql); $user = $userfinal; echo "<td align=center> <div id=box> <table width='100%'> <tr> <td><h2>Edit profile</h2> <form method='post'> <table><tr><th>ID#:</th><td>".$user."</td></tr> <tr><th>Name:</th><td><input type='text' name='callname' value='".$row['callname']."'/></td></tr> <tr><th>Email:</th><td><input type='text' name='email' value='".$row['email']."'/></td></tr> <tr><th>Password:</th><td><input type='password' name='password' value='".$row['password']."'/></td></tr> <tr><th>Registered:</th><td>".$row['registered']."</td></tr> <tr><th>Last Login:</th><td>".$row['lastlogin']."</td></tr> </table><br /> <input type='submit' name='btnedit' value='update' class=button /> </form></div></td> </tr> </table> </td></tr> </table>"; ?> <?php include('footer.php'); ?> these are sections of my profile, just plain right now so easier for u to read: Code: [Select] $notes = 'notes'; $signature = 'signatures'; $friends = 'friends'; $middle=array ( "0" => array ( "section" => $notes, "hide" => "0", "c" => "apple" ), "1" => array ("section" => $signature, "hide" => "0", "c" => "apple" ), "2" => array ("section" => $friends, "hide" => "0", "c" => "apple" ), ); $order = array(2,1,0); foreach ($order as $index) { echo '<br>'.$middle[$index]['section']; } If the hide = 1 how do i hide a array in my foreach? Hi, I just integrate my website with paypal test account. It works fine. now i want that if i pay on paypal website it should return to my website. i use following code to do that <input type="hidden" name="return" value="http://www.miricreation.ae.com/shopping-cart-details.php"> but it didn't working. i also enable auto return url into my test account. but no luck. is there anything need to do for this in code?????????? Please help Thanks I want to give the visitors to my site the option of setting certain preferences and remembering what was chosen from one visit to the next. They might have the choice of setting the backgrond colour of the web page or the font or whatever.
I've already written and tested code to write standard cookies that preserve their choices. However, I'm wondering if that's the best way or if there is a better approach. I don't want visitors to have to re-choose their preferences every time they arrive at the site, which would appear to be the result of using a session cookie stored on the server.
If standard cookies ARE the best solution for my situation, how can I test if the visitor has cookies enabled on their browser? I know that some people definitely don't enable cookies and I'm quite prepared to advise them that they won't be able to save preferences until they enable cookies. However, I first need to know how I can tell definitively if cookies are enabled.
Most of the simple code examples I've found by googling simply try to write a cookie and then try to read it; if both succeed, they think the they've established whether cookies are enabled. The more sophisticated examples, particularly those at stackoverflow, come closer but all of them seem to be critiqued by someone to the effect that they won't work in this or that particular situation.
Given how long cookies and PHP have been in existence, I have to believe that SOMEONE has figured out a definitive way of testing whether cookies are enabled that works in all reasonable circumstances. Can anyone share that technique with me?
I am creating a quiz, with Multiple choice, true and false, and fill in the blanks questions.
The first 2 types are working fine, and I am working on tesing the fill the blank questions...
See code:
//QUESTION 9 if (empty($_POST["ix"])) { $ixErr = "Please select an answer."; } else { $ix = test_input($_POST["ix"]); // check if question only contains letters and whitespace if (!preg_match("/^[a-zA-Z ]*$/",$ix)) { $ixErr = "Only letters and white space allowed."; else ($ix == "charming") { $score = $score+10; echo "<p>9.) " . $ix . " is correct.</p>\n"; } else { echo "<p>9.) " . $ix . " is incorrect.</p>\n"; } } }First, I am testing to see if it is empty, if yes, display error, otherwise use the test_input function on the entered information. Then I want to test and verify that the entered data only contains characters and/or blank spaces, if that returns yes, then I want to test the content for the correct answer. But for some reason the code gets stuck upon testing for the correct answer, please note: I did try elseif, but same issue, please help, thank you. HI - I'm trying to write an expression which tests the existence of a value within a POST variable. I have tried every which way ie isset, empty, ==0.00, NULL and yet I'm doing something wrong as nothing works. I hope you can help this student of PHP ! The expression is testing whether a price per lb exists ie the price of chicken per pound. But some products are not priced this way eg a jar of jam has no $pricelb[$i]. Here's some detail. The expression I am testing is: Code: [Select] if (!isset($pricelb[$i])){ // FIRST HALF FAILS $ordervalue = $price[$i]; $weight = '0.00';} else // SECOND HALF WORKS $pricelb = $pricelb[$i];{ $weight = $weight[$i]; $ordervalue = $pricelb * $weight; The $pricelb[$i] refers to an array of product weights coming off of the array $pricelb = $_POST['pricelb'] which I then cycle through using a for Loop, hence $pricelb[$i]. Bottom Line: if there is no pricelb then the then the ordervalue for the purchase is the same as the starting unit price. Suppose I have 2 products on the order. One with a pricelb of 5 and one with none. Then I do print_r on $_POST['pricelb'] I get: Code: [Select] Array ( [0] => 5 ) I.E. the second value is absent. YET, if I look into the DB table I see pricelb 0.00 for the second value - very confusing ! MANY MANY thanks ! for all your help ! hi, Hi have a web application www.prakhargoel.com/projects/lms/ that is used by students for logging and requesting a computer system in the internet lab. There is a corresponding labadmin at www.prakhargoel.com/projects/lms/labadmin. Though I tried to make this web app as secure as possible, there might be some shortcomings in the security which could be used by hackers. Please analyse the vulnerabilities and tell where I need to improve. If anyone needs, I can provide the php code for further testing. I have: 1) applied sha1 encryption to all passwords. 2) timeout sessions 3) sql injection filters, etc I'm pulling my hair out trying to figure out a simple problem. I've got the following PHP code in an HTML page: $shutoff_date = strtotime($wkend_start_date) - 259200; if ($shutoff_date > $todays_date) { $current_month = date("m"); $current_year = date("y"); $freshman_eligible = 0; if ($current_month >= 2 && $current_month <=7) { $freshman_eligible = 1; } if ($current_month <= 7) { $seniors = $current_year ; } else {$seniors = $current_year + 1; } $juniors = $seniors + 1; $sophomores = $seniors + 2; $freshman = $seniors + 3; echo "HTML Stuff blah, blah, blah"; if ($freshman_eligible = 1) { echo "<option value=\"$freshman\">$freshman</option>";} } The last test to see if $freshman_eligible is equal to 1 is always testing true, and it's actually resetting $freshman_eligible to whatever I put inside the IF statement. No matter what the variable is set to previously, it will reset to whatever I test for in the last section, and hence always tests true. I thought maybe it was an issue with scope, but I'm not sure what the issue would be or how to resolve it. What am I missing??? |