Jump to content

Recommended Posts

Hi,

 

Table is SiteItems

with the following fields :

  id int(11)  Nee  auto_increment             

  klant tinyint(3)  UNSIGNED Ja NULL               

  titel varchar(80) utf8_general_ci  Ja NULL               

  oms text utf8_general_ci  Ja NULL               

  tekst text utf8_general_ci  Ja NULL               

  soort int(11)  Ja NULL               

  timestamp timestamp  ON UPDATE CURRENT_TIMESTAMP Nee CURRENT_TIMESTAMP               

  auteur varchar(50) utf8_general_ci  Ja NULL               

  del tinyint(4)  Ja 0

 

Using MySQL 5.0.32 & PHP 4

 

In my PHP code it says :

$strSQL = "select * from SiteItems where id = " . $id . ";";
$result = mysql_query($strSQL)
     or die("Fout bij uitvoeren query");
$line = mysql_fetch_array($result);

 

after connecting to the DB. Connection goes fine, but then it gives a query error...

The . $id . refers to id 170 in the index.php with :

<?php
header("location: si.php?id=170");
?>

Anyone a suggestion ?

 

 

Link to comment
https://forums.phpfreaks.com/topic/88472-select-from-query-error/
Share on other sites

a) in future, post the query error.  things will go much faster.

 

b) drop the semicolon from the end of the query:

 

$strSQL = "select * from SiteItems where id = " . $id;

 

c) you don't need to exit from double quotes to insert a variable:

 

$strSQL = "select * from SiteItems where id=$id";

The frontpage is showing now, as told before but the content of the DB is not showing.

More specific the content of this field : tekst text utf8_general_ci  Ja NULL

 

any idea ?

This is a site i took over from a company that went bankrupt... and i have no idea how they put it together...

Should i post the complete site in zip or just some codes ??

Hereby the code of the si.php :

<?php
include 'includes/webfunctions.php';
setlocale (LC_ALL, 'nl_NL');
// Verbinding maken, een database selecteren
$link = mysql_connect(DB_Server,DB_Login,DB_Pasword)
     or die("Kan geen verbinding maken");
mysql_select_db(DB_Name)
     or die("Kan geen database selecteren");
$strSQL = "select * from SiteItems where id='$id'";
$result = mysql_query($strSQL)
     or die("Fout bij uitvoeren query");
$line = mysql_fetch_array($result);

Head($line["titel"]);
switch ($line["soort"]) {
Case "1":?>
<table cellpadding="2" cellspacing="0" width="100%">
<tr>
  <td "width=100%"><?php print $line['tekst']?></td>
</tr>
</table>
<?
break;




Case "2": Case"3": Case"5":
$strSQL = "select SiteItems.titel,SiteItems.tekst,lenicoTeKoop.*, lenicoTeKoopProvincie.titel as provincie,lenicoTeKoop.prijsklasse from SiteItems ";
$strSQL.= " LEFT JOIN lenicoTeKoop ON (SiteItems.id=lenicoTeKoop.siteitem) ";
$strSQL.= " LEFT JOIN lenicoTeKoopProvincie ON (lenicoTeKoop.provincie=lenicoTeKoopProvincie.id) ";
//$strSQL.= " LEFT JOIN lenicoTeKoopPrijsKlasse ON (lenicoTeKoop.prijsklasse=lenicoTeKoopPrijsKlasse.id) ";
$strSQL.= " where SiteItems.id = " . $id . ";";
$result = mysql_query($strSQL)
     or die("Fout bij uitvoeren query");
$line = mysql_fetch_array($result);
$oppervlakte = $line["grondopp1"]*100 + $line["grondopp2"];
if ($oppervlakte > 0){
if ($oppervlakte > 9999){
 $oppervlakte = round($oppervlakte/10000,2) ." ha";
}else{
 $oppervlakte = $oppervlakte ." m²";
}
}else{
$oppervlakte="";
}?>
<table cellpadding="0" cellspacing="0" width="100%">
<tr>
<td valign="top">
<?$makelink = 0;
$strSQL = "select id,naam,ext from Resources where id=".$line["foto1"];
$result = mysql_query($strSQL)
     or die("Fout bij uitvoeren query");
$line2 = mysql_fetch_array($result);
if (stristr("gif jpg jpeg png bmp",$line2["ext"])) {
$imageSize =  getimagesize("res/ref".$line2["id"].".".$line2["ext"]);
if ($imageSize[0] > 150){ 
  $breedte = 150;
  $makelink = 1;
}else{
  $breedte = $imageSize[0];
}
$hoogte = $breedte*$imageSize[1]/$imageSize[0];
if ($makelink == 1){?><a href="#" onclick="javascript:window.open('showpicture.php?id=<?php print $line["foto1"]?>','showpicture','resizable=1')"><?}?><img src="res/ref<?php print $line2["id"]?>.<?php print $line2["ext"]?>" alt="<?php print $line2["naam"]?>" width="<?=$breedte?>" height="<?=$hoogte?>" border="0" hspace="5"></a>
<?}?>
  </td>
  	<?php if (stristr("gif jpg jpeg png bmp",$line2["ext"])) { ?>
    <td>   </td>
<?php } ?>
<td valign="top" width="100%" align="left">
  <table cellpadding="2" cellspacing="0" width="100%">
  	<tr><td colspan="2" class="titel"><?php print $line["titel"]?></td></tr>
   <tr><td width="11%"><b>Locatie</b>:</td><td width="89%"><?php print $line["gemeente"]?>, <?php print $line["adres"]?></td></tr>
   <tr><td><b>Provincie</b>: </td><td><?php print $line["provincie"]?></td></tr>
   <? if($oppervlakte != "") { ?>
   <tr><td><b>Oppervlakte</b>:</td><td><?php print $oppervlakte?></td></tr>
   <? } ?>
   <?if($line["grondbreedte"]<>""){?><tr><td><b>Gevelbreedte</b>:</td><td><?php print $line["grondbreedte"]?> m</td></tr><?}?>
   <?if($line["ki"]<>""){?><tr><td><b>Kadastraal inkomen</b>:</td><td><?php print $line["ki"]?></td></tr><?}?>
   <?if($line["slaapkamers"]<>"0"){?><tr><td><b>Slaapkamers</b>:</td><td><?php print $line["slaapkamers"]?></td></tr><?}?>
   <? if($line["cv"] != "") { ?>
   <tr><td nowrap><b>Centrale verwarming</b>:</td><td><?php print $line["cv"]?></td></tr>
   <? } ?>
   <?if($line["bj"]<>""){?><tr><td><b>Bouwjaar</b>:</td><td><?php print $line["bj"]?></td></tr><?}?>
   <? if($line["prijsklasse"] != "") { ?>
   <tr><td><b>Prijs</b>:</td><td><?php print $line["prijsklasse"]?></td></tr>
   <? } ?>
   <?if($line["referentie"]<>""){?><tr><td><b>Referentie</b>:</td><td><?php print $line["referentie"]?></td></tr><?}?>
  </table>
  </td>
  
</tr>
<tr>
	<td colspan="3"><br></td>
</tr>
<? if($line["tekst"] != "") { ?>
<tr>
<td colspan="3">
	<table border="0" cellpadding="0" cellspacing="0">
	<tr>
	<td valign="top"><b>Omschrijving</b>: </td><td><?php print $line["tekst"]?></td>	
	</tr>
</table>
  </td>
</tr>
<? } ?>
</table>
<table cellpadding="2" cellspacing="0" width="100%">
<tr><td colspan="3"> </td></tr>
<tr><td>
<?$makelink = 0;
$strSQL = "select id,naam,ext from Resources where id=".$line["foto2"];
$result = mysql_query($strSQL)
     or die("Fout bij uitvoeren query");
$line2 = mysql_fetch_array($result);
if (stristr("gif jpg jpeg png bmp",$line2["ext"])) {
$imageSize =  getimagesize("res/ref".$line2["id"].".".$line2["ext"]);
if ($imageSize[0] > 180){ 
$breedte = 180;
$makelink = 1;
}else{
$breedte = $imageSize[0];
}
$hoogte = $breedte*$imageSize[1]/$imageSize[0];
if ($makelink == 1){?><a href="#" onclick="javascript:window.open('showpicture.php?id=<?php print $line["foto2"]?>','showpicture','resizable=1')"><?}?><img src="res/ref<?php print $line2["id"]?>.<?php print $line2["ext"]?>" alt="<?php print $line2["naam"]?>" width="<?=$breedte?>" height="<?=$hoogte?>" border="0"></a>
<?}?></td>
<td>
<?$makelink = 0;
$strSQL = "select id,naam,ext from Resources where id=".$line["foto3"];
$result = mysql_query($strSQL)
     or die("Fout bij uitvoeren query");
$line2 = mysql_fetch_array($result);
if (stristr("gif jpg jpeg png bmp",$line2["ext"])) {
$imageSize =  getimagesize("res/ref".$line2["id"].".".$line2["ext"]);
if ($imageSize[0] > 180){ 
$breedte = 180;
$makelink = 1;
}else{
$breedte = $imageSize[0];
}
$hoogte = $breedte*$imageSize[1]/$imageSize[0];
if ($makelink == 1){?><a href="#" onclick="javascript:window.open('showpicture.php?id=<?php print $line["foto3"]?>','showpicture','resizable=1')"><?}?><img src="res/ref<?php print $line2["id"]?>.<?php print $line2["ext"]?>" alt="<?php print $line2["naam"]?>" width="<?=$breedte?>" height="<?=$hoogte?>" border="0"></a>
<?}?></td>
<td>
<?$makelink = 0;
$strSQL = "select id,naam,ext from Resources where id=".$line["foto4"];
$result = mysql_query($strSQL)
     or die("Fout bij uitvoeren query");
$line2 = mysql_fetch_array($result);
if (stristr("gif jpg jpeg png bmp",$line2["ext"])) {
$imageSize =  getimagesize("res/ref".$line2["id"].".".$line2["ext"]);
if ($imageSize[0] > 180){ 
$breedte = 180;
$makelink = 1;
}else{
$breedte = $imageSize[0];
}
$hoogte = $breedte*$imageSize[1]/$imageSize[0];
if ($makelink == 1){?><a href="#" onclick="javascript:window.open('showpicture.php?id=<?php print $line["foto4"]?>','showpicture','resizable=1')"><?}?><img src="res/ref<?php print $line2["id"]?>.<?php print $line2["ext"]?>" alt="<?php print $line2["naam"]?>" width="<?=$breedte?>" height="<?=$hoogte?>" border="0"></a>
<?}?></td></tr>
</table>
<?
break;




Case "4":
$strSQL = "select SiteItems.titel,SiteItems.tekst,lenicoTeKoop.*, lenicoTeKoopProvincie.titel as provincie,lenicoTeKoopPrijsKlasse.titel as prijsklasse from SiteItems ";
$strSQL.= " LEFT JOIN lenicoTeKoop ON (SiteItems.id=lenicoTeKoop.siteitem) ";
$strSQL.= " LEFT JOIN lenicoTeKoopProvincie ON (lenicoTeKoop.provincie=lenicoTeKoopProvincie.id) ";
$strSQL.= " LEFT JOIN lenicoTeKoopPrijsKlasse ON (lenicoTeKoop.prijsklasse=lenicoTeKoopPrijsKlasse.id) ";
$strSQL.= " where SiteItems.id = " . $id . ";";
$result = mysql_query($strSQL)
     or die("Fout bij uitvoeren query");
$line = mysql_fetch_array($result);
$oppervlakte = $line["grondopp1"]*100 + $line["grondopp2"];
if ($oppervlakte > 9999){
$oppervlakte = round($oppervlakte/10000,2) ." ha";
}else{
$oppervlakte = $oppervlakte ." m²";
}?>

<table cellpadding="0" cellspacing="0" width="100%">
<tr>
<td valign="top">
<?$strSQL = "select id,naam,ext from Resources where id=".$line["foto1"];
$result = mysql_query($strSQL)
     or die("Fout bij uitvoeren query");
$line2 = mysql_fetch_array($result);
if (stristr("gif jpg jpeg png bmp",$line2["ext"])) {
$imageSize =  getimagesize("res/ref".$line2["id"].".".$line2["ext"]);
if ($imageSize[0] > 500){ 
$breedte = 500;
}else{
$breedte = $imageSize[0];
}
$hoogte = $breedte*$imageSize[1]/$imageSize[0]?>
<a href="#" onclick="javascript:window.open('showpicture.php?id=<?php print $line["foto1"]?>','showpicture','resizable=1')"><img src="res/ref<?php print $line2["id"]?>.<?php print $line2["ext"]?>" alt="<?php print $line2["naam"]?>" width="<?=$breedte?>" height="<?=$hoogte?>" border="0"></a>
<?}?>
  </td>
  	<?php if (stristr("gif jpg jpeg png bmp",$line2["ext"])) { ?>
    <td>   </td>
<?php } ?>
<td valign="top" width="100%" align="left">

<table cellpadding="2" cellspacing="0" width="100%">
<tr><td width="100%" class="titel" colspan="2"><?php print $line["titel"]?></td></tr>
<tr><td width="11%"><b>Locatie</b>:</td><td width="89%"><?php print $line["gemeente"]?>, <?php print $line["adres"]?></td></tr>
<tr><td><b>Provincie</b>:</td><td><?php print $line["provincie"]?></td></tr>
<tr><td nowrap><b>Oppervlakte</b>:</td><td><?php print $oppervlakte?></td></tr>
<?if($line["referentie"]<>""){?><tr><td><b>Referentie</b>:</td><td><?php print $line["referentie"]?></td></tr><?}?>
</table>
  </td>
  
</tr>
<tr>
	<td colspan="3"><br></td>
</tr>
<? if($line["tekst"] != "") { ?>
<tr>
<td colspan="3">
	<table border="0" cellpadding="0" cellspacing="0">
	<tr>
	<td valign="top"><b>Omschrijving</b>: </td><td><?php print $line["tekst"]?></td>	
	</tr>
</table>
  </td>
</tr>
<? } ?>
</table><?




break;
}
echo "Er doen zich technishe problemen voor bij deze site. We trachten deze zo snel mogelijk op te lossen.";
Footer();
mysql_free_result($result);
?>

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.