Jump to content

cademichaels

New Members
  • Posts

    3
  • Joined

  • Last visited

cademichaels's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. How would I properly handle a bad SQL string query? For example if the $table provided doesn't exist, the where expression is invalid, or the $field doesn't exist? function GetMax($field, $table, $WhereExpression) { $con = mysqli_connect(ServerHostName, ServerUser, ServerPass, ServerDB); if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); exit(); } $q = "SELECT Max($field) AS MaxOfGetMax FROM $table WHERE $WhereExpression"; $rst = mysqli_query($con, $q); if ($rst=false){ if ($row = mysqli_fetch_array($rst)) { return $row["MaxOfGetMax"]; } return null; } }
  2. Thanks for your help. I found the problem! (I wasn't clearing the string later in the code)
  3. So here is the code: About 99% of the time it returns the XML listed under "Good Return" but almost randomly it is returning the code under "Bad Return". I echoed out all of the $ToID's and there is no weirdness (Only long integers) foreach ($xml->result->Accounts->row as $a) { $ToID = (String) $a->FL[0]; $FromData = (String) $a->FL[1]; $ToXML .= '<row no="' . $UpdateCount . '">'; $ToXML .= '<FL val="Id">' . $ToID . '</FL>'; $ToXML .= '<FL val="' . $ToField . '">' . $this->FixID($FromData) . '</FL>'; $ToXML .= "</row>"; $UpdateCount+=1; $TotalUpdateCount+=1; echo "$ToID <br>"; //For debugging } ---- Bad Return (Its missing a < after ID) <row no="162"> <FL val="Id">1058030000000072643/FL><FL val="MemberCode">Firms.338</FL> </row> ---- End bad return ---- Good Return <row no="163"> <FL val="Id">1058030000000072642</FL> <FL val="MemberCode">Firms.337</FL> </row> ---- End good return
×
×
  • 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.