Cant get "check record exist to work" |
5/30/2012 6:37:16 AM |
PHPRunner General questions | |
S
scoobysteve author
Hi all I have a application whereby I want to score my members on content, I am trying to check to see if a value is present in a certain field, and then add points to another field if it is. I am trying to do this on the "after record updated" section, basically "AddImage6" field is a image file, so in this instance I want to direct to a page if this field has any value in there because the file name is random, but if its remains empty then it redirects to another page, I will replace this with "different code once I can get this to work. I am using the code below, what ever i put in the AddImage6<>''"; section it only diverts to the same page when the values are different. |
|
C
|
cgphp 5/30/2012 |
What is the default value for the AddImage6 field in the database? $strSQLExists = "select * from tblproperties where AddImage6 IS NOT NULL"; |
S
|
scoobysteve author 5/30/2012 |
What is the default value for the AddImage6 field in the database? Try this: $strSQLExists = "select * from tblproperties where AddImage6 IS NOT NULL";
|
S
|
scoobysteve author 5/30/2012 |
OK this is the code I wish to run but for some reason it always goes for the first option even if there is a NULL value in the MySQL database in filed ADDImage6 |
S
|
scoobysteve author 5/31/2012 |
OK this is the code I wish to run but for some reason it always goes for the first option even if there is a NULL value in the MySQL database in filed ADDImage6 If I delete the image and then hit save it still goes from the first option and adds 100 to the field score1 any ideas please, I guess this line is at fault somewhere $strSQLExists = "select from tblproperties where ADDImage6 IS NOT NULL"; Code used on the Edit page "After record updated" Event global $conn; $strSQLExists = "select from tblproperties where ADDImage6 IS NOT NULL"; $rsExists = db_query($strSQLExists,$conn); $data=db_fetch_array($rsExists); if($data) { global $conn; $strUpdate = "update tblproperties set score1='100' where UserName='".$_SESSION["UserID"]."'"; db_exec($strUpdate,$conn); } else { global $conn; $strUpdate = "update tblproperties set score1='0' where UserName='".$_SESSION["UserID"]."'"; db_exec($strUpdate,$conn); }
|
![]() |
Sergey Kornilov admin 5/31/2012 |
The typical suggestion is to print all your SQL queries on the page instead of executing them and run them manually against your database. This way you can see what exactly causes the trouble. |
S
|
scoobysteve author 5/31/2012 |
The typical suggestion is to print all your SQL queries on the page instead of executing them and run them manually against your database. This way you can see what exactly causes the trouble.
|