Jump to content

Search a mysql database using a php script and a value from text box


Recommended Posts

Hello

 

I have this script here which is activated when I click on the submit button it gets the value from the text box as it comes up in the error when I click the submit button.

 

<?php

session_start();

if(isset($_SESSION['username']) ==  false){

header("Location: login.php");

exit();

}

 

$roomno = $_GET['roomno'];

 

require "connect.php";

if (isset($_GET['search'])){

$query = "select *  from booking, student, room where booking.RoomNo = room.RoomNo and booking.StudentId = student.StudentId and RoomNo='".$roomno."'";

$result = mysql_query($query, $connection)

or die("Unable to execute query<br>$query");

}

?>

 

I get this error when i click submit:

 

 

Unable to execute query

select * from booking, student, room where booking.RoomNo = room.RoomNo and booking.StudentId = student.StudentId and RoomNo='1'

 

So it is getting the value from the input box but I can't get it to display the data.

 

I think it is a syntax error but I have been trying to work it out for ages but it is really bugging me now

 

Can someone please help asap as I have a tight deadline or anywhere you can direct me that might help

 

Thanks in advance

 

Chris

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.