Documentation Index
Fetch the complete documentation index at: https://mintlify.com/ubik69/backEndDevelopment/llms.txt
Use this file to discover all available pages before exploring further.
Overview
The Primary School Management System uses PHP’s MySQLi extension to connect to a MySQL database. All PHP files establish their own database connections using the procedural mysqli interface.Connection Configuration
Connection Parameters
The application uses the following connection parameters consistently across all PHP files:sdb-57.hosting.stackcp.netThe MySQL database server hostname
student84-353031351c89Database username for authentication
ua92-studentAcDatabase password for authentication
student84-353031351c89The database name to connect to
Connection Pattern
Standard Connection Method
All PHP files in the application use this consistent pattern:Alternative Variable Naming
Some files use$connection instead of $link:
Both
$link and $connection variable names are used throughout the codebase. Ensure you use the correct variable name when executing queries in each file.Connection Files Reference
Here’s where database connections are established in the application:Student Operations
AddStudent.php- Uses$linkViewStudent.php- Uses$linkUptadeStudent.php- Uses$linkDeleteStudent.php- Uses$link
Teacher Operations
AddTeacher.php- Uses$linkViewTeacher.php- Uses$linkUptadeTeacher.php- Uses$linkDeleteTeacher.php- Uses$link
Parent Operations
AddParent.php- Uses$linkViewParent.php- Uses$linkUptadeParent.php- Uses$linkDeleteParent.php- Uses$link
Class Operations
AddClass.php- Uses$linkViewClass.php- Uses$linkUptadeClass.php- Uses$linkDeleteClass.php- Uses$link
Other Operations
admin_login.php- Uses$connectionAddGymMember.php- Uses$linkViewGymMember.php- Uses$linkAddSalary.php- Uses$linkViewSalary.php- Uses$linkContact.php- Uses$linkViewContact.php- Uses$link
Executing Queries
Insert Operations
After establishing a connection, insert queries follow this pattern:Select Operations
Query results are fetched usingmysqli_query() and processed with fetch_assoc():
Update Operations
Delete Operations
Connection Error Handling
Current Implementation
The application uses basic error handling:Recommended Enhanced Error Handling
For production environments, implement more detailed error handling:Security Considerations
SQL Injection Vulnerability
The application directly concatenates user input into SQL queries:Recommended: Use Prepared Statements
Replace direct concatenation with prepared statements:Parameter Types for mysqli_bind_param
For INT, BIGINT, and other integer types
For FLOAT, DOUBLE, DECIMAL types
For VARCHAR, TEXT, DATE, and other string types
For BLOB and binary data types
Configuration Best Practices
Environment Variables
Store database credentials in environment variables or a separate configuration file, not hardcoded in PHP files
Connection Pooling
Use persistent connections with
mysqli_connect() p: prefix for better performance under high loadCharacter Encoding
Always set character encoding to utf8mb4 after connection to support all Unicode characters
Error Logging
Log database errors to files instead of displaying them to users in production
Recommended Configuration File
Create a separate configuration file for database credentials:Connection Lifecycle
Opening a Connection
Using the Connection
Closing the Connection
The current codebase does not explicitly close connections. PHP automatically closes connections at the end of script execution, but it’s best practice to close them manually.
Complete Example
Troubleshooting
Connection Refused
If you receive “Connection refused” errors:- Verify the database server is running
- Check firewall rules allow connections to the MySQL port (default 3306)
- Confirm the hostname is correct and resolvable
Authentication Failed
If authentication fails:- Verify username and password are correct
- Check the user has permissions to access the specified database
- Ensure the user is allowed to connect from your host/IP address
Database Not Found
If the database doesn’t exist:- Verify the database name is spelled correctly
- Check the database exists on the server
- Confirm your user has access to that specific database
Character Encoding Issues
If you see garbled text or special characters display incorrectly:Migration Recommendations
Create Connection Helper
Build a
db_connect.php file that handles connection logic with proper error handlingImplement Prepared Statements
Migrate all SQL queries from string concatenation to prepared statements