Why does this not work?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jeaux
Forum Commoner
Posts: 25
Joined: Sun Aug 24, 2008 5:11 pm

Why does this not work?

Post by jeaux »

The MySQL db

Code: Select all

 
-- phpMyAdmin SQL Dump
-- version 3.2.0.1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Sep 06, 2009 at 03:24 PM
-- Server version: 5.1.37
-- PHP Version: 5.3.0
 
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
 
--
-- Database: `cars1`
--
CREATE DATABASE `cars1` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
USE `cars1`;
 
-- --------------------------------------------------------
 
--
-- Table structure for table `additionalcontacts`
--
 
CREATE TABLE IF NOT EXISTS `additionalcontacts` (
  `contactid` int(10) NOT NULL AUTO_INCREMENT,
  `carid` int(10) NOT NULL,
  `firstname` varchar(20) NOT NULL,
  `lastname` varchar(20) NOT NULL,
  `phone` varchar(12) NOT NULL,
  PRIMARY KEY (`contactid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
 
--
-- Dumping data for table `additionalcontacts`
--
 
 
-- --------------------------------------------------------
 
--
-- Table structure for table `cars`
--
 
CREATE TABLE IF NOT EXISTS `cars` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `year` int(4) NOT NULL,
  `make` varchar(15) NOT NULL,
  `model` varchar(20) NOT NULL,
  `firstname` varchar(20) NOT NULL,
  `lastname` varchar(20) NOT NULL,
  `phone` varchar(12) NOT NULL,
  `address` varchar(30) NOT NULL,
  `license` varchar(8) NOT NULL,
  `VIN` varchar(16) NOT NULL,
  `dateofloss` int(11) NOT NULL,
  `status` int(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=79 ;
 
--
-- Dumping data for table `cars`
--
 
INSERT INTO `cars` (`id`, `year`, `make`, `model`, `firstname`, `lastname`, `phone`, `address`, `license`, `VIN`, `dateofloss`, `status`) VALUES
(29, 2007, 'Kia', 'Rio', 'Susan', 'Hohmann', '713', '8330 Lamond', '', '', 0, 1),
(28, 2008, 'Nissan', 'Sentra', 'U', 'Save', '', '', 'HWN-403', '', 0, 0),
(27, 2007, 'Cadillac', 'Escalade', 'Bryan', 'Therfo', '713', '3430 Chambers CIR.', '', '', 0, 1),
(26, 2003, 'Chev.', 'Impala', 'Andrea', 'Tellison', '832', '12070 S. Circle Dr.', '', '', 0, 0),
(25, 2005, 'Chev.', 'Malibu', 'Oscar', 'Martinez', '832', '1950 Eldridge #11305', '', '', 0, 0),
(24, 1993, 'Toyota', 'Camery', 'Michaud', 'Delva', '713', '9900 Richmond Ave. #1616', '', '', 0, 1),
(23, 2002, 'Pontiac', 'G6', 'Marcus', 'York', '832', '2900 S. Guessner', '', '', 0, 0),
(22, 2008, 'Infinity', 'FX35', 'Sharon', '', '', '', '', '', 0, 1),
(21, 2002, 'Chev.', 'Trailblazer', 'Michael', 'Welly', '', '', '', '', 0, 0),
(20, 2007, 'Mitsubishi', 'Galant', 'Joshep', 'Williams', '832', '10440 South Dr. #1712', '', '', 0, 1),
(30, 2007, 'Toyota', 'Avalon', 'Brenda', 'Thomas', '713', '9435 Benning Dr.', '', '', 0, 0),
(31, 2006, 'Ford', 'F-150', 'Olga', 'Conty', '832', '6202 Reims Rd. 316D', '', '', 0, 0),
(32, 2005, 'Mercedez', '500 CLK', 'Roger', 'Ben David', '713', '9006 Mullins', '', '', 0, 0),
(33, 2002, 'Chevy', 'Blazer', 'Brenda', 'Wilson', '713', '', '', '', 0, 0),
(34, 2000, 'Chevy', 'Tahoe', 'Yuval', 'Ohana', '', '5233 Petty St. A', '', '', 0, 0),
(35, 2004, 'Pontiac', 'Grand Pre.', 'Dora', 'Biasley', '832', '5600 W-loop S.', '', '', 0, 0),
(36, 2007, 'Ford', 'Escape XLS', 'Ramon', 'Martinez', '832', '8011 Dairy View Ln.', '', '', 0, 1),
(37, 2000, 'Chev.', 'Blazer', 'Victor', 'Lerma', '832', '', '', '', 0, 1),
(43, 1996, 'Honda', 'Accord', 'Arnaldo ', 'Agosto', '832', '', '', '', 0, 0),
(44, 1996, 'Honda', 'Accord', 'Arnaldo ', 'Agosto', '832', '', '', '', 0, 1),
(45, 2007, 'Pontiac', 'G6', 'Marcus', 'York', '832', '', '', '', 0, 0),
(46, 2007, 'Toyota', 'Scion', 'Kristin ', 'Schmitt', '713', '', '', '', 0, 0),
(47, 2000, 'Nissan', 'X-Terra', 'Nicandro', 'Arellano', '832', '', '', '', 0, 0),
(48, 1999, 'Toyota', 'Camry', 'Jessica', 'Coreas', '832', '', '', '', 0, 0),
(49, 2003, 'Ford', 'Van', 'Best  Care', '', '713', '', '', '', 0, 0),
(50, 2000, 'Chevy.', 'Blazer', 'Victor', 'Lerma ', '832', '', '', '', 2008, 0),
(51, 2008, 'Suba', 'Impreza', 'Natalie', 'Adelman', '713', '', '', '', 0, 0),
(52, 2002, 'VW', 'Golf', 'Jerry', 'Garcia', '832', '', '', '', 0, 0),
(53, 2005, 'BMW', '325i', 'Ron ', 'Shabi', '', '', '', '', 1251172800, 0),
(55, 2005, 'Honda', 'Odyssey', 'Loc', 'Diep', '254', '', '', '', 0, 1),
(56, 2003, 'Mercedez', 'C-230', 'Cindy', 'Mejia', '713', '', '', '', 0, 0),
(57, 2002, 'Cadillac', 'Escalade', 'Pastor', 'Torres', '713', '', '', '', 0, 0),
(58, 2006, 'Ford', 'Taurus', 'Naestor', 'Ramos', '713', '8910 Lugary', '195-KTG', '', 1251518400, 0),
(61, 2003, 'Toyota', 'Camery', 'Robert', 'B', '281', '2322 Shadowdale', 'W69-DPD', '', 1230786000, 0),
(62, 2007, 'Mazda', '5', 'Michael', 'Del Angel', '832', '', '', '', 1250654400, 0),
(63, 2005, 'Nissan', 'Altima', 'Ashely', 'Zimu', '832', '2606 Southmore', 'BTF-508', '', 0, 0),
(74, 2000, 'Pontiac', 'Grand Am GT', 'Henry', 'Emrik', '281', '2111 Holly Hall #1618', '220-WBN', '', 1252036800, 0),
(68, 2002, 'Mercedes', 'ML350', 'Susan', '', '', '', '', '', 1230786000, 1),
(67, 2004, 'Mitsubishi', 'Galant', 'Jesse', 'Cantu', '979', '158 Straight way dr.', '594-LWT', '', 1251172800, 0),
(69, 2002, 'Mercedes', 'ML350', 'Susan', 'Perez', '281', '6035 Parkwood Place', 'BVZ-879', '', 1248840000, 0),
(70, 2007, 'Chevy', '1500', 'Warrick', 'Washington', '713', '', '08MTV7', '', 1250913600, 0),
(71, 2005, 'Ford', 'Focus', 'Oscar ', 'Reyes', '713', '10402 SandPiper #261', 'Y41-NBT', '', 1233205200, 0),
(72, 2006, 'Corvette', '', 'Kiri', 'Keir', '713', '10545 Hammerly #157', 'KL5853', '', 1243569600, 1),
(73, 2007, 'Nissan', '350Z', 'Juan', 'Sosa', '832', '806 Foxborough Ln.', '970-WNC', '', 1252036800, 0),
(78, 2999, 'nbv cn', ' nvcn', 'nbvcn', 'nbvc n', 'nbvcn', 'nbvn', 'nbvn', 'nbv', 0, 0);
 
-- --------------------------------------------------------
 
--
-- Table structure for table `insurance`
--
 
CREATE TABLE IF NOT EXISTS `insurance` (
  `insuranceid` int(10) NOT NULL AUTO_INCREMENT,
  `carid` int(10) NOT NULL,
  `insurancename` varchar(50) NOT NULL,
  `adjustorname` varchar(20) NOT NULL,
  `insurancephone` varchar(12) NOT NULL,
  PRIMARY KEY (`insuranceid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
 
--
-- Dumping data for table `insurance`
--
 
 
-- --------------------------------------------------------
 
--
-- Table structure for table `notes`
--
 
CREATE TABLE IF NOT EXISTS `notes` (
  `noteid` int(10) NOT NULL AUTO_INCREMENT,
  `carid` int(10) NOT NULL,
  `note` varchar(255) NOT NULL,
  `date` date NOT NULL,
  PRIMARY KEY (`noteid`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;
 
--
-- Dumping data for table `notes`
--
 
INSERT INTO `notes` (`noteid`, `carid`, `note`, `date`) VALUES
(1, 1, 'hello world', '2009-08-25'),
(2, 0, 'whatever', '0000-00-00'),
(3, 0, 'whatever', '0000-00-00');
 
-- --------------------------------------------------------
 
--
-- Table structure for table `parts`
--
 
CREATE TABLE IF NOT EXISTS `parts` (
  `partid` int(10) NOT NULL AUTO_INCREMENT,
  `carid` varchar(10) NOT NULL,
  `description` varchar(255) NOT NULL,
  `vendor` varchar(100) NOT NULL,
  `date` datetime NOT NULL,
  `recieved` int(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`partid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
 
--
-- Dumping data for table `parts`
 
 
 
And here's the php

Code: Select all

 
 
<?php
$con = mysql_connect("EXCLUDED DATA");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
 
mysql_select_db("cars1", $con);
 
$result = mysql_query("SELECT * FROM `cars` WHERE `status` = '0' ORDER BY `year` DESC");
//Next 2 line are just to make sure that the array has something in it.
$num_rows = mysql_num_rows($result);
echo "$num_rows Rows\n";
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Admin</title>
</head>
 
<body>
<p><img src="Images/A-1 Banner.jpg"><a href="addcar.html">Add Car</a></p>
 
<table width="900" border="0">
     <tr> <td width="50" align="center" bgcolor="#CC9933">&nbsp;</td>
    <td width="51" align="center" bgcolor="#CC9933"><strong>Year </strong></td>
    <td width="61" align="center" bgcolor="#CC9933"><strong>Make</strong></td>
    <td width="106" align="center" bgcolor="#CC9933"><strong>Model</strong></td>
    <td width="80" align="center" bgcolor="#CC9933"><strong>F Name</strong></td>
    <td width="97" align="center" bgcolor="#CC9933"><strong>L Name</strong></td>
    <td width="108" align="center" bgcolor="#CC9933"><strong>Phone</strong></td>
    <td width="82" align="center" bgcolor="#CC9933"><strong>License</strong></td>
    <td width="80" align="center" bgcolor="#CC9933"><strong>D.O.L</strong></td>
    <td width="65" align="center" bgcolor="#CC9933"><strong>RO</strong></td>
  </tr> 
<?
while($row = mysql_fetch_array($result)){
?>
 <tr>
      <td>
         <form id="form1" name="form1" method="post" action="showcar.php">
<label>
        <input type="hidden" name="carid" value ="
<?
   echo $row['id'];
?>
">
        <input type="submit" name="submit" value="Show">
      </label>
      </form>
      </td>
      <td align="center">     
<?
   echo $row['year'];
?>
     </td>
     <td align="center">
<?
  echo $row['make'];
?>
     </td>
     <td align="center">
<?
  echo $row['model']; 
?>
     </td>
     <td align="center">
<?
  echo $row['firstname'];
?>
     </td>
     <td align="center">
<?
  echo $row['lastname'];
?>
     </td>
     <td align="center">
<?
  echo $row['phone'];
?>
     </td>
     <td align="center">
<?
  echo $row['license'];
?>
     </td>
     <td align="center">
<?
  echo date("m-d-Y", $row['dateofloss']);
?>
     </td>
     <td align="center">
<?
  echo $row['id'];
?>
     </td>
   </tr>
<?     
  }
?>
<?
mysql_close($con);
?> 
 
</body>
</html>
 
Thanks for any help,
Joe
Mark Baker
Forum Regular
Posts: 710
Joined: Thu Oct 30, 2008 6:24 pm

Re: Why does this not work?

Post by Mark Baker »

And what exactly is happening?
jeaux
Forum Commoner
Posts: 25
Joined: Sun Aug 24, 2008 5:11 pm

Re: Why does this not work?

Post by jeaux »

the output of a "view source" has the php code in it.

Code: Select all

 
34 Rows
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Admin</title>
</head>
 
<body>
<p><img src="Images/A-1 Banner.jpg"><a href="addcar.html">Add Car</a></p>
 
<table width="900" border="0">
     <tr> <td width="50" align="center" bgcolor="#CC9933">&nbsp;</td>
 
    <td width="51" align="center" bgcolor="#CC9933"><strong>Year </strong></td>
    <td width="61" align="center" bgcolor="#CC9933"><strong>Make</strong></td>
    <td width="106" align="center" bgcolor="#CC9933"><strong>Model</strong></td>
    <td width="80" align="center" bgcolor="#CC9933"><strong>F Name</strong></td>
    <td width="97" align="center" bgcolor="#CC9933"><strong>L Name</strong></td>
    <td width="108" align="center" bgcolor="#CC9933"><strong>Phone</strong></td>
 
    <td width="82" align="center" bgcolor="#CC9933"><strong>License</strong></td>
    <td width="80" align="center" bgcolor="#CC9933"><strong>D.O.L</strong></td>
    <td width="65" align="center" bgcolor="#CC9933"><strong>RO</strong></td>
  </tr> 
<?
while($row = mysql_fetch_array($result)){
?>
 <tr>
      <td>
         <form id="form1" name="form1" method="post" action="showcar.php">
 
<label>
        <input type="hidden" name="carid" value ="
<?
   echo $row['id'];
?>
">
        <input type="submit" name="submit" value="Show">
      </label>
      </form>
      </td>
      <td align="center">     
<?
   echo $row['year'];
?>
     </td>
     <td align="center">
 
<?
  echo $row['make'];
?>
     </td>
     <td align="center">
<?
  echo $row['model']; 
?>
     </td>
     <td align="center">
<?
  echo $row['firstname'];
?>
     </td>
     <td align="center">
<?
  echo $row['lastname'];
?>
     </td>
 
     <td align="center">
<?
  echo $row['phone'];
?>
     </td>
     <td align="center">
<?
  echo $row['license'];
?>
     </td>
     <td align="center">
<?
  echo date("m-d-Y", $row['dateofloss']);
?>
     </td>
     <td align="center">
 
<?
  echo $row['id'];
?>
     </td>
   </tr>
<?     
  }
?>
<?
mysql_close($con);
?> 
 
</body>
</html>
 
All of the above is straight from firefox>view>page source
User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

Re: Why does this not work?

Post by Darhazer »

Short tags are disabled
Either change all <? to <?php or change the short_open_tag setting in php.ini
jeaux
Forum Commoner
Posts: 25
Joined: Sun Aug 24, 2008 5:11 pm

Re: Why does this not work?

Post by jeaux »

Solved. Many thanks for help with a supernoob prob.
Post Reply