I have this error when i open the page...but once i select the city from dropdown list,the error doesn't exist. Error is like this:

WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1]

SELECT * FROM wp_city_details WHERE id=

I have city dropdown list like this:

<select class="form-control" name="city" id="city"  onchange="this.form.submit();">

    <option value="0 ----"></option>

                                $i = 1;
                                $cities = all_cities();
                                foreach ($cities as $city){
                                    $value = $i . " " . $city;
                                    if (isset($_POST["city"])){
                                        if ($_POST["city"] == $value){
                                            ?> selected="true" <?php
                                    value="<?php echo $value; ?>"><?php echo $city;?></option>
  • Well the error is with your SQL. So the error must exist there. What's the code for your query? – Jacob Peattie Dec 18 '18 at 8:38
  • $query = "SELECT * FROM wp_city_details WHERE id=" . $id; – Mht Dec 29 '18 at 8:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.