This topic is locked

Read Only creates an error

8/8/2006 11:08:47 AM
PHPRunner General questions
A
amirgulamali author

I have a required field in my page,

Now i dont want the users to be able to edit it after entering it once. So i let it be READ ONLY on editing but I am getting an error when the page loads:
--------------------------------------------------------------------------

PHP error happened
Technical information

Error type 256

Error description You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

URL localhost/neva7/_students_edit.php?

Error file C:\wamp\www\7\include\dbconnection.php

Error line 26

SQL query update `_students` set
--------------------------------------------------------------------------
The page works fine if i let the users edit the filed which i cant affort to do..
any help would be appreciated

A
amirgulamali author 8/8/2006

anyone? does READ ONLY conflict with the REQUIRED field.. or shall i ask, can a REQUIRED field be "VIEWED" as READ ONLY ?.. i dont see any reason why it shoudnt..
Admins, help pls.. or anyone..

J
Jane 8/9/2006

Amir,
edit page doesn't work if all fields are read-only on the EDIT page. Make one field is not readonly on the EDIT page or remove edit page.
Required field can't be as readonly.

I'm not sure that I understand you correctly.

Please clarify exactly what you try to achieve.

W
wrjost 8/9/2006

Hello,

hate to contradict you, Jane ...

Required field can't be as readonly.


... but I successfully did just that. It works as long as you give it a default value.
In my case I am building a tournament registration site which keeps track of when users registered their teams. (This datetime field must not be alterable at a later date, due to deadlines.) So, I made it readonly AND required, with a default value of "now()".
Best regards,

Wilfried

J
Jane 8/9/2006

Wilfried,
as I understand if field is required then user should fill it.

If field is readonly then user can't change this field.
There is a workaround to make field as readonly and reqired at the same time but it's nonsensical.

W
wrjost 8/9/2006

Jane,

of course, you are right.
My field "registration date" used to be a required field which users had to fill out. But then I realized they could manipulate the date later on and made it "read-only" with the default value of "now()" - I just forgot to uncheck the "required" flag.
But, I had a similar problem to Amir's: my users have to state a "reference time" of their team when they register it for a tournament. And they must not be able to alter it later on.
Solution:

In the "Choose Fields" section uncheck the field for the EditPage (they can not edit what they cannot see...).
In the "Formatting" section mark the field as "required" in the "Edit format".
Worked for me.
Regards,

Wilfried

A
amirgulamali author 8/9/2006

I have other fields which I don’t want to be read only, I only want Student Number to be read only (because if its editable, chanCes are that users might edit it - I don’t want that)..
I want student number to be a REQUIRED FIELD when adding a new record but when that record is edited, for other fields such as dates etc, I dnt want student number to be editable...
"A student number for a student will never change once assigned, other fields such as Majors, courses etc change from time to time.. I want students to fill theier number when signing up..(a MUST/REQUIRED field) but when they edit their other info.. student number should be READ ONLY!" hope I was clear..
Thanks to all

Amir

J
Jane 8/9/2006

Amir,
use solution which Wilfried suggested.

A
amirgulamali author 8/9/2006

Ok.. i tried unchecking it from the edit page and Student Number does not appear in hte edit page.. I wish I had it there as read only.. guess this is the conclusion:
A REQUIRED FIELD (IN ADD PAGE) CANNOT BE VIEWED AS READ ONLY (IN EDIT PAGE)
Correct?
Ok if correct , then i can live with it, however would like the student number to be displayed in the edit page on the header.. my current header displays:
REGISTERED STUDENTS, Edit record [entry_id: 3] where entry_id is a PK.. for my own use only.. i dont want the students to be able to see it.. can i have the student number for each particular record be displayed there instead? Jane this related to my other post.. "Editing Records" thanks for your help both of you
Amir <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=10288&image=1&table=forumreplies' class='bbc_emoticon' alt=':blink:' />

A
amirgulamali author 8/9/2006

I tried using:

echo "<h1>REGISTERED STUDENTS, "."Edit record"." [".StudentNumber."]</h1>";


but i am getting:

PHP error happened

Technical information

Error type 8

Error description Use of undefined constant StudentNumber - assumed 'StudentNumber'

URL localhost/TRY1/_students_edit.php?editid=3

Error file C:\wamp\www\TRY1\_students_edit.php

Error line 224

SQL query select `entry_id`, `Username`, `FirstName`, `LastName`, `StudentNumber`, `Email`, `Major`, `InternationalStudent`, `AnnualFeePaid`, `EnrollStudentin`, `CoursesCompleted`, `Comments` From `_students` where `entry_id`=3


This makes sense since StudentNumber is no longer defined in that page.. since i unchecked it from the Edit page as suggested above!
But then again i have:

include("include/_students_variables.php"); hence defined.. pls correct me if im not understanding the logic here
Guess a solution to one problem lead to another.. pls advice!

Alexey admin 8/10/2006

Amir,
find this snippet in your ..._edit.php file

LogInfo($strSQL);

$rs=db_query($strSQL,$conn);

$data=db_fetch_array($rs);

and move it just before the line you modified:

echo "<h1>REGISTERED STUDENTS, "."Edit record"...



Then change the line this way:

echo "<h1>REGISTERED STUDENTS, "."Edit record"." [".$data["StudentNumber"]."]</h1>";

A
amirgulamali author 8/10/2006

Thanx alexey, that works but creates more errors in other funtions.. I would rather make the Student Number field read only and not loose any of its funtionalty... I am using edit_events to pass student number to another tables as well
This is one thing i would like to see in the new version:

A REQUIRED field (IN ADD) be viewed as READ ONLY (IN EDIT)
Is there any way I could do it?
I tried to study this code in my edit page:
// is field editable
if(GetEditFormat("StudentNumber") != EDIT_FORMAT_HIDDEN)

GetData($rs,$data,"StudentNumber", Format("StudentNumber"));

echo "\r\n<tr><td class=shade>".Label("StudentNumber")." </td><td>";

echo BuildEditControl("",$value,GetEditFormat("StudentNumber"),MODE_EDIT);

GetEditFormat("StudentNumber")==EDIT_FORMAT_READONLY

echo GetData($rs,$data,"StudentNumber", Format("StudentNumber"));

echo htmlspecialchars(GetData($rs,$data,"StudentNumber", Format("StudentNumber")));
if(GetEditFormat("StudentNumber")==EDIT_FORMAT_READONLY)

{

if(Format("StudentNumber")!=FORMAT_HTML && Format("StudentNumber")!=FORMAT_FILE_IMAGE && Format("StudentNumber")!=FORMAT_FILE && Format("StudentNumber")!=FORMAT_HYPERLINK && Format("StudentNumber")!=FORMAT_EMAILHYPERLINK && Format("StudentNumber")!=FORMAT_CHECKBOX)

echo htmlspecialchars(GetData($rs,$data,"StudentNumber", Format("StudentNumber")));

else

echo GetData($rs,$data,"StudentNumber", Format("StudentNumber"));

}

echo GetLegendIcon("StudentNumber");

if(GetEditFormat("StudentNumber") != EDIT_FORMAT_HIDDEN)

echo "</td></tr>";

but removing this piece doesnt pass the Student Number into another table upon editing.. sorry for my questions.. appreciate your help tho
thanx

Alexey admin 8/10/2006

Amir,
thank you for sharing your idea.
You can make a field read-only on the Edit manually modifying PHPRunner-generated files.
Unfortunately we don't support the code modifications made by our customers.