CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge -> Programming

 Validation Event + php

Print topic Send  topic

Author Message
phper

Posts: 4
Posted: 09/27/2004, 5:11 PM

I'm trying to write a validation event in codecharge 2.0.7 using PHP.

here is the code:
=======
$dbquery = "SELLECT * FROM studentclass WHERE
student_id = $fldstudent_id AND
class_id = $fldclass_id AND
course_id = $fldcourse_id";
$dbresult = mysql_query($dbquery);
if (!$dbresult)
$sstudentclass1Err .= "Student is currently enrolled <br>in selected class";
=======

I have added the code into the validation box with no success. It seems to fail every time and return the error message no matter if the query is true or not.

What is the correct way to do/write this or what am i doing wrong?
View profile  Send private message
Nicole

Posts: 586
Posted: 10/12/2004, 2:48 AM

Hello,
It appears that your query is valid every time and thus mysql_query() returns true. Quote from PHP manual:
"A non-FALSE return value means that the query was legal and could be executed by the server. It does not indicate anything about the number of rows affected or returned. It is perfectly possible for a query to succeed but affect no rows or return no rows."

I suggest that you try DLookUp() function instead and count number of records which match the WHERE:
  
$result=0;  
$result=DLookUp("studentclass", "count(*)", "student_id =". $fldstudent_id." AND class_id = ".$fldclass_id ." AND  course_id = ". $fldcourse_id);  
if ($result>0)  
$sstudentclass1Err .= "Student is currently enrolled <br>in selected class";  

_________________
Regards,
Nicole
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.