Jump to content

amsgwp

Members
  • Posts

    27
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

amsgwp's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. This code should be pretty self explanatory, but I'm struggling bad to get it to work. I want to check if the "propview" element is blank, if so, replace it with "No Contingencies". Simple right? $details_array = array( "propview" => JText::_('COM_IPROPERTY_PROPVIEW' ), "beds" => JText::_('COM_IPROPERTY_BEDS' ), "baths" => JText::_('COM_IPROPERTY_BATHS' ), "sqft" => (!$this->settings->measurement_units) ? JText::_('COM_IPROPERTY_SQFT' ) : JText::_('COM_IPROPERTY_SQM' ), "lotsize" => JText::_('COM_IPROPERTY_LOT_SIZE' ), "lot_acres" => JText::_('COM_IPROPERTY_LOT_ACRES' ), "yearbuilt" => JText::_('COM_IPROPERTY_YEAR_BUILT' ), "heat" => JText::_('COM_IPROPERTY_HEAT' ), "garage_type" => JText::_('COM_IPROPERTY_GARAGE_TYPE' ), "roof" => JText::_('COM_IPROPERTY_ROOF' )); if(empty($details_array["propview"])) { $details_array = array( "propview" => "No Contingencies" ); } It either doesn't do anything or it wipes out the entire array. Maybe the logic should be embedded in the original array, but I haven't found any examples that show that ever being done.
  2. Well I think I figured out my issue and it's a lot bigger than I thought. The script uses ADODB connections instead of the mysql connect functions. I would have to modify so many lines to replace it with mysql connect functions. I think thats why mysql_num_rows isn't working. here is the connect code require($SYS["includes"] . "/adodb/adodb.inc.php"); $conn = &ADONewConnection("mysql"); $conn->Connect($SYS["db_host"], $SYS["db_user"], $SYS["db_pass"], $SYS["db_data"]); I tried replacing $conn with mysql(connect) but it then kills all other parts of the script. Does anyone know if any ADODB method for counting rows so I can use this login script?
  3. Ya, that does sound right. I also realized that for some reason it would have a blank row in the database which allowed anyone to login! And it creates this field if you submit a blank register form! Wow, I checked the database structure and it requires that the username be over 1 character so I don't understand how thats happening. I might just be missing something. Anyways, I tried re-writing login code with the below code but I get the following error: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/login.php on line 16 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/login.php on line 18 require("./shared.php"); $user=$conn->qstr($HTTP_POST_VARS["user"], get_magic_quotes_gpc()); $pass=$HTTP_POST_VARS["pass"]; //$remember = $HTTP_POST_VARS["remember"]; $qry="SELECT playerID, username, password, fullname, email, defProfile FROM $playertbl WHERE username='$user'"; $result=mysql_query($qry); $count=mysql_num_rows($result); while($row = mysql_fetch_array($result, MYSQL_ASSOC)) if($count==1) { unset($pass); unset($user); $HTTP_SESSION_VARS["userID"]=$row["playerID"]; $HTTP_SESSION_VARS["username"]=$row["username"]; $HTTP_SESSION_VARS["fullname"]=$row["fullname"]; $HTTP_SESSION_VARS["email"]=$row["email"]; $HTTP_SESSION_VARS["profileID"]=$row["defProfile"]; $HTTP_SESSION_VARS["phoolID"]=0; header("Location: " . $SYS["base_href"] . "/success.php?type=return&" . SID); } else { echo "<strong>Wrong Username or Password. </strong>"; }
  4. I'm been editing a old script I found on source forge for doing NCAA pickems, I've noticed its seems to be a pretty vulnerable script but it'll work for my uses. Can anyone help figure this out? When you go to the site, and if you click the sign in button, it logs you in and lets you edit stuff with out even entering anything at all! Here is the login code $user=$conn->qstr($HTTP_POST_VARS["user"], get_magic_quotes_gpc()); $pass=$HTTP_POST_VARS["pass"]; //$remember = $HTTP_POST_VARS["remember"]; $qry="SELECT playerID, username, password, fullname, email, defProfile FROM $playertbl WHERE username=$user"; if($rs=&$conn->Execute($qry)===FALSE) { echo "<p><strong>Authentication failed:<br/>\n" . $conn->ErrorNo() . ": " . $conn->ErrorMsg() . "</strong></p>\n"; exit; } if($rs->EOF) { header("Location: " . $SYS["base_href"] . "/signon.php?message=8&" . SID); } elseif($pass!=$rs->fields["password"]) { header("Location: " . $SYS["base_href"] . "/signon.php?message=9&" . SID); } else { unset($pass); unset($user); $HTTP_SESSION_VARS["userID"]=$rs->fields["playerID"]; $HTTP_SESSION_VARS["username"]=$rs->fields["username"]; $HTTP_SESSION_VARS["fullname"]=$rs->fields["fullname"]; $HTTP_SESSION_VARS["email"]=$rs->fields["email"]; $HTTP_SESSION_VARS["profileID"]=$rs->fields["defProfile"]; unset($rs); $HTTP_SESSION_VARS["phoolID"]=0; header("Location: " . $SYS["base_href"] . "/success.php?type=return&" . SID); } I've also checked the database for a blank entry or something but that didnt work.
  5. I just get the same error, it says Fatal error: Maximum execution time of 30 seconds exceeded in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\search_members2.php on line 106 Line 106 is the closing } right above the $results = I just rebooted the MSSQL server and that didn't help. All the other queries run lightning but if that line that starts with for, runs then it's game over. here is the entire page <form name="search" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> Seach for: <input type="text" name="find" /> <input type="submit" name="add" id="add" value="Search" /> </form> <?php include("connect.php"); if(isset($_POST['add'])) { print "<form action=\"search_members2.php\" id=\"form1\" name=\"form1\" method=\"post\">\n"; $query = "select * from members where first_name like '%$_POST[find]%' or last_name like '%$_POST[find]%' or street like '%$_POST[find]%' or city like '%$_POST[find]%' or state like '%$_POST[find]%';"; $result = mssql_query($query,$link) or die("Unable to select: ".mssql_get_last_message()); print "<div id=\"myvar\">$query</div>\n"; print "<a onclick=\"switchMenu('myvar');\" title=\"Show SQL\">Show SQL</a>\n"; print "<table class=\"sample\">\n"; echo"<tr><th>Member ID</th><th>First Name</th><th>Last Name</th><th>Delete</th></tr>"; while($row = mssql_fetch_array($result)) { echo "<tr><td>"; echo $row['Member_ID']; echo "</td>"; echo "<td>"; echo $row['First_Name']; echo "</td>"; echo "<td>"; echo $row['Last_Name']; echo "</td>"; echo "<td>"; ?> <input type="checkbox" name="checkbox[]" id="checkbox" value="<?php echo $row['Member_ID']?>" /> <?php echo "</td>"; echo "</tr>"; //echo "</table>"; } echo "</table>"; echo "<input type=\"submit\" name=\"delete\" value=\"Delete\" id=\"delete\">"; echo "</form>"; } if(isset($_POST['delete'])) { $checkbox = $_POST['checkbox']; $sql = "update members set status = 'Inactive' where member_id ="; for($i=0;$i<sizeof($checkbox);$i++){ $del_id = $checkbox[$i]; if ($i=0) { $sql .= "$del_id"; } else { $sql .= "OR Member_ID = $del_id"; } } $result = mssql_query($sql) or die(mssql_get_last_message()); } mssql_close(); ?>
  6. Ok well why is this not working then?? if(isset($_POST['delete'])) { $checkbox = $_POST['checkbox']; $sql = "update members set status = 'Inactive' where member_id ="; for($i=0;$i<sizeof($checkbox);$i++){ $del_id = $checkbox[$i]; if ($i=0) { $sql .= "$del_id"; } else { $sql .= "OR Member_ID = $del_id"; } } $result = mssql_query($sql); } is that correct? My PHP freaks out and I get a timeout. if you want to watch it choke horribly go to http://fit4life.darktech.org/search_members2.php
  7. I'm having no such luck with this the code seems fine, but now my code is getting into a infinite loop and timing out. do you see anything wrong? It was throwing up a error at the last = where $result = mssql_query($sql) if(isset($_POST['delete'])) { $checkbox = $_POST['checkbox']; echo $checkbox; $sql = "update members set status = 'Inactive' where member_id ="; for($i=0;$i<sizeof($checkbox);$i++){ $del_id = $checkbox[$i]; if ($i=0) { $sql .= "$del_id"; } else { $sql .= "OR Member_ID = $del_id"; } } $result = mssql_query($sql); } ignore that I left the post function at delete, thats really irrelevant right now. EDIT I've also just tried this little snippet to debug if(isset($_POST['delete'])) { $checkbox = $_POST['checkbox']; echo $checkbox; } [code] The result after selecting two or more checkboxes is the word "Array" is displayed on the page. Yuck. [/code]
  8. message: Incorrect syntax near '='. I never got your code to work the first time, I tried someone else's. I knew for this to work I would have to get your code to work. if(isset($_POST['delete'])) { $chkbx = $_POST['checkbox']; $sql = "update members set status = 'Inactive' where member_id = "; for($i=0;$i<sizeof($checkbox);$i++){ $del_id = $checkbox[$i]; if ($i=0) { $sql . "$del_id"; } else { $sql . " OR Member_ID = $del_id"; } } $result = mssql_query($sql); } I obviously can't figure out how to properly concatenate the strings
  9. update members set status = 'Inactive' where member_id = $[chkbox] the only problem is I need to loop this code for each check box that is checked, I can't find a way using SQL to have multiple member id's in an update.
  10. One more question, What if I wanted to update a field in all the rows the checkboxes that are checked. Say I have a table that has a column called Status and it can either be Active or Inactive. How can I change this one field for all the boxes that are checked? So all the checked ID's change to inactive.
  11. thanks! it didn't like the dot part for combing the sql statement with the id's Warning: mssql_query() [function.mssql-query]: message: Incorrect syntax near '='. (severity 15) in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\search_members.php on line 106 Warning: mssql_query() [function.mssql-query]: Query failed in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\search_members.php on line 106
  12. to see what i'm doing check out http://www.utipu.com/app/invited/id/77c7a302a4f447659555fdd00a9f7ec5
  13. In one SQL query, can I not do DELETE FROM members where id=1,2,3,4,5,6 i did a print $id; just to see how the id's were being formated when multiple were selected. It was just ID1ID2 without a space or comma. How can I add commas between the id's(assuming that would work).
  14. ok, after getting the raw data it looked like it was sending the correct id, so I did some changing around and here is my new delete function if(isset($_POST['delete'])) { foreach($_POST['checkbox'] as $id) $sql = "DELETE FROM Members WHERE Member_ID ='$id'"; $result = mssql_query($sql); } it deletes if I only have one checkbox selected. So i what can I do to make it delete multiple id's?
  15. Well It doesn't give an error at all. It just doesn't delete anything from the actual database. I'm trying to print_r right now. (I'll post a response in a minute) Also, I have no idea why I was serializing. I got this snippet of code from somewhere online and thats how it was setup. Can I safely remove this?
×
×
  • 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.