PHP - Getting A Strange Error From My Query...
Quote
Unknown column 'Carmel' in 'where clause'
Passing variable via the URL: https://www.courtsideindiana.com/season-preview/19-20/sectional1920/?sectional=8&school=Carmel Sectional = 8 School = Carmel Before I added the &school=Carmel, it was working, just echoing the total list of schools in the table. $sectional = $_GET['sectional']; $school = $_GET['school']; echo $school; // Query $query = "SELECT * FROM a_schools WHERE sectional=".$sectional." AND school=" . $school .""; $results = mysqli_query($con,$query); echo mysqli_error($con); while($row = mysqli_fetch_assoc($results)) { echo $row['school'] . '<br>'; }
Similar TutorialsI don`t get it, waht is wrong?! Code: [Select] <?php require_once 'auth.php'; if (!isset($_SESSION['SESS_VERIFY'])) { header("location: access-denied.php"); exit(); } if ($_SESSION['lang'] == 'Ro') { // setare data romania date_default_timezone_set('Europe/Bucharest'); $today = getdate(); $zi = $today['mday']; $luna = $today['mon']; $lunastring = $today['month']; $an = $today['year']; $data = $zi.$luna.$an; $data = (string)$data; $ora = date('H:i:s'); $msg = array(); $err = array(); $luni = array ( 1=>'Ianuarie', 2=>'Februarie', 3=>'Martie', 4=>'Aprilie', 5=>'Mai', 6=>'Iunie', 7=>'Iulie', 8=>'August', 9=>'Septembrie', 10=>'Octobrie', 11=>'Noiembrie', 12=>'Decembrie'); // comun const SQL_ERR = 'SQL statement failed with error: '; const ADD_MODEL = 'ADAUGA UN MODEL NOU'; . .many constants.. . } elseif ($_SESSION['lang'] == 'It') {... Thank you! Hi guys, In my connection.php I have: $db->query("DROP TABLE IF EXISTS mydata") ; $db->query("CREATE TABLE mydata ( ID INT AUTO_INCREMENT NOT NULL PRIMARY KEY, guid INT, title VARCHAR(100), body LONGTEXT, term VARCHAR(100) )"); and my query code : $myarray = array ( guid => 100, title => "title test", body => "just a test", term => "term test", ); $myplaceholders[] = '(' . implode (", ", array_fill(0, count($myarray), '?')) . ')'; //also tried '(?,?,?,?)' $mykeys = implode(', ', array_keys($myarray)); array_push($values, ...array_values($myarray)); //also tried $values = array_values($myarray) ; $res = $db->prepare("INSERT INTO mydata ($mykeys) VALUES " . join(', ', $myplaceholders)) ; if ($res->execute($values)) { echo 'data inserted'; } else { echo 'error in query'; } After executing the code, the table is created but no data is inserted. The strange thing is when I leave the create table statement out of the connection.php and run the code the data is inserted. Any ideas where I'm going wrong? HI every one I have uploaded a web site 2 month ago and It worked well . Since 1 week ago , it shows me this error and I don't know what is the problem . I have completely uploaded my web site again but it hasn't make different . This is the address birjand-niazmandi.com . I have uploaded class.phpmailer.php again but I can't understand what is the problem ? How can I solve it ? thanks Hello guys, I have these lines of code echo $_POST['uteamid']; $iddquery1 = mysql_query("Select Driver_ID from Driver where Driver_Name='".$temp."'"); $result = mysql_fetch_assoc($iddquery1); $idquery2 =mysql_query("Select Driver_ID from Driver where Driver_Name='".$_POST['DriverSubst']."'"); $resultidquery2 = mysql_fetch_assoc($idquery2); $replaceid = $result['Driver_ID']; echo $replaceid; $updatequery2 = "Update Team_Driver SET Driver_ID = '".$resultidquery2['Driver_ID']."' where UTeam_ID='".$_POST['uteamid']."' and Driver_ID='".$replaceid."'"; echo $updatequery2; Output of the query is: 5 1 Update Team_Driver SET Driver_ID = '2' where UTeam_ID='5' and Driver_ID='' Why is that last Driver_ID = null? wen it should be 1..and its echoing 1 right before that line. Any help will be appreciated Im creating a function for executing a system command. The idea is to show the command return. I use pre to show it, so i created a general function iPre that echos a string with that tag. The problem is that this code dont work. function compComando($com) { return escapeshellcmd($com); } function ejecComando($com) { $return = passthru(compComando($com)); if ($return) { return $return; } else { pe(); } } function iPre($txt) { echo '<pre>'; echo $txt; echo '</pre>'; } iPre(ejecComando('dir C:')); But if i call this simple code it works. Why? echo '<pre>'; echo ejecComando('dir C:'); echo '</pre>'; Here its shown well formatted, in the other no. I suppose thats something relating passing the string to the function...? I have the most simple loop ever on this earth an its doin strange things. There are 6 rows in my cache table. I have a query to echo the rows onto the page with a loop. Now Im try to limit the rows returned to 1 row. simples eh. $FetchCacheq = mysql_query("SELECT * FROM cacheInfo LIMIT 1") or die('cache error'); <table width="480" border="0" cellpadding="0" cellspacing="5"> <tr> <td colspan="2" valign="baseline"><strong>Caches you have found</strong></td> </tr> <?php do { ?> <tr> <td width="250" height="31" align="left" valign="middle"><?php echo $row['cacheName'];?></td> <td width="230" align="left" valign="middle"><img src="/images/submit.png" width="20" height="20" /></td> </tr> <?php } while($row = mysql_fetch_assoc($FetchCacheq));?> </table> The problem I have is its showing two rows. Here is the source code from the page <table width="480" border="0" cellpadding="0" cellspacing="5"> <tr> <td colspan="2" valign="baseline"><strong>Caches you have found</strong></td> </tr> <tr> <td width="250" height="31" align="left" valign="middle"></td> <td width="230" align="left" valign="middle"><img src="/images/submit.png" width="20" height="20" /></td> </tr> <tr> <td width="250" height="31" align="left" valign="middle">Your Life in Their Hands</td> <td width="230" align="left" valign="middle"><img src="/images/submit.png" width="20" height="20" /></td> </tr> </table> as you can see one of the rows doesnt even have the cache name in it!!! please help im really confused. When I used Amazon API to capture a product details using the well known code (http://www.chipdir.nl/amazon/aws_signed_request.phps), It made this error, and consequently lots of CPU usage which made my server down. Code: [Select] [14-Mar-2011 20:38:01] PHP Warning: simplexml_load_string() [<a href='function.simplexml-load-string'>function.simplexml-load-string</a>]: uestProcessingTime>0.0009990000000000</RequestProcessingTime></OperationRequest> in /home/laptop/public_html/jewelryaccessories.us/amazon.php on line 52 Line 51 - 60 of amazon.php is Code: [Select] // parse XML $pxml = simplexml_load_string($response); if ($pxml === False) { return False; // no xml } else { return $pxml; } I hope this is in the correct section. My host and I have spent many hours on this and can find no reason for this error Only MSIE creates the problem and it only occurs on the index page on load and on refresh. All other browsers are fine Scenario: on loading in ie 7,8 I get these error messages Error messages Error Log - [Sat Nov 12 23:49:44 2011] [error] [client 60.230.xxx.xx] File does not exist: /hsphere/local/home/MYDOMAIN/MYDOMAIN.com.au/none Transfer Log - 203.26.xxx.xx - - [12/Nov/2011:23:49:00 +0000] "GET /none HTTP/1.1" 302 233 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; InfoPath.1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)" Always followed by ...... 203.26.xxx.xx - - [12/Nov/2011:23:49:00 +0000] "GET /error_page.php HTTP/1.1" 200 13196 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; InfoPath.1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)" Although it calls GET /error_page.php it does not go to the error_page.php but loads the index page without any further errors. Any help is greatly appreciated Cheers Here is my code: // Start MySQL Query for Records $query = "SELECT codes_update_no_join_1b" . "SET orig_code_1 = new_code_1, orig_code_2 = new_code_2" . "WHERE concat(orig_code_1, orig_code_2) = concat(old_code_1, old_code_2)"; $results = mysql_query($query) or die(mysql_error()); // End MySQL Query for Records This query runs perfectly fine when run direct as SQL in phpMyAdmin, but throws this error when running in my script??? Why is this??? Code: [Select] 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 '= new_code_1, orig_code_2 = new_code_2WHERE concat(orig_code_1, orig_c' at line 1 Ok I have this code.. Code: [Select] <?php header("Expires: Thu, 17 May 2001 10:17:17 GMT"); // Date in the past header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header ("Pragma: no-cache"); // HTTP/1.0 session_start(); if (!isset($_SESSION['SESSION'])) require ( "../db_connection.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>User Registration Form</title> </head> <body><center><br /><br /> <form name="registration" method="post" action="/php/user_registration/registered.php"> <table> <tr> <td>First Name:</td> <td><input type="text" name="fname" value="<?php $_SESSION['fname'] ?>" size="30" maxlength="50" /></td> </tr> <tr> <td>Last Name:</td> <td><input type="text" name="lname" value="<?php $_SESSION['lname'] ?>" size="30" maxlength="50" /></td> </tr> <tr> <td>E-Mail Address:</td> <td><input type="text" name="email" value="<?php $_SESSION['email'] ?>" size="30" maxlength="50" /></td> </tr> <tr> <td>Phone:</td> <td><input type="text" name="phone" value="<?php $_SESSION['phone'] ?>" size="30" maxlength="50" /></td> </tr> <tr> <td>City:</td> <td><input type="text" name="city" value="<?php $_SESSION['city'] ?>" size="30" maxlength="50" /></td> </tr> <tr> <td>Status:</td> <td> <select name="status" id="status"> <option>Pls. Select One <option value="single">Single <option value="relationship">In a Relationship <option value="complicated">It's Complicated </select> </td> </tr> <tr> <td>Province:</td> <td><input type="text" name="province" value="<?php $_SESSION['province'] ?>" size="30" maxlength="50" /></td> </tr> <tr> <td>Password:</td> <td><input type="password" name="password" size="30" maxlength="50" /></td> </tr> <tr> <td>Confirm Password:</td> <td><input type="password" name="password2" size="30" maxlength="50" /></td> </tr> <tr> <td> <input type="reset" name="Submit2" value="Reset"></td> <td> <input type="button" name="Submit" value="Submit" onclick="SubmitForm(); return false;" ></td> </tr> </table> </form> </center> </body> </html> I'm not actually doing anything yet up there though I'm having an error on row "province". The error is Quote Undefined index: province in C:\wamp\www\php\user_registration\registration_form.php on line 75 I have tried almost everything and of all the rows I have there, that's the only one I'm having error at. I'm curious why I'm getting that error. Anyone? I have this function I use to simplify things. function search_string( $needle, $haystack ) { if ( preg_match_all( "/$needle/im", $haystack ) || strpos( $haystack, $needle ) ) { return TRUE; } return FALSE; } I keep getting this error in my PHP logs, and it comes in a sequence: [07-Nov-2020 05:34:14 America/Los_Angeles] PHP Warning: preg_match_all(): Unknown modifier 'G' in /home/baser-b/public_html/include/functions.php on line 791 [07-Nov-2020 05:34:14 America/Los_Angeles] PHP Warning: preg_match_all(): Unknown modifier 'g' in /home/baser-b/public_html/include/functions.php on line 791 Meaning, it will come with one with the small g, then three with the big G, then one with the small g, then five with the big G, and so on.... My question is, how can I stop getting this error. It won't show me the functions being called to arrive at this answer, as this is likely an error generated by another function calling this one. I was wondering if anyone knew what to change in the search_string function to stop getting this error, why this error is happening, or why the strange repetitive sequence. Is it someone trying to do a hack? The only variable that would be changeable by a visitor would be the $needle variable, so what could they type that has something to do with 'g' to get this? Anyway, thanks. A friend of mine must of changed something on the site while I was asleep last night and now all the site says when you go to it is: Error Database query error Warning: mail() [function.mail]: SMTP server response: 530 SMTP authentication is required. in C:\xampp\htdocs\inc\utils.inc.php on line 449 I'm not exactly sure what he did since I can't contact him. Can anyone help me fix this? Hi, i'm currently coding a new inbox for my website, but ive got an error which says: 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 'to='NoName' ORDER BY id DESC' at line 1 Im not sure why ive got that as everything seems to be fine :S My Code: $user=$_SESSION['username']; $get_messages = mysql_query("SELECT `id` FROM `inbox` WHERE to='$user' ORDER BY `id` DESC") or die("Error on line 9 - " . mysql_error()); Thanks for any help/advise given.  Warning: mysqli_query() expects parameter 1 to be mysqli, null given in /home/omerbsh/hallofblogs.com/autoTwit/Library/database.php on line 13 Warning: mysqli_error() expects exactly 1 parameter, 0 given in /home/omerbsh/hallofblogs.com/autoTwit/Library/database.php on line 13 Error: The Query:INSERT INTO twitter_profiles VALUES('dfggffg','dgfgfdg','1') Hi all, having a strange problem with my query Its only returning some of my data, and in the format User 1 <br /> <br /> User 2 <br /> <br /> <br /> <br /> Code: [Select] $newmembers = "SELECT * FROM users WHERE linked_user IS NOT NULL ORDER BY datejoined LIMIT 6"; $nmresult = mysql_query($newmembers); while($row = mysql_fetch_array($nmresult)){ echo $row['linked_user']; echo "<br />";} ?> Code: [Select] mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean i get that error with this code: $online_query = $link->simple_query('u_username', 'users', 'u_online=1 AND u_hidden != 1', '0u_username'); while($online_info = $link->fetch_array($online_query)) //THIS LINE THROWS THE ERROR the simple_query function is: function simple_query($fields, $table, $clause, $order) { global $link, $config; if(!empty($clause)) { $clause = "WHERE $clause"; } else { $clause = ''; } if(!empty($order)) { $direction = $order[0]; switch($direction) { case '0': $direction = 'ASC"'; break; case '1': $direction = 'DESC'; break; } $order = substr($order, 1, strlen($order)); $order = "ORDER BY $order $direction"; } $query = mysqli_query($this->link, "SELECT $fields FROM ".TBL_PREFIX."$table $clause $order"); return $query; } when i use a normal query instead of my simple_query function it works fine. it also worked fine before i made the database class. Where am i going wrong? Hello, i have one little problem and can't pass it. Problem is i need to call new sql query inside another query. Am trying to make accordion which will put result of first query($sql) like title and result of second query($sql2) like list of current item. All time am getting error : Quote Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC SQL Server Driver]Connection is busy with results for another hstmt, SQL state S1000 in SQLExecDirect in ..... I know reasone is because i use query inside query so am trying to figure is there any way to bypass it or make it work. Example: Code: [Select] $sql="EXECUTE _PROCEDURE1 '".$date."',''.$code."; $rs=odbc_exec($conn,$sql); if (!$rs){exit("Error in SQL");} while (odbc_fetch_row($rs)){ $id_number=odbc_result($rs,"ID"); $name=odbc_result($rs,"NAME"); echo $id_number.' - '.$name; $sql2="EXECUTE _PROCEDURE2 '".$id_number."',''.$name."; $name=odbc_exec($conn,$sql2); while(odbc_fetch_row($popust)){ $detail = odbc_result($sql2,"DETAILS"); $detail2 = odbc_result($sql2,"DETAILS2"); $detail3 = odbc_result($sql2,"DETAILS3"); echo $detail.' - '.$detail2.' - '.$detail3; } } I hope i explained it well. Thanks. I have following error when i try to enter my student info into the database. ! ) Warning: Header may not contain more than a single header, new line detected. in C:\wamp\www\Student registration\new student registration\newStudentRegistrationFormvalidation.php on line 43 newStudentRegistrationFormvalidation.php <?php $admission_no=$_POST['admission_no']; $admission_date=$_POST['admission_date']; $full_name=$_POST['full_name']; $name_with_initial=$_POST['name_with_initial']; $date_of_birth=$_POST['date_of_birth']; $religion=$_POST['religion']; $address=$_POST['address']; $telephone=$_POST['telephone']; $grade_on_admission=$_POST['grade_on_admission']; $grade_ID=$_POST['grade_ID']; $stream_ID=isset($_POST['stream_ID']) ? $_POST['stream_ID'] :''; $class_ID=$_POST['class_ID']; $student_house=$_POST['student_house']; $password=$_POST['password']; $description_about_st=$_POST['description_about_st']; $payment=$_POST["payment"]; $currentdate=getdate(time()); $year=$currentdate["year"]; //admission number validation $answer=''; $con=mysql_connect("localhost","root",""); mysql_select_db("student_management",$con); $query="SELECT admission_no FROM student_info WHERE student_info.admission_no='$admission_no'"; $result=mysql_query($query); while($row=mysql_fetch_array($result)){ $answer=$row['admission_no'];} if($answer==0) { //line 43 header("location:student registrationDatabase.php?admission_no=".$admission_no."&year=".$year."&admission_date=".$admission_date."&full_name=".$full_name."&name_with_initial=".$name_with_initial."&date_of_birth=".$date_of_birth."&religion=".$religion."&address=".$address."&telephone=".$telephone."&grade_on_admission=".$grade_on_admission."&grade_ID=".$grade_ID."&stream_ID=".$stream_ID."&class_ID=".$class_ID."&student_house=".$student_house."&password=".$password."&description_about_st=".$description_about_st."&payment=".$payment); exit(); }else{ ?> <body> <?php echo "Admission number".$admission_no."This student has been alredy entered to the system ."."<BR>"."<BR>"."<BR>"; echo "<a href='newStudentRegistrationForm.php'>GO to manage student details page</a> "; exit(); }?> studentregistrationDatabase.php <?PHP $admission_no=$_POST['admission_no']; $admission_date=$_POST['admission_date']; $full_name=$_POST['full_name']; $name_with_initials=$_POST['name_with_initial']; $dob=$_POST['date_of_birth']; $religion=$_POST['religion']; //$gender=$_GET['gender']; $address=$_POST['address']; $telephone=$_POST['telephone']; $grade_on_admission=$_POST['grade_on_admission']; $present_grade=$_POST['grade_ID']; $stream=$_POST['stream_ID']; $present_class=$_POST['class_ID']; $student_house=$_POST['student_house']; $password=$_POST['password']; $description_about_st=$_POST['description_about_st']; $payment=$_POST["payment"]; $current=getdate(time()); $year=$current["year"]; $today = date("Y-m-d"); $con=mysql_connect("localhost","root",""); mysql_select_db("student_management",$con); //insert to database $query="select count(*) from student_info where admission_no='$admission_no'"; $result=mysql_query($query); $row=mysql_fetch_array($result); if($row[0]==0) { $query="insert into student_info values(null,'$admission_no','$admission_date','$full_name','$name_with_initials','$dob','$religion','$address','$telephone','$grade_on_admission','$password','$student_house','$description_about_st')"; $result=mysql_query($query); if($stream!=null){ $query="select class_id from class where class.grade_id='$present_grade' and class.class_name='$present_class' and class.stream='$stream'"; }else{ $query="select class_id from class where class.grade_id='$present_grade' and class.class_name='$present_class'"; } $result=mysql_query($query); while($row=mysql_fetch_array($result)){ $class_id=$row['class_id']; } $query="insert into student_class values('$admission_no','$class_id','$year')"; $result=mysql_query($query); if($payment=="2000") { $query="insert into payment_amount values(null,'2000','$today')"; $result=mysql_query($query); $query="SELECT amount_id FROM payment_amount order by amount_id DESC limit 1"; $result=mysql_query($query); while($row = mysql_fetch_array($result)) { $amount_id=$row['amount_id']; } $query="insert into payment values('$admission_no','$amount_id')"; $result=mysql_query($query); }else{ $query="insert into payment_amount values(null,'0','$today')"; $result=mysql_query($query); $query="SELECT amount_id FROM payment_amount order by amount_id DESC limit 1"; $result=mysql_query($query); while($row = mysql_fetch_array($result)) { $amount_id=$row['amount_id']; } $query="insert into payment values('$admission_no','$amount_id')"; $result=mysql_query($query); } header("location:../new student registration-parent details/studentRegistrationParentDetailsForm.php?admission_no=".$admission_no); exit(); } else{ ?> <?php echo "Admission number".$admission_no."This student has been already entered to the system"."<BR>"."<BR>"."<BR>"; echo "<a href='student registration.php'>GO to registration page</a>"; exit(); } ?> Hello all, I am having this very frustrating issue, I am trying to print this query i got from my SQL table. However, If the query returns 10 [1,2,3,4,5,6,7,8,9] results it just prints 5 [2,4,6,8,10] . I have no idea what to do. Code: [Select] <!--Error Reporting Production Only[start]--> <?php error_reporting(E_ALL & ~E_NOTICE); ini_set('display_errors','1'); //Error Reporting Production Only[end]--> //Connect to Database [start]--> require_once 'sqllogin.php'; $db_server = mysql_connect($db_hostname, $db_username, $db_password); if (!$db_server) die("Unable to connect to MySQL: " . mysql_error()); mysql_select_db($db_database) or die("Unable to select database: " . mysql_error()); //Connect to Database [end]--> //Process the search [start]--> //Initialize the search output variable $search_output = ""; $sql_command = "SELECT * FROM `Alpha` WHERE 1"; //See if the posted search field is set and has a value if (isset($_POST['searchquery']) && $_POST['searchquery'] !="") {//IF START 1 //run code if condition is met //Filter the search query user input $searchquery = preg_replace('#[a-z 0-9 A-Z]#i', '', $_POST['searchquery']); // Search Query********************* if($_POST['filter1'] == "All") {//all filter code goes her $sql_command = "SELECT id, lastname, firstname, building, room FROM `Alpha` WHERE firstname LIKE '%$_POST[searchquery]%' OR lastname LIKE '%$_POST[searchquery]%' OR id LIKE '%$_POST[searchquery]%'"; } else if($_POST['filter1'] == "Last Name") {//Last Name filter code goes her $sql_command = "SELECT id, lastname, firstname, building, room FROM `Alpha` WHERE lastname LIKE '%$_POST[searchquery]%'"; } else if($_POST['filter1'] == "First Name") {//First Name filter code goes her $sql_command = "SELECT id, lastname, firstname, building, room FROM `Alpha` WHERE firstname LIKE '%$_POST[searchquery]%'"; } else if($_POST['filter1'] == "First Name") {//ID filter code goes her $sql_command = "SELECT id, lastname, firstname, building, room FROM `Alpha` WHERE id LIKE '%$_POST[searchquery]%'"; } }//IF END 1 $query = mysql_query($sql_command) or die(mysql_error()); $count = mysql_num_rows($query); if ($count>0) { $search_output.= "<hr /> $count results for <strong>$_POST[searchquery]</strong><hr /> $sql_command <hr />**IF**POST = $_POST[searchquery] Count=$count, Query= $query<hr />"; /*for ($j = 0 ; $j < $rows ; ++$j) { $id = $row["id"]; $lastname = $row["lastname"]; $firstname = $row["firstname"]; $building = $row["building"]; $room = $row["room"]; $search_output .= "$id \t $firstname \t\t $lastname \t\t $building \t$room<br />"; } *************** Can be used instead but not here try putting it where $search_output is echo 'ID: ' . $row[0] . '<br />'; echo 'Last Name: ' . $row[1] . '<br />'; echo 'First Name: ' . $row[2] . '<br />'; echo 'Building: ' . $row[3] . '<br />'; echo 'Room: ' . $row[4] . '<br /><br />'; *********************** */ while($row = mysql_fetch_array($query)) { $row = mysql_fetch_array($query); $id = $row[0]; $lastname=$row[1]; $firstname=$row[2]; $building=$row[3]; $room=$row[4]; $search_output .= "$id $firstname $lastname $building $room<br />"; } } else { $search_output ="<hr /> 0 results for <strong>$searchquery</strong><hr /> $sql_command <hr />****ELSE**POST = $_POST[searchquery] Count=$count, Query= $query<hr /" ; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>MC Reslife WEB APP Developed by; JB</title> <link href="styles.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="Header">Monroe College Resident's Life Web App</div> <div id="Page"> <div id="Menu"> <h1>Search</h1> <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="POST"> <input name="searchquery" type="text" maxlength="19" size="19"/> <input name="myBTN" type="submit" /> <br /> Search By: <select name="filter1"> <option value="All">All</option> <option value="Last Name">Last Name</option> <option value="First Name">First Name</option> <option value="ID Number">ID Number</option> </select> </form> <hr /> <h1>Menu</h1> <p><a href="#">Alpha List</a></p> <p><a href="#">Lock Out Log</a></p> <p><a href="#">Current Probations</a></p> </div> <div id="Content"> <h1>Alpha List</h1> <?php echo $search_output; ?> <p>*************************</p> <?php echo "this is what in post $_POST[searchquery]"?> </div> </div> <div id="Footer">Content for id "Footer" Goes Here</div> </body> </html> please help me Hi all !,
I am stuck on the following piece of code which does not give an error nor does it give a result. ( i.e. it gives 0 num_rows which should be > 1).
If, however, I execute the query in phpmyadmin by simply substituting the values of $pp,$ll and $room_no in the query it gives the correct result.
Please can someone tell me what I may be doing wrong here. Thanks !
$fcon = mysqli_connect($db_host,$db_user,$db_pass,$db_database) or die('Unable to establish a DB connection'); $pp = "(ms.level = 'Beginner' || ms.level = 'Intermediate')"; $ll = 'ms.diff <= 7'; $room_no = 4; $query = "SELECT md.Member_reg_id, md.fname, md.lname, md.email, md.cell, ms.level, ms.diff, ms.score, r.ID_Status FROM register as r JOIN member_detail as md ON r.ID = md.Member_reg_id JOIN memstatus as ms On r.ID = ms.ID WHERE r.CENTERCODE = ? AND r.ID_Status ='A' AND ? AND ? ORDER by level, diff, score DESC"; $stmt=$fcon->prepare($query); $stmt->bind_param('iss',$room_no,$pp,$ll); if(!$stmt->execute()) die('Failed to execute the query'.$fcon->error); else { echo "Executed"; $stmt->bind_result($Member_reg_id,$fname,$lname,$email,$cell,$level,$diff ,$score,$ID_Status); $numrows = $stmt->num_rows; $stmt->store_result(); // echo $numrows; while($stmt->fetch()) { echo "<br>".$fname.' '.$lname; echo "<br>".$level; echo "<br>".$diff; echo "<br>".$score; echo "<br>".$cell; echo "<br>".$email; } } Edited by ajoo, 03 January 2015 - 08:00 AM. |