Jump to content

sashi34u

Members
  • Posts

    21
  • Joined

  • Last visited

    Never

Everything posted by sashi34u

  1. Dear All, I am using WAMPSERVER 2.0 .I have developed a web based interactive application using PHP and MySQL. I wrote the code in a notepad and saved it with a .php extension. I have also uploaded some data into MySQL tables using the MySQL console provided by Wampserver. After I start the wampserver the application requires me to fill in the details in a html form to run a search and print the data to the browser. The problem I am facing is, sometimes after I fill in the details and submit the form no values are printed to the browser. This usually happens right after I start the WAMPSERVER. Sometimes I do not see this problem at all. I have my final defense in a couple of days and it would not look good if the application doesnt return any values to the browser. Any kind suggestions in this regard would be of great help. Let me know if you need additional details. Thanks, Sashi
  2. Hi, I have installed WAMPSERVER version WampServer 2.0i [07/11/09] Includes : - Apache 2.2.11 - MySQL 5.1.36 - PHP 5.3.0 I am trying to upload a .csv file onto the mysql server using the folowing command. LOAD DATA INFILE 'C:\\Documents and Settings\\Sashikanth Gurram\\Desktop\\courses\\Web_Application\\occupancy.csv' INTO TABLE OCCUPANCY FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n'; When I am using this command, I am getting the error as follows ERROR 1062 (23000): Duplicate entry 'P12N-January-Monday-8:00' for key 'PRIMARY' Can you please let me know what the problem is? I have used the same file previously in my VISTA OS and it worked fine then. I am currently using it in my XP OS and now I am facing this problem. Can you please let me know what the problem is? Thanks, Sashi
  3. Hi, I have been trying to use an inner join and outer join command at a time in a query. But, It is not working properly. I believe that my syntax is wrong. Can anyone please help me in this matter. I am posting the query below. Actually this query is being used in PHP. So please ignore the variables. To explain a little bit, the table IMAGE does not have entries to all the building codes in the table Buildings. That is the reason I wanted to use an outer join. Thanks, Sashi SELECT Location FROM Image LEFT JOIN Buildings ON Image.bldcode=Buildings.BuildingCode buildingname, parking_lot_name, (FS+COM+RES+FS_COM+VISITOR+GEN) AS total_spaces, (TIMED+METER) AS Metered, empty_spaces, distance, round(distance/($low_speed*60),1) AS low_time, round(distance/($high_speed*60),1) AS high_time FROM buildings, buildings_lots, parkinglots, occupancy where ( buildings.buildingcode=buildings_lots.building_code AND parkinglots.parking_lot_code=buildings_lots.parking_lot_code AND parkinglots.parking_lot_code=occupancy.parking_lot) AND buildingname='$build' AND month='$Month' AND day='$Today' AND Time='$times' ORDER BY Distance
  4. I have been trying to use the mysqli_fetch_row ($result) command unsuccessfully. I want to retrieve the information row by row and display it on the browser. Can any one please point out the error I have made. I am pasting the code below Thanks, Sashi <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html dir="ltr" xmlns="http://www.w3.org/1999/xhtml"> <!-- #BeginTemplate "master.dwt" --> <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <!-- #BeginEditable "doctitle" --> <title>Home</title> <!-- #EndEditable --> <link href="styles/style2.css" media="screen" rel="stylesheet" title="CSS" type="text/css" /> <style type="text/css"> .style1 { text-align: right; } </style> </head> <body> <!-- Begin Container --> <div id="container"> <!-- Begin Masthead --> <div id="masthead"> <img alt="" height="118" src="images/parking_lot_1.jpg" width="391" /><h1 class="style1"> </h1> <h1 class="style1">Parking Lot Information</h1> </div> <!-- End Masthead --> <!-- Begin Navigation --> <div id="navigation"> <ul> <li><a href="default.html">Home</a></li> <li><a href="about/about.htm">Background</a></li> <li><a href="news/news.htm">About</a></li> <li><a href="products/products.htm">Visitor Information</a></li> <li><a href="services/services.htm">Links</a></li> <li><a href="contact/contact.htm">Contact</a></li> </ul> </div> <!-- End Navigation --> <!-- Begin Page Content --> <div id="page_content"> <form name= "Criteria_select" action="default.php" method="post"> <br> <div align="center"> <select name="criteria"> <option value=""> Select the Criteria</option> <option value="Distance">Distance</option> <option value="Empty spaces">Empty spaces</option> </form> <form name= "Records" action="default.php" method="post"> <br> <div align="center"> <select name="records"> <option value=""> Select the Number of records you want to fetch</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> </form> <br/> <form name= "building_select" action="default.php" method="post"> <br> <div align="center"> <select name="name"> <option value=""> Select a Building</option> <option value="Agnew Hall">Agnew Hall</option> <option value="Air Conditioning Facility">Air Conditioning Facility</option> <option value="Ambler Johnston Hall">Ambler Johnston Hall</option> <option value="Architecture Annex">Architecture Annex</option> <option value="Armory">Armory</option> <option value="Art and Design Learning Center">Art and Design Learning Center</option> <option value="Barringer Hall">Barringer Hall</option> <option value="Bio informatics phase I">Bio informatics phase I</option> <option value="Bio informatics phase II">Bio informatics phase II</option> <option value="Bishop-Favrao Hall">Bishop-Favrao Hall</option> <option value="Brodie Hall">Brodie Hall</option> <option value="Building 270F">Building 270F</option> <option value="Burchard Hall">Burchard Hall</option> <option value="Burke Johnston Student Center">Burke Johnston Student Center</option> <option value="Burrows/Burleson Tennis Center">Burrows/Burleson Tennis Center</option> <option value="Burruss Hall">Burruss Hall</option> <option value="Campbell Hall">Campbell Hall</option> <option value="Cassell Coliseum">Cassell Coliseum</option> <option value="Central Stores">Central Stores</option> <option value="Cheatham Hall">Cheatham Hall</option> <option value="Chemistry/Physics Building">Chemistry/Physics Building</option> <option value="Cochrane Hall">Cochrane Hall</option> <option value="College of Science Admin. Bldg.">College of Science Admin. Bldg.</option> <option value="Cowgill Hall">Cowgill Hall</option> <option value="Cranwell International Center">Cranwell International Center</option> <option value="Dairy Science Complex">Dairy Science Complex</option> <option value="Davidson Hall">Davidson Hall</option> <option value="Derring Hall">Derring Hall</option> <option value="Dietrick Hall">Dietrick Hall</option> <option value="Durham Hall">Durham Hall</option> <option value="Eggleston Hall">Eggleston Hall</option> <option value="Engel Hall">Engel Hall</option> <option value="English Field">English Field</option> <option value="Femoyer Hall">Femoyer Hall</option> <option value="Fleet Services">Fleet Services</option> <option value="Food Science and Technology">Food Science and Technology</option> <option value="Fralin Biotechnology Center">Fralin Biotechnology Center</option> <option value="Golf Course Clubhouse">Golf Course Clubhouse</option> <option value="Graduate Life Center at Donaldson Brown">Graduate Life Center at Donaldson Brown</option> <option value="Greenhouses">Greenhouses</option> <option value="Hahn Hall">Hahn Hall</option> <option value="Hahn Horticulture Gardens">Hahn Horticulture Gardens</option> <option value="Hancock Hall">Hancock Hall</option> <option value="Harper Hall">Harper Hall</option> <option value="Harry T.Peters Large Animal Hospital">Harry T.Peters Large Animal Hospital</option> <option value="Health and Safety Building">Health and Safety Building</option> <option value="Henderson Hall">Henderson Hall</option> <option value="Hillcrest Hall">Hillcrest Hall</option> <option value="Holden Hall">Holden Hall</option> <option value="Holtzman Alumni Center">Holtzman Alumni Center</option> <option value="Hutcheson Hall">Hutcheson Hall</option> <option value="Institute of Critical Technology and Applied Science">Institute of Critical Technology and Applied Science</option> <option value="Jamerson Athletic Center">Jamerson Athletic Center</option> <option value="Johnson Hall">Johnson Hall</option> <option value="Lane Hall">Lane Hall</option> <option value="Lane Stadium/Worsham Field">Lane Stadium/Worsham Field</option> <option value="Latham Hall">Latham Hall</option> <option value="Lee Hall">Lee Hall</option> <option value="Life Sciences I">Life Sciences I</option> <option value="Litton-Reaves Hall">Litton-Reaves Hall</option> <option value="Major Williams Hall">Major Williams Hall</option> <option value="McBryde Hall">McBryde Hall</option> <option value="McComas Hall">McComas Hall</option> <option value="Media Annex">Media Annex</option> <option value="Media Building">Media Building</option> <option value="Merryman Athletic Center">Merryman Athletic Center</option> <option value="Miles Hall">Miles Hall</option> <option value="Military Building">Military Building</option> <option value="Monteith Hall">Monteith Hall</option> <option value="New Residence Hall-Career Services Site">New Residence Hall-Career Services Site</option> <option value="New Residence Hall-East">New Residence Hall-East</option> <option value="Newman Hall">Newman Hall</option> <option value="Newman Library">Newman Library</option> <option value="Norris Hall">Norris Hall</option> <option value="O’Shaughnessy Hall">O’Shaughnessy Hall</option> <option value="Old Security Building">Old Security Building</option> <option value="Owens Hall">Owens Hall</option> <option value="Pamplin Hall">Pamplin Hall</option> <option value="Parking Services">Parking Services</option> <option value="Patton Hall">Patton Hall</option> <option value="Payne Hall">Payne Hall</option> <option value="Peddrew-Yates Residence Hall">Peddrew-Yates Residence Hall</option> <option value="Performing Arts Building">Performing Arts Building</option> <option value="Power Plant">Power Plant</option> <option value="Price Hall">Price Hall</option> <option value="Pritchard Hall">Pritchard Hall</option> <option value="Randolph Hall">Randolph Hall</option> <option value="Rasche Hall">Rasche Hall</option> <option value="Rector Field House">Rector Field House</option> <option value="Richard B. Talbot Educational Resources Center">Richard B. Talbot Educational Resources Center</option> <option value="Robeson Hall">Robeson Hall</option> <option value="Sandy Hall">Sandy Hall</option> <option value="Saunders hall">Saunders hall</option> <option value="Seitz Hall">Seitz Hall</option> <option value="Shanks Hall">Shanks Hall</option> <option value="Shultz Hall">Shultz Hall</option> <option value="Skelton Conference Center">Skelton Conference Center</option> <option value="Slusher Hall">Slusher Hall</option> <option value="Smith Career Center">Smith Career Center</option> <option value="Smyth Hall">Smyth Hall</option> <option value="Solitude">Solitude</option> <option value="Southgate Center">Southgate Center</option> <option value="Squires Student Center">Squires Student Center</option> <option value="Sterrett Facilities Complex">Sterrett Facilities Complex</option> <option value="Student Services Building">Student Services Building</option> <option value="Surge Space Building">Surge Space Building</option> <option value="The Grove">The Grove</option> <option value="The Inn at Virginia Tech">The Inn at Virginia Tech</option> <option value="Thomas Hall">Thomas Hall</option> <option value="Torgersen Hall">Torgersen Hall</option> <option value="University Bookstore">University Bookstore</option> <option value="University Club">University Club</option> <option value="Vawter Hall">Vawter Hall</option> <option value="Virginia-Maryland Regional College of Veterinary Medicine">Virginia-Maryland Regional College of Veterinary Medicine</option> <option value="Visitor Information Center">Visitor Information Center</option> <option value="Wallace Annex">Wallace Annex</option> <option value="Wallace Hall">Wallace Hall</option> <option value="War Memorial Chapel">War Memorial Chapel</option> <option value="War Memorial Hall">War Memorial Hall</option> <option value="Whittemore Hall">Whittemore Hall</option> <option value="William E. Lavery Health Research Center">William E. Lavery Health Research Center</option> <option value="Williams Hall">Williams Hall</option> <option value="Women's Softball Field">Women's Softball Field</option> <option value="Wright House">Wright House</option> </select> </form> <input type="submit" value="Submit" /> <br> <?php // Connects to your Database $host="*****"; $user="*****"; $password="*****"; $dbname="*****"; $cxn=mysqli_connect($host, $user, $password, $dbname) ; if (!$cxn=mysqli_connect($host, $user, $password, $dbname)) { $error=mysqli_error($cxn); echo "$error"; die(); } //Define the variables for Day and Month $criteria=$_POST["criteria"]; $build=$_POST["name"]; $records=$_POST["records"]; $i=0; $Today=date("l"); $Month=date("F"); $low_speed=2.5; $high_speed=4; $hour=date("G"); $minute=date("i"); if ($minute>=00 && $minute<=14) { $minute=00; } elseif ($minute>=15 && $minute<=29) { $minute=15; } elseif ($minute>=30 && $minute<=44) { $minute=30; } else { $minute=45; } $times="$hour:$minute"; echo $criteria; if ($criteria=="Distance") { $sql="SELECT buildingname, parking_lot_name, (FS+COM+RES+FS_COM+VISITOR+GEN) AS total_spaces, (TIMED+METER) AS Metered, empty_spaces, distance, round(distance/($low_speed*60),1) AS low_time, round(distance/($high_speed*60),1) AS high_time, Location FROM buildings, buildings_lots, parkinglots, occupancy, Image where (buildings.buildingcode=occupancy.building AND buildings.buildingcode=buildings_lots.building_code AND parkinglots.parking_lot_code=buildings_lots.parking_lot_code AND parkinglots.parking_lot_code=occupancy.parking_lot AND Buildings.BuildingCode=Image.BuildingCode) AND buildingname='$build' AND month='$Month' AND day='$Today' AND Time='$times' ORDER BY DESC Distance"; $data = mysqli_query($cxn,$sql); if (!$data==mysqli_query($cxn,$sql)) { $error=mysqli_error($cxn); echo "$error"; die(); } echo "<br>"; echo "<table border='1' cellspacing='5' cellpadding='2'>"; echo "<tr>\n <th>Building</th>\n <th>Parking Lot</th>\n <th>Total Spaces</th>\n <th>Metered Spaces</th>\n <th>Estimated Number of Empty Spaces</th>\n <th>Distance (Feet)</th>\n <th>Estimated walking time to the building</th>\n </tr>\n"; While ($i<$records) { $row=mysqli_fetch_row($data); $building = $row[0]; $parking_lot = $row[1]; $total_spaces = $row[2]; $Metered = $row[3]; $Number_of_Empty_Spaces = $row[4]; $Distance = $row[5]; $time_l = $row[6]; $time_h=$row[7]; $location=$row[8]; echo "<tr>\n <td>$building</td>\n <td>$parking_lot</td>\n <td>$total_spaces</td>\n <td>$Metered</td>\n <td>$Number_of_Empty_Spaces</td>\n <td>$Distance</td>\n <td>$time_h - $time_l mins</td>\n </tr>\n"; $i++; } /* while ($row=mysqli_fetch_array($data)) { extract($row); $building = $row[0]; $parking_lot = $row[1]; $total_spaces = $row[2]; $Metered = $row[3]; $Number_of_Empty_Spaces = $row[4]; $Distance = $row[5]; $time_l = $row[6]; $time_h=$row[7]; $location=$row[8]; echo "<tr>\n <td>$building</td>\n <td>$parking_lot</td>\n <td>$total_spaces</td>\n <td>$Metered</td>\n <td>$Number_of_Empty_Spaces</td>\n <td>$Distance</td>\n <td>$time_h - $time_l mins</td>\n </tr>\n"; } */ echo "</table>\n"; echo "</p>\n"; echo '<img src="imgtest.php?id=' . $building . '" border="5" alt="' . $build . '">'; } elseif ($criteria=="Empty spaces") { $sql="SELECT buildingname, parking_lot_name, (FS+COM+RES+FS_COM+VISITOR+GEN) AS total_spaces, (TIMED+METER) AS Metered, empty_spaces, distance, round(distance/($low_speed*60),1) AS low_time, round(distance/($high_speed*60),1) AS high_time, Location FROM buildings, buildings_lots, parkinglots, occupancy, Image where (buildings.buildingcode=occupancy.building AND buildings.buildingcode=buildings_lots.building_code AND parkinglots.parking_lot_code=buildings_lots.parking_lot_code AND parkinglots.parking_lot_code=occupancy.parking_lot AND Buildings.BuildingCode=Image.BuildingCode) AND buildingname='$build' AND month='$Month' AND day='$Today' AND Time='$times' ORDER BY DESC empty_spaces"; $data = mysqli_query($cxn,$sql); if (!$data=mysqli_query($cxn,$sql)) { $error=mysqli_error($cxn); echo "$error"; die(); } echo "<br>"; echo "<table border='1' cellspacing='5' cellpadding='2'>"; echo "<tr>\n <th>Building</th>\n <th>Parking Lot</th>\n <th>Total Spaces</th>\n <th>Metered Spaces</th>\n <th>Estimated Number of Empty Spaces</th>\n <th>Distance (Feet)</th>\n <th>Estimated walking time to the building</th>\n </tr>\n"; While ($i<$records) { $row=mysqli_fetch_row($data); $building = $row[0]; $parking_lot = $row[1]; $total_spaces = $row[2]; $Metered = $row[3]; $Number_of_Empty_Spaces = $row[4]; $Distance = $row[5]; $time_l = $row[6]; $time_h=$row[7]; $location=$row[8]; echo "<tr>\n <td>$building</td>\n <td>$parking_lot</td>\n <td>$total_spaces</td>\n <td>$Metered</td>\n <td>$Number_of_Empty_Spaces</td>\n <td>$Distance</td>\n <td>$time_h - $time_l mins</td>\n </tr>\n"; $i++; } /* while ($row=mysqli_fetch_array($data)) { extract($row); $building = $row[0]; $parking_lot = $row[1]; $total_spaces = $row[2]; $Metered = $row[3]; $Number_of_Empty_Spaces = $row[4]; $Distance = $row[5]; $time_l = $row[6]; $time_h=$row[7]; $location=$row[8]; echo "<tr>\n <td>$building</td>\n <td>$parking_lot</td>\n <td>$total_spaces</td>\n <td>$Metered</td>\n <td>$Number_of_Empty_Spaces</td>\n <td>$Distance</td>\n <td>$time_h - $time_l mins</td>\n </tr>\n"; } */ echo "</table>\n"; echo "</p>\n"; echo '<img src="imgtest.php?id=' . $building . '" border="5" alt="' . $build . '">'; } else { $sql="SELECT buildingname, parking_lot_name, (FS+COM+RES+FS_COM+VISITOR+GEN) AS total_spaces, (TIMED+METER) AS Metered, empty_spaces, distance, round(distance/($low_speed*60),1) AS low_time, round(distance/($high_speed*60),1) AS high_time, Location FROM buildings, buildings_lots, parkinglots, occupancy, Image where (buildings.buildingcode=occupancy.building AND buildings.buildingcode=buildings_lots.building_code AND parkinglots.parking_lot_code=buildings_lots.parking_lot_code AND parkinglots.parking_lot_code=occupancy.parking_lot AND Buildings.BuildingCode=Image.BuildingCode) AND buildingname='$build' AND month='$Month' AND day='$Today' AND Time='$times'"; $data = mysqli_query($cxn,$sql); if (!$data=mysqli_query($cxn,$sql)) { $error=mysqli_error($cxn); echo "$error"; die(); } echo "<br>"; echo "<table border='1' cellspacing='5' cellpadding='2'>"; echo "<tr>\n <th>Building</th>\n <th>Parking Lot</th>\n <th>Total Spaces</th>\n <th>Metered Spaces</th>\n <th>Estimated Number of Empty Spaces</th>\n <th>Distance (Feet)</th>\n <th>Estimated walking time to the building</th>\n </tr>\n"; While ($i<$records) { $row=mysqli_fetch_row($data); $building = $row[0]; $parking_lot = $row[1]; $total_spaces = $row[2]; $Metered = $row[3]; $Number_of_Empty_Spaces = $row[4]; $Distance = $row[5]; $time_l = $row[6]; $time_h=$row[7]; $location=$row[8]; echo "<tr>\n <td>$building</td>\n <td>$parking_lot</td>\n <td>$total_spaces</td>\n <td>$Metered</td>\n <td>$Number_of_Empty_Spaces</td>\n <td>$Distance</td>\n <td>$time_h - $time_l mins</td>\n </tr>\n"; $i++; } /* while ($row=mysqli_fetch_array($data)) { extract($row); $building = $row[0]; $parking_lot = $row[1]; $total_spaces = $row[2]; $Metered = $row[3]; $Number_of_Empty_Spaces = $row[4]; $Distance = $row[5]; $time_l = $row[6]; $time_h=$row[7]; $location=$row[8]; echo "<tr>\n <td>$building</td>\n <td>$parking_lot</td>\n <td>$total_spaces</td>\n <td>$Metered</td>\n <td>$Number_of_Empty_Spaces</td>\n <td>$Distance</td>\n <td>$time_h - $time_l mins</td>\n </tr>\n"; } */ echo "</table>\n"; echo "</p>\n"; echo '<img src="imgtest.php?id=' . $building . '" border="5" alt="' . $build . '">'; } ?> </div> </div> <!-- End Page Content --> <!-- Begin Footer --> <div id="footer"> <p><a href="default.html">Home</a> | <a href="about/about.htm">Background</a> | <a href="calendar/calendar.htm">About</a> | <a href="contact/contact.htm">Visitor Information</a> | <a href="employees/employees.htm">Links</a> | <a href="employment/employment.htm">Contact</a> </p> </div> <!-- End Footer --></div> <!-- End Container --> </body> <!-- #EndTemplate --> </html>
  5. I am just trying to display the pic as it is without any modifications. I am retrieving the location of the image into a variable and then using the tha varibale wherever it is necessary. The main problem with what you have suggested is(of creating 2 files), I am designing this application as a user input application and I will need the user input to run the query and get the image location (As well as a table of results). So I will be definitely needing a HTML form to input the data. Any suggestions on how it can be done? Thanks, Sashi
  6. Dear all, I have been trying to retrieve the location of a image from database and display the image in the browser using PHP. I have written a sort of code for the purpose. All I am getting in my browser after using the code is a long set of ASCII characters with the following warning *Warning*: Cannot modify header information - headers already sent by (output started at C:\wamp\www\mysqli.php:65) in *C:\wamp\www\mysqli.php* on line *237 * I am herewith attaching my code. If anyone can point out the error or give some kind of advice that would be really great. The location of the image is stored in a table by the name IMAGE under the column name Location and here in the code, the location is retrieved under the varibale name $Location. I have already looked through the Header errors sticky. But I cannot think of anyway in which I can change my code as of now to remove the warning. I have posted this question in the db forum, but it did not clear my doubts. Any help would be greatly appreciated thanks, Sashi <html> <body> <form action="mysqli.php" method="post"> <br> <div align="center"> Building Name:<select name="name"> <option value=""> Select a Building</option> <option value="Agnew Hall">Agnew Hall</option> <option value="Rector Field House">Rector Field House</option> <option value="Richard B. Talbot Educational Resources Center">Richard B. Talbot Educational Resources Center</option> <option value="Robeson Hall">Robeson Hall</option> <option value="Sandy Hall">Sandy Hall</option> <option value="Saunders hall">Saunders hall</option> <option value="Seitz Hall">Seitz Hall</option> <option value="Shanks Hall">Shanks Hall</option> <option value="Shultz Hall">Shultz Hall</option> <option value="Skelton Conference Center">Skelton Conference Center</option> <option value="Williams Hall">Williams Hall</option> <option value="Women's Softball Field">Women's Softball Field</option> <option value="Wright House">Wright House</option> </select> </div> <input type="submit" /> </form> <img src="mysqli.php?"> <?php // Connects to your Database $host="*******"; $user="*****"; $password="******"; $dbname="*******"; $cxn=mysqli_connect($host, $user, $password, $dbname) ; if (!$cxn=mysqli_connect($host, $user, $password, $dbname)) { $error=mysqli_error($cxn); echo "$error"; die(); } else { echo "Connection established successfully"; } //Define the variables for Day and Month $Today=date("l"); $Month=date("F"); $build=$_POST["name"]; $low_speed=2.5; $high_speed=4; $hour=date("G"); $minute=date("i"); if ($minute>=00 && $minute<=14) { $minute=00; } elseif ($minute>=15 && $minute<=29) { $minute=15; } elseif ($minute>=30 && $minute<=44) { $minute=30; } else { $minute=45; } $times="$hour:$minute"; $sql="SELECT buildingname, parking_lot_name, empty_spaces, distance, round(distance/($low_speed*60),1) AS low_time, round(distance/($high_speed*60),1) AS high_time, Location FROM buildings, buildings_lots, parkinglots, occupancy2, Image where (buildings.buildingcode=occupancy2.building AND buildings.buildingcode=buildings_lots.building_code AND parkinglots.parking_lot_code=buildings_lots.parking_lot_code AND parkinglots.parking_lot_code=occupancy2.parking_lot AND Buildings.BuildingCode=Image.BuildingCode) AND buildingname='$build' AND month='$Month' AND day='$Today' AND Time='$times'"; $data = mysqli_query($cxn,$sql); if (!$data=mysqli_query($cxn,$sql)) { $error=mysqli_error($cxn); echo "$error"; die(); } else { echo "<br>"; echo "Query sent successfully"; } echo "<br>"; echo "<h1> PARKING LOT INFORMATION <h1>"; echo "<table border='1' cellspacing='5' cellpadding='2'>"; echo "<tr>\n <th>Building</th>\n <th>Parking Lot</th>\n <th>Estimated Number of Empty Spaces</th>\n <th>Distance (Feet)</th>\n <th>Estimated walking time to the building</th>\n </tr>\n"; while ($row=mysqli_fetch_array($data)) { extract($row); $building = $row[0]; $parking_lot = $row[1]; $Number_of_Empty_Spaces = $row[2]; $Distance = $row[3]; $time_l = $row[4]; $time_h=$row[5]; $location=$row[6]; echo "<tr>\n <td>$building</td>\n <td>$parking_lot</td>\n <td>$Number_of_Empty_Spaces</td>\n <td>$Distance</td>\n <td>$time_h - $time_l mins</td>\n <td>$location</td>\n </tr>\n"; } echo "</table>\n"; $err=1; if ($img = file_get_contents($location, FILE_BINARY)) { if ($img = imagecreatefromstring($img)) $err = 0; } if ($err) { header('Content-Type: text/html'); echo '<html><body><p style="font-size:9px">Error getting image...</p></body></html>'; } else { header('Content-Type: image/jpeg'); imagejpeg($img); imagedestroy($img); } ?> </body> </html>
  7. Hi, I have studied the pages you have suggested. As I understand from the pages, we should not output anything to the browser before the header using the echo function. Is that right? So when I have looked back in the code, I see that the image retrieved is not printed before the header function. So I did not quite understand where the problem is exactly. Also, I have moved the results table part below the image retrieval code(Just to make sure that I haven't output any stuff before the header) But I still get the same problem. I further deleted all the echo statements that are present before the header (like the connection established successfully and query sent successfully statements). I am just posting the new code below to just let you know what I did. What I did may be stupid but please let me know what I could have or should have done. thanks, Sashi <html> <body> <form action="image.php" method="post"> <br> <div align="center"> Building Name:<select name="name"> <option value=""> Select a Building</option> <option value="Agnew Hall">Agnew Hall</option> <option value="Air Conditioning Facility">Air Conditioning Facility</option> <option value="Ambler Johnston Hall">Ambler Johnston Hall</option> <option value="Architecture Annex">Architecture Annex</option> <option value="Armory">Armory</option> <option value="Art and Design Learning Center">Art and Design Learning Center</option> <option value="Barringer Hall">Barringer Hall</option> <option value="Bio informatics phase I">Bio informatics phase I</option> <option value="Bio informatics phase II">Bio informatics phase II</option> <option value="Bishop-Favrao Hall">Bishop-Favrao Hall</option> <option value="Brodie Hall">Brodie Hall</option> <option value="Building 270F">Building 270F</option> <option value="Burchard Hall">Burchard Hall</option> <option value="Burke Johnston Student Center">Burke Johnston Student Center</option> <option value="Burrows/Burleson Tennis Center">Burrows/Burleson Tennis Center</option> <option value="Burruss Hall">Burruss Hall</option> <option value="War Memorial Hall">War Memorial Hall</option> <option value="Whittemore Hall">Whittemore Hall</option> <option value="William E. Lavery Health Research Center">William E. Lavery Health Research Center</option> <option value="Williams Hall">Williams Hall</option> <option value="Women's Softball Field">Women's Softball Field</option> <option value="Wright House">Wright House</option> </select> </div> <input type="submit" /> </form> <img src="image.php?"> <?php // Connects to your Database $host="localhost"; $user="root"; $password="prreddy"; $dbname="VT_VPM"; $cxn=mysqli_connect($host, $user, $password, $dbname) ; if (!$cxn=mysqli_connect($host, $user, $password, $dbname)) { $error=mysqli_error($cxn); echo "$error"; die(); } //Define the variables for Day and Month $Today=date("l"); $Month=date("F"); $build=$_POST["name"]; $low_speed=2.5; $high_speed=4; $hour=date("G"); $minute=date("i"); if ($minute>=00 && $minute<=14) { $minute=00; } elseif ($minute>=15 && $minute<=29) { $minute=15; } elseif ($minute>=30 && $minute<=44) { $minute=30; } else { $minute=45; } $times="10:$minute"; $sql="SELECT buildingname, parking_lot_name, empty_spaces, distance, round(distance/($low_speed*60),1) AS low_time, round(distance/($high_speed*60),1) AS high_time, Location FROM buildings, buildings_lots, parkinglots, occupancy2, Image where (buildings.buildingcode=occupancy2.building AND buildings.buildingcode=buildings_lots.building_code AND parkinglots.parking_lot_code=buildings_lots.parking_lot_code AND parkinglots.parking_lot_code=occupancy2.parking_lot AND Buildings.BuildingCode=Image.BuildingCode) AND buildingname='$build' AND month='$Month' AND day='$Today' AND Time='$times'"; $data = mysqli_query($cxn,$sql); header('Content-Type: text/html'); $err=1; if ($img = file_get_contents($location, FILE_BINARY)) { if ($img = imagecreatefromstring($img)) $err = 0; } if ($err) { echo 'style="font-size:9px">Error getting image...'; } else { header('Content-Type: image/jpeg'); imagejpeg($img); imagedestroy($img); } echo "<br>"; echo "<h1> PARKING LOT INFORMATION <h1>"; echo "<table border='1' cellspacing='5' cellpadding='2'>"; echo "<tr>\n <th>Building</th>\n <th>Parking Lot</th>\n <th>Estimated Number of Empty Spaces</th>\n <th>Distance (Feet)</th>\n <th>Estimated walking time to the building</th>\n </tr>\n"; while ($row=mysqli_fetch_array($data)) { extract($row); $building = $row[0]; $parking_lot = $row[1]; $Number_of_Empty_Spaces = $row[2]; $Distance = $row[3]; $time_l = $row[4]; $time_h=$row[5]; $location=$row[6]; echo "<tr>\n <td>$building</td>\n <td>$parking_lot</td>\n <td>$Number_of_Empty_Spaces</td>\n <td>$Distance</td>\n <td>$time_h - $time_l mins</td>\n <td>$location</td>\n </tr>\n"; } echo "</table>\n"; ?> </body> </html>
  8. Dear all, I have been trying to retrieve the location of a image from database and display the image in the browser using PHP. I have written a sort of code for the purpose. All I am getting in my browser after using the code is a long set of ASCII characters with the following warning *Warning*: Cannot modify header information - headers already sent by (output started at C:\wamp\www\mysqli.php:65) in *C:\wamp\www\mysqli.php* on line *237 * I am herewith attaching my code. If anyone can point out the error or give some kind of advice that would be really great. The location of the image is stored in a table by the name IMAGE under the column name Location and here in the code, the location is retrieved under the varibale name $Location. thanks, Sashi <html> <body> <form action="mysqli.php" method="post"> <br> <div align="center"> Building Name:<select name="name"> <option value=""> Select a Building</option> <option value="Agnew Hall">Agnew Hall</option> <option value="Rector Field House">Rector Field House</option> <option value="Richard B. Talbot Educational Resources Center">Richard B. Talbot Educational Resources Center</option> <option value="Robeson Hall">Robeson Hall</option> <option value="Sandy Hall">Sandy Hall</option> <option value="Saunders hall">Saunders hall</option> <option value="Seitz Hall">Seitz Hall</option> <option value="Shanks Hall">Shanks Hall</option> <option value="Shultz Hall">Shultz Hall</option> <option value="Skelton Conference Center">Skelton Conference Center</option> <option value="Williams Hall">Williams Hall</option> <option value="Women's Softball Field">Women's Softball Field</option> <option value="Wright House">Wright House</option> </select> </div> <input type="submit" /> </form> <img src="mysqli.php?"> <?php // Connects to your Database $host="*******"; $user="*****"; $password="******"; $dbname="*******"; $cxn=mysqli_connect($host, $user, $password, $dbname) ; if (!$cxn=mysqli_connect($host, $user, $password, $dbname)) { $error=mysqli_error($cxn); echo "$error"; die(); } else { echo "Connection established successfully"; } //Define the variables for Day and Month $Today=date("l"); $Month=date("F"); $build=$_POST["name"]; $low_speed=2.5; $high_speed=4; $hour=date("G"); $minute=date("i"); if ($minute>=00 && $minute<=14) { $minute=00; } elseif ($minute>=15 && $minute<=29) { $minute=15; } elseif ($minute>=30 && $minute<=44) { $minute=30; } else { $minute=45; } $times="$hour:$minute"; $sql="SELECT buildingname, parking_lot_name, empty_spaces, distance, round(distance/($low_speed*60),1) AS low_time, round(distance/($high_speed*60),1) AS high_time, Location FROM buildings, buildings_lots, parkinglots, occupancy2, Image where (buildings.buildingcode=occupancy2.building AND buildings.buildingcode=buildings_lots.building_code AND parkinglots.parking_lot_code=buildings_lots.parking_lot_code AND parkinglots.parking_lot_code=occupancy2.parking_lot AND Buildings.BuildingCode=Image.BuildingCode) AND buildingname='$build' AND month='$Month' AND day='$Today' AND Time='$times'"; $data = mysqli_query($cxn,$sql); if (!$data=mysqli_query($cxn,$sql)) { $error=mysqli_error($cxn); echo "$error"; die(); } else { echo "<br>"; echo "Query sent successfully"; } echo "<br>"; echo "<h1> PARKING LOT INFORMATION <h1>"; echo "<table border='1' cellspacing='5' cellpadding='2'>"; echo "<tr>\n <th>Building</th>\n <th>Parking Lot</th>\n <th>Estimated Number of Empty Spaces</th>\n <th>Distance (Feet)</th>\n <th>Estimated walking time to the building</th>\n </tr>\n"; while ($row=mysqli_fetch_array($data)) { extract($row); $building = $row[0]; $parking_lot = $row[1]; $Number_of_Empty_Spaces = $row[2]; $Distance = $row[3]; $time_l = $row[4]; $time_h=$row[5]; $location=$row[6]; echo "<tr>\n <td>$building</td>\n <td>$parking_lot</td>\n <td>$Number_of_Empty_Spaces</td>\n <td>$Distance</td>\n <td>$time_h - $time_l mins</td>\n <td>$location</td>\n </tr>\n"; } echo "</table>\n"; $err=1; if ($img = file_get_contents($location, FILE_BINARY)) { if ($img = imagecreatefromstring($img)) $err = 0; } if ($err) { header('Content-Type: text/html'); echo '<html><body><p style="font-size:9px">Error getting image...</p></body></html>'; } else { header('Content-Type: image/jpeg'); imagejpeg($img); imagedestroy($img); } ?> </body> </html>
  9. Hi corbin, I got the reply from somewhere else. I am posting it here so that you can have a look. Let me know if it makes sense. I did not get any errors. All I see is a page with the heading occupancy and then several vertical cells. But the suggestion pasted below solved the problem. Thanks for all your help. I believe your problem is that the mysqli_fetch_array function on line 39 returns an enumerated array and the extract function on line 41 takes the values in an array and assigns it to an associative array based on the keys. Since the keys in an enumerated array are numbers, those are the variable names. I believe you will have an easier time if you do the following: while ($row=mysqli_fetch_array($data)) { $building = $row[0]; $parking_lot = $row[1]; $month = $row[2]; $day = $row[3]; $occupancy = $row[4]; $empty_spaces = $row[5]; $special_days = $row[6]; echo "<tr>\n <td>$building</td>\n <td>$parking_lot</td>\n <td>$month</td>\n <td>$day</td>\n <td>$occupancy</td>\n <td>$empty_spaces</td>\n <td>$special_days</td>\n </tr>\n"; echo "<tr><td colspan='7'><hr /></td></tr>\n"; } Now it is important in the order with which the fields are returned from the database since that will affect the row values when you are assigning them to variables (ie- if the day is returned first in the array it should be " $day = $row[0]" )
  10. Yes, the column names match perfectly. Print_r would show us the structure and the values present in a database. But I would like to fit the output into a defined. With respect to that, do you see any changes in the code?
  11. Hi all, I am trying to run a query to retrieve data from mysql database and display it in a webpage in a table. The query is running fine, but the the data is not appearing on the webpage. All I see is a webpage with few empty cells. The echo command starting from line 42 is something like this echo "<tr>\n <td>$building</td>\n <td>$parking_lot</td>\n <td>$month</td>\n <td>$day</td>\n <td>$occupancy</td>\n <td>$empty_spaces</td>\n <td>$special_days</td>\n </tr>\n"; The variables I have used here ie., $building, $parking_lot etc are nothing but the column names in the mysql database ie., building, parking_lot etc. I hope I did not mess up in that sense. But, I do not know the reason for the non appearance of the data. I am posting the whole code below. Also I am inserting a screenshot of the display in the webpage. If anyone has any answer please let me know. Thanks Sashi <?php // Connects to your Database $host="********"; $user="*******"; $password="*******"; $dbname="*********"; $cxn=mysqli_connect($host, $user, $password, $dbname) ; if (!$cxn=mysqli_connect($host, $user, $password, $dbname)) { $error=mysqli_error($cxn); echo "$error"; die(); } else { echo "Connection established successfully"; } $sql="SELECT * FROM occupancy"; $data = mysqli_query($cxn,$sql); if (!$data=mysqli_query($cxn,$sql)) { $error=mysqli_error($cxn); echo "$error"; die(); } else { echo "<br>"; echo "Query sent successfully"; } echo "<br>"; echo "<h1> OCCUPANCY <h1>"; echo "<table cellspacing='0'>"; echo "<tr><td colspan='7'><hr /></td></tr>"; while ($row=mysqli_fetch_array($data)) { extract($row); echo "<tr>\n <td>$building</td>\n <td>$parking_lot</td>\n <td>$month</td>\n <td>$day</td>\n <td>$occupancy</td>\n <td>$empty_spaces</td>\n <td>$special_days</td>\n </tr>\n"; echo "<tr><td colspan='7'><hr /></td></tr>\n"; } echo "</table>\n"; ?>
  12. Hi Maq, sorry about the misunderstanding. I was looking at the wrong place. The double quote was indeed missing . Thank you very much -sashi
  13. Hi all, I have pasted the PHP code I wrote below. I do not know why, but I am getting the parse error: unexpected '>'. It says the error is on line 38. The exact line on line 38 is echo"<tr>\n Basically, I am trying to execute an sql query through PHP which tries to extract data from the mysql database and display the data in the browser. The query is running fine but I am getting the problems when I try to display the data in the browser. Can anyone help me with it? Thanks, Sashi <?php /* CONNECTS TO THE DATABASE*/ $host="********"; $user="********"; $password="********"; $dbname="********"; $cxn=mysqli_connect($host, $user, $password, $dbname); if (!$cxn=mysqli_connect($host, $user, $password, $dbname)) { $error=mysqli_error($cxn); echo "$error"; die(); } else { echo "Connection established successfully"; } $sql="select * FROM OCCUPANCY"; $data=mysqli_query($cxn,$sql); if (!$data=mysqli_query($cxn,$sql)) { $error=mysqli_error($cxn); echo "$error"; die(); } else { echo "Query sent successfully"; } echo "<br>"; echo "<html>"; echo "<h1>OCCUPANCY<h1>"; echo "<table cellspacing='5'>"; echo "<tr><td colspan='7'><hr /></td></tr>; while ($row=mysqli_fetch_array($data)) { extract($row); echo"<tr>\n <td>$building</td>\n <td>$parking_lot</td>\n <td>$month</td>\n <td>$day</td>\n <td>$occupancy</td>\n <td>$empty_spaces</td>\n <td>$special_days</td>\n </tr>\n"; echo "<tr><td colspan='7'><hr /></td></tr>\n"; } echo"</table>\n"; echo "</html>"; ?>
  14. Sorry about the confusion. I was actually using '\n'. I just mis typed it in the query box. I am using the Vista operating system, and the file I have used was excel file in the MS_WORD 2007 format. I have saved it as .csv file and used it to upload the data. Forgot to mention one more thing. When I said that 1) Some of the rows have their first letter missing 2)Some of the rows have 2 or more than two letters missing 3) only one row has the full name without missing any thing I was using a .txt file, with a comma between the first column and second column, the 3rd row from the bottom goes in correctly. This particular row has a building code which is not entirely numeric. It has an alphabet in the building code. I do not know if that is causing some issue. I was trying different combinations in .csv and .txt and got mixed up. Sorry about that.
  15. These are some of the lines in the original .csv file Burruss Hall 176 Squires Student Center 180 Student Services Building 192 Torgersen Hall 174 University Bookstore 178 Whittemore Hall 134 Williams Hall 152 Smyth Hall 105 The First part is the building name and the later integer part is the building code.
  16. Hi all, My MySQL version is 5.0.51b I am trying to upload a CSV file using the LOAD DATA INFILE command. The data is getting uploaded, but when I see the data, in the First column 1) Some of the rows have their first letter missing 2)Some of the rows have 2 or more than two letters missing 3) only one row has the full name without missing any thing This is the Code I am using: LOAD DATA INFILE 'C:/Users/Sashikanth/desktop/buildings.csv' INTO TABLE sashi4 FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '/n' (BN, BC); Can anyone please tell me as to what the reason could be?? Thanks, Sashi
  17. Yes you are right....but if I want to install (I will uninstall the WAMP first) the software separately ie., PHP and MySQL separately how do I go about linking them? How can I get the PHP work with MySQL in sync.....like if I write a command in PHP asking to connect to the MySQL server it should be able to connect to the server. Also I have tried to download the APACHE server from the website but I do not know how to download it...can you please guide me through it Thanks, Sashi
  18. Hello everyone, I have installed WAMP server on my PC. Then I have installed the MySQL and PHP software by downloading them from the site. The PHP programs I have written used to work fine but when I tried to connect to the MySQL database or create a new database using the PHP programming nothing happens in the browser. I do not know what happened. After several attempts I finally uninstalled the MySQL and PHP programs and then when I tried to connect to the MySQL usin PHP it worked fine I do not know the reason for this. Can anyone tell me what the reason is? Further more I would like to install PHP and MySQL along with a server like APACHE. But I do not know where to download the APACHE server from. Also When I install PHP and MySQL how do I link PHP and MySQL so that they work in tandem. Would be great if anyone can clear these doubts. I know that these are very basic questions but I am a starter. Thanks, Sashi
×
×
  • 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.