Jump to content

jugdish114

New Members
  • Posts

    5
  • Joined

  • Last visited

jugdish114's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I am having an issue where the output from a MySQL stored procedure is not handled correctly, when there is NO resultset, as opposed to a NULL resultset. For example: 1) select * from myTable; //this works, there are 0,1, multiple records returned 2) select * from myTable where 1=2; //this works, there are 0 records returned in a NULL resultset 3) set user_level = 'user'; if user_level = 'admin' then select * from myTable; //this never hits end if; There is an error in #3, the query is never touched, so NO resultset is returned. This is different from what happens in example #2, where a resultset is returned, it is just NULL. My code looks like this: if ( ($result = $mysqli_conn->query($SQL)) == false ) { printf("Invalid query: %s\nWhole query: %s\n", $mysqli_conn->error, $SQL); } else { while ($myrow = $result->fetch_array(MYSQLI_ASSOC)) { ... do something here } Any thoughts on how to handle this cleanly? Thanks all, Frank
  2. This works for my needs: function null_intval($int_string) { if ($int_string == "") return 'NULL'; if ($int_string == null) return 'NULL'; return mysql_real_escape_string($int_string); } Thanks again, fc
  3. Thanks DavidAM. That was the same basic approach I was working on last night; I think the reason why my code wasn't working the way I wanted was that i was saying "if $string == NULL" where your code uses the lowercase null instead. (Still not sure what the difference is, I need to do some reading) I will work this new code in tonight, thanks again for the help. fc
  4. It's a NULL, not a string (eg 'NULL'). I'm not sure if passing null would work where NULL did not. Does that make sense?
  5. I'm trying to pass a NULL to a stored procedure in a PHP script to MySQL, and I am scrubbing the variables using mysql_real_escape_string, but the NULLs that are passed are giving me problems. My script should look like this: call spMyStoredProc(1,2,NULL,'username'); but unfortunately I get: call spMyStoredProc(1,2,,'username'); I am wondering if I want to move away from using mysql_real_escape_string, and possibly write my own function? Anybody have any ideas? thanks, Frank C
×
×
  • 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.