Avatar of jerrrrry
jerrrrry

asked on 

php sql variable database extracting data question

hello i have a variable
$show that is 'img/affiche1.gif'
i want to extract all the data in my database where the field image is egal to this variable

i got this error using the code i give u

Notice: Undefined variable: sql in C:\wamp\www\print.php on line 108
Erreur SQL !Unknown column 'img' in 'where clause'

//////////////////////////////// sql creation table

CREATE TABLE IF NOT EXISTS `image` (
  `cat` int(11) unsigned NOT NULL DEFAULT '0',
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `s_cat` int(10) unsigned NOT NULL,
  `chemin` varchar(100) NOT NULL,
  `image` varchar(60) NOT NULL,
  `movie` varchar(80) NOT NULL,
  `name` varchar(30) NOT NULL DEFAULT '',
  `infos-fr` text NOT NULL,
  `infos-en` text NOT NULL,
  PRIMARY KEY (`id`),
  KEY `cat` (`cat`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=53 ;

////////////////////////////////////////////// DATA
INSERT INTO `image` (`cat`, `id`, `s_cat`, `chemin`, `image`, `movie`, `name`, `infos-fr`, `infos-en`) VALUES
(1, 1, 1, '/img/imagette_10.gif', 'img/affiche1.gif', '', '', 'fr text ', 'en text '),
(1, 2, 1, '/img/imagette_logo1.gif', 'http://www.test.com', '', '', 'logo pour un laboratoire d''analyses médicales', 'logo for an analysis laboratory '),
(1, 3, 1, '/img/imagette_logo2.gif', '', '', '', 'projet pour une ONG ', 'project for an NGO'),
(1, 4, 2, '/img/imagette_affiche1.gif', '/img/affiche1.gif', '', '', 'carte postale pour un animateur en pâte à modeler', 'postcard for an animator'),
(1, 5, 2, '/img/imagette_affiche2.jpg', '', '', '', 'Concours Chaumont non au réchauffement climatique.', 'Chaumont stop global warming'),
(1, 6, 2, '/img/imagette_affiche3.gif', '', '', '', 'affiche publicitaire', 'board ');

thanks

<?php
if ($_GET['show'] == '') $show = 0;
	else $show = $_GET['show'];

if ($show != '0') {
   echo "<p id='info'>test</p>";
	echo $show;   
    $requete3 = mysql_query('SELECT *  FROM image WHERE image= '.$show.' ')OR die('Erreur SQL !'.$sql.''.mysql_error());

	while($resultat = mysql_fetch_assoc($requete3))
     { echo $resultat['chemin'];
	 } }
     else 
	 {echo "<p id='info'>on n'est pas sur l'affichage spécifique d'image</p>";
	
	 	 }

Open in new window

PHPMySQL ServerDatabases

Avatar of undefined
Last Comment
jerrrrry

8/22/2022 - Mon