Jump to content

SQL Where Help


DudleyRay
 Share

Recommended Posts

function check_existing($eq,$exists,$ac,$link) { $sql_Eq = "SELECT Code1 AS Code FROM CodeTable WHERE Code2 = '$computercode'"; $typeRow = doQuery($link, $sql_Eq); if ($exists) { // (eg if there is any existing route) echo "Comparing : is $typeRow->CODE inside $eq ?<br>"; if (strpos(" ".$eq,$typeRow->CODE) > 0) { // the ac is there already. do nothing. $need = false; } else { // the ac isn't there. the list must be updated $need = true; } } else { // no route found : must add the route $need = true; } if ($need) { // prepare new ac to be added //echo "Need to add this : $typeRow->CODE<br>"; return $typeRow->CODE.","; } else { return false; } sqlsrv_free_result($types); }

Edited by DudleyRay
Link to comment
Share on other sites

Add this to the top of whatever page you're running that function on: ini_set('display_errors', 1);error_reporting(E_ALL); Does the doQuery function check for database errors? On the last line you're using a variable called $types that I don't see defined, and the function sqlsrv_free_result isn't a built-in function if you're trying to use one there.

Link to comment
Share on other sites

Notice: Trying to get property of non-object in URL on line 42 This is line 42 return $typeRow->CODE.","; There is stuff I am leaving out I know is working because the information I want added is getting added. Just a one column of a table isn't have data entered. Even though the information is getting added to different columns within the table.

Edited by DudleyRay
Link to comment
Share on other sites

That error means that $typeRow is not an object, so doQuery is not returning what you think it is. You can use var_dump if you want to figure out what it's returning. It's fine if you want to leave out code, but I can only answer questions based on what I see. If something that you think is working or is not important is actually important then I can't take that into account if you leave it out. I can tell you that $typeRow is not an object, but I don't know why because I don't know what the doQuery function does for example.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...