Jump to content

shaunmckinnon

Members
  • Posts

    30
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

shaunmckinnon's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Fixed with this: public function deleteIt($id) { $conn = $this -> connect_open(); // set the table $table = $this -> table; // delete the row required $sql = "DELETE FROM $table WHERE id = $id"; if($conn -> query($sql)) { try { return (int)(($conn->affected_rows > 0) ? true : false); } catch (Exception $e) { echo '<br>Caught exception: ', $e -> getMessage(), '<br>'; } } else { return (int)false; } $conn = $this -> connect_close(); } Thanks again for the help.
  2. Thanks!!! That is exactly what I want. My brain is fried. I've been doing this for 12 hours straight. Time to unplug.
  3. Never mind. I var_dump'd the value in my file that's getting the returned value and it comes up bool(false). $dbman = new DBManipulate; $dbman -> set_Table('users'); $result = $dbman -> deleteIt(6); var_dump($result); I need to learn more. Cheers and thanks for the help!
  4. Thank you. I never knew that, but it makes perfect sense. I'm not doing anything yet. I just want a returned value of either true or false. It's so bizarre. I could just return 1 or 0 and It works. But the second I change it to true or false, even with (int)false, it refuses to obey. Here is the adjusted code: public function deleteIt($id) { $conn = $this -> connect_open(); // set the table $table = $this -> table; // delete the row required $sql = "DELETE FROM $table WHERE id = $id"; if($conn -> query($sql)) { try { return (int)$conn -> affected_rows > 0; } catch (Exception $e) { echo '<br>Caught exception: ', $e -> getMessage(), '<br>'; } } else { return (int)false; } $conn = $this -> connect_close(); }
  5. I don't know if this makes a difference, but here is the whole method: public function deleteIt($id) { $conn = $this -> connect_open(); // set the table $table = $this -> table; // delete the row required $sql = "DELETE FROM $table WHERE id = $id"; if($conn -> query($sql)) { try { return $conn -> affected_rows > 0; } catch (Exception $e) { echo '<br>Caught exception: ', $e -> getMessage(), '<br>'; } } else { return false; } $conn = $this -> connect_close(); }
  6. False should return as "0", as True returns as "1". Either way, it doesn't return. Thanks for the help on getting rid of the ternary. I've tried a crazy amount of things and now I'm stuck in a circle of bad practice. lol However, even with your change, it still won't return the boolean. I still get nothing. Here is the current code: $sql = "DELETE FROM $table WHERE id = $id"; if($conn -> query($sql)) { try { return $conn -> affected_rows > 0; } catch (Exception $e) { echo '<br>Caught exception: ', $e -> getMessage(), '<br>'; } } else { return false; }
  7. Hello: I've just started learning OOPHP, and I love it!!! However, I've come across a strange issue. I'm trying to return a boolean value from my ternary statement. It will not return the boolean. I can return a string literal, an integer, anything else you can think of, but not a boolean. I'm curious if someone could explain why. Here's the code: // delete the row required $sql = "DELETE FROM $table WHERE id = $id"; if($conn -> query($sql)) { try { $num = ($conn -> affected_rows > 0) ? true : false; return $num; } catch (Exception $e) { echo '<br>Caught exception: ', $e -> getMessage(), '<br>'; } } else { return false; } Any help is appreciated. Thank you so much in advance.
  8. that should work. if you're trying to pass PHP variables, you need to echo the variables in the javascript code. probably easier to <? $variable_1 = "unchecked"; $variable_2 = "checked"; echo '<input type="radio" id="" name="" value="'.$variable_1.'">'; ?> i would just block what i need to do in a small php block. still don't quite know what you're looking to do, but hopefully one of these code blocks can help decipher some hassle for you.
  9. I think you're trying to pass PHP variables to the javascript function. If that's the case, you may be approaching it wrong. ie: <html> <head> <script> function check(n1,n2) { document.getElementById('n1').checked=true; document.getElementById('n2').checked=true; } <script> </head> <body> <form> <input type="radio" id="n1" name="n1"> <input type="radio" id="n2" name="n2"> <input type="button" id="checker" name="checker" onClick="check('n1', n2');"> </form> </body> </html> [code] [/code]
  10. sorry, i fixed that. it's still doing the same thing now in both firefox and internet explorer. it shows the select box but when you attempt to make a selection it closes the box on you and doesn't allow it. in fact when you click the arrow, the drop down box recede's immediately.
  11. explain further. do you mean you're trying to call the onClick event in PHP?
  12. when I parse it shows in firefox the select box, but won't let it be selectable. in explorer it just shows AMPM side by side with now select box. Can't figure out what I've done wrong. Here's the code: <html> <head> <title>test</title> <script> function createTimeSelect(id){ document.getElementById(id).innerHTML="" +"<input type='text' id='' name='' value='hour' size='6'>" +":" +"<input type='text' id='' name='' value='minutes' size='6'" +"<select id='' name=''>" +"<option value=''>AM</option>" +"<option value=''>PM</option>" +"</select>"; } </script> </head> <body> <span id="timeSelectField" onClick="createTimeSelect(this.id);">***click here to select the time***</span> </body> </html> Thanks, Shaun
  13. not sure what the problem is. everytime I run this script it tells me that the getElementById is undefined: <html> <head> <title>test</title> <script> // JavaScript Document //testing var var displayTest; //***256fX Calendar Widget*** //labels for the days of the week, names of the months, and number of days in each month days = new Array("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"); months = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); noDays = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); //fall back to today's date today = new Date(); var x = months.length; for(i=0; i<x; i++){ document.getElementById("testing").innerHTML="<br>"+months[i]+" - "+noDays[i]+"<br>"; } </script> </head> <body> <p id="testing"></p> </body> </html> any help would be appreciated. I'm quite new to Javascript, so it's probably something dumb. thanks, shaun
  14. just figured that out LOL wow!!! really important to keep up with this stuff if you want to remember it. 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.