Click here to Skip to main content
15,664,618 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
what I want to do is, everytime a user chooses an option from my dropdownlist on my registration form, the records on my database table adds up by 1.

I keep getting there error:
Fatal error: Uncaught mysqli_sql_exception: Unknown column 'information_service' in 'where clause' in C:\xampp\htdocs\user-page\user_interface\appointment.php:11 Stack trace: #0 C:\xampp\htdocs\user-page\user_interface\appointment.php(11): mysqli_query(Object(mysqli), 'UPDATE scoring ...') #1 {main} thrown in C:\xampp\htdocs\user-page\user_interface\appointment.php on line 11

HERE is the code of my form

		<div class = "container-fluid">
			<form method= "post" action= "appointment.php">
				<h1>Book Appointment for Guidance</h1>
					<div class= "group">
					<select name="service" id ="services" onchange="enableType(this)">
						<option value ="0">--Choose Services--</option>
						<option value ="individual_inventory">Individual Inventory</option>
						<option value ="counselling_service">Counselling Services</option>
						<option value ="information_service">Information Services</option>
						<option value ="follow-up_service">Follow-up Services</option>
						<option value ="psychological_testing_and_evaluation">Psychological Testing and Evaluation</option>
						<option value ="referral">REFERRAL</option>
						<option value ="placement_service">Placement Services</option>

					<input name="submit" type ="submit" class="button" value="Submit">

What I have tried:

THis is my php code:

<pre><?php include_once('connect.php');


    $serv =$_POST['service'];
    $type =$_POST['types'];
    $case =$_POST['cases'];

           $mysql ="UPDATE scoring SET services_score = services_score + 1 WHERE services = $serv";
        $mysqls ="UPDATE scoring SET types_score = types_score + 1 WHERE counseling_types= $type";
        $mysqlss ="UPDATE scoring SET cases_score = cases_score + 1 WHERE counseling_cases = $case";


The variable $serv is assigned for the <select> tag named 'service'. and the information_service from the error message is a value name for <option>Information Service. it is also a name of a row in my database. I have named the row and the value the same, so that, if the user chooses any from the option, then the code will execute to call the row from my database according to the user selected option. but the code recognizes the option value as a column name.

please help me
Updated 24-Nov-22 0:42am
Richard Deeming 24-Nov-22 8:25am    
Your code is vulnerable to SQL Injection[^]. NEVER use string concatenation/interpolation to build a SQL query. ALWAYS use a parameterized query.
PHP: SQL Injection - Manual[^]

1 solution

It's not that code - read the error message:
unknown column 'information_service' in 'where clause' in C:\xampp\htdocs\user-page\user_interface\appointment.php:11

It can't find a column called information_service in your DB.

Since none of what you show us references information_service the problem is elsewhere in you code where we can't see it.
So start by looking at the file appointment.php and specifically at line number 11 - that's where the problem is being reported.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900