Re: getting close ...but still "record doesn't exist"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks for information on this one. I am putting print
statements in after my sql and getting more details
about the problem. I proceeded to put spaces infront
of my "from" & "where" statements. I am still getting
a sql error, but I think it is past the prior trouble
spot. Now, I get "Resource id #3Record doesn't exist."
This is in reference to the last bit of sql code: 

$fileContent = @mysql_result($result, 1, "furn_pic");

header("content-type: $fileType");

echo $fileContent;

}

else
{
echo "Record doesn't exist.";
}
?>

Is this a simple problem to fix?

--- Luis Moreira <luis.moreira@xxxxxxxxxxxxxxx> wrote:

> You send way too much info, forcinf people to read
> through all of it, to 
> understand your way of thinking and your problem.
> Keep it simple.
> 
> Anyway, I think there is something wrong in here
> 
> $sql = "SELECT furn_pic";
> 	$sql .=  "FROM crost"; 
> 	$sql .=  "WHERE item_num = $item_num";
> 	$result = mysql_query($sql)or die("Couldn't get
> file
> list"); 
> 
> Unless I am very much mistaken, PHP does not invent
> spaces whiel concatenating strings.
> Insert one space before the words FROM and WHERE,
> otherwise you will get something like 
> 
> 
> SELECT furn_picFROM crostWHERE item_num = ...
> 
> Luis
> 
> 
> Patrick Roane wrote:
> 
> >I am trying to display a gif file that I've
> >successfully stored up to mysql. I have 3 short
> files
> >that all work to gether to accomplish this task. 
> >
> >1. get_image.html (no problems w/this one)
> >
> >2. get_image.php   (I think this one is fine too)
> >
> >3. crostchair.php   (this one has the problem)
> >
> >It is with the 3rd file where the problem exists.
> >
> >Here is a clip from that file:
>
>-----------------------------------------------------
> >$sql = "SELECT furn_pic";
> >	$sql .=  "FROM crost"; 
> >	$sql .=  "WHERE item_num = $item_num";
> >	$result = mysql_query($sql)or die("Couldn't get
> file
> >list"); 
>
>---------------------------------------------------------
> >At first, I had to rem out my initial 3 lines of
> code
> >to even get as far as I did, or I'd get "invalid
> >modelID specified"
>
>--------------------------------------------------------
> ><?php
> >	
> >	#global $item_num;
> >
> >
> >    #if(!is_numeric($item_num))
> >
> >    #die("Invalid modelId specified");
>
>-------------------------------------------------------
> >In my db table, item_num is an AUTO_INCREMENT
> primary
> >key.
>
>---------------------------------------------------------
> >Here is code for get_image.php:
>
>-------------------------------------------------------
> ><?php
> >
>
>/*----------------------------------------------------start
> >of database
>
>connection/selection------------------------------*/
> >
> >$link = mysql_pconnect( "localhost", "", "" );
> >    if ( ! $link ) {
> >		$dberror = mysql_error();
> >		return false;
> >	}else {
> >    print "<h2>Successfully connected to
> >server</h2>\n\n";
> >    }
> >
> >    if ( ! mysql_select_db( "myfiles", $link ) ) {
> >		$dberror = mysql_error();
> >	    return false;
> >	}
> >	mysql_select_db("myfiles");
> >
> >	$dbQuery = "SELECT item_num, model_id, furn_name
> ";
> >
> >    $dbQuery .= "FROM crost ";
> >
> >    $dbQuery .= "ORDER BY model_id ASC";
> >
> >    $result = mysql_query($dbQuery) or
> die("Couldn't
> >get file list");
> >
> >?>
> >	
> ><!------------------------------------------end of
> >database
>
>connection/selection------------------------------------------>
> >
> >
> ><!------------------------------------------start
> of
> >HTML column
> >headings------------------------------------------>
> 
> >	
> >	
> >	
> >	<table border="1" cellpadding="0" cellspacing="0"
> >bordercolor="#111111" width="100%">
> >
> ><tr>
> >
> ><td width="34%" bgcolor="#FF9900" height="21">
> >
> ><p style="margin-left: 10"><b><font size="2"
> >face="Verdana" color="#FFFFFF">
> >
> >Model ID</font></b></td>
> >
> ><td width="33%" bgcolor="#FF9900" height="21">
> >
> ><p style="margin-left: 10"><b><font face="Verdana"
> >size="2" color="#FFFFFF">
> >
> >Furniture name</font></b></td>
> >
> ><td width="33%" bgcolor="#FF9900" height="21">
> >
> ><p style="margin-left: 10"><b><font face="Verdana"
> >size="2" color="#FFFFFF">
> >
> >File</font></b></td>
> >
> ></tr>
> >
> ><!------------------------------------------end of
> >HTML column
> >headings------------------------------------------>
> 
> >
> >
> ><!-------------start of HTML table that inludes ID,
> >name and pic of each piece of furniture
> >------------------------------------------>	
> >
> >
> >
> ><?php
> >
> >//As mentioned above, we will be displaying each
> file
> >as a table row. The HTML code above creates this
> >table.
> >
> >while($row = mysql_fetch_array($result))
> >
> >{
> >
> >?>
> >
> ><tr>
> >
> ><td width="34%" bgcolor="#FFDCA8" height="21">
> >
> ><p style="margin-left: 10; margin-right: 10">
> >
> ><font face="Verdana" size="1">
> >
> ><?php echo $row["model_id"]; ?>
> >
> ></font>
> >
> ></td>
> >
> >
> >
> ><td width="33%" bgcolor="#FFDCA8" height="21">
> >
> ><p style="margin-left: 10">
> >
> ><font face="Verdana" size="1">
> >
> ><?php echo $row["furn_name"]; ?>
> >
> ></font>
> >
> ></td>
> >
> >
> >
> ><td width="33%" bgcolor="#FFDCA8" height="21">
> >
> ><p style="margin-left: 10"><font face="Verdana"
> >size="1">
> >
> ><a href="crostchair.php?fileId=<?php echo
> >$row["item_num"]; ?>">
> >
> >Download now
> >
> ></a></font>
> >
> ></td>
> >
> ></tr>
> >
> ><?php
> >
> >}
> >
> >echo "</table>";
> >
> >?>
> >
>
>---------------------------------------------------------
> >here is code for crostchair.php
>
>---------------------------------------------------------
> ><?php
> >	
> >	#global $item_num;
> >
> >
> >    #if(!is_numeric($item_num))
> >
> >    #die("Invalid modelId specified");
> >
>
>/*----------------------------------------------------start
> >of database
>
>connection/selection------------------------------*/
> >
> >
> >    $link = mysql_pconnect( "localhost", "", "" );
> >    if ( ! $link ) {
> >		$dberror = mysql_error();
> >		return false;
> >	}else {
> >    print "<h2>Successfully connected to
> >server</h2>\n\n";
> >    }
> >
> >    if ( ! mysql_select_db( "myfiles", $link ) ) {
> >		$dberror = mysql_error();
> >	    return false;
> >	}
> >	
> >	$sql = "SELECT furn_pic";
> >	$sql .=  "FROM crost"; 
> >	$sql .=  "WHERE item_num = $item_num";
> >	$result = mysql_query($sql)or die("Couldn't get
> file
> >list");
> >	
> >    if(mysql_num_rows($result) == 1)
> > 
> >/*-----if row returned from our query, we save its
> >actual data to a variable,
>
>$fileContent.----------------------------------------------*/
> >     {
> >
> >
> >     $fileContent = @mysql_result($result, 0,
> >"furn_pic");
> >
> >
> >
> >     header("Content-type: $fileType");
> >
> >     echo $fileContent;
> >
> >     }
> > 
> >     else
> >
> >     {
> >
> >     echo "Record doesn't exist.";
> >
> >     }
> >
> >	?>
> >Any ideas?
> >
> >=====
> >Patrick Roane
> >Web design and development
> >www.franklin-band.com
> >Fox River Grove, Il.
> >
> >  
> >
> > begin:vcard
> fn:Luis Moreira (Eng)
> n:Moreira;Luis
> org;quoted-printable:Banco Espirito Santo -
> ACE;Comunica=C3=A7=C3=B5es e Seguran=C3=A7a
> adr;quoted-printable;dom:;;R. da Fraternidade
> Oper=C3=A1ria, 5;Carnaxide;;2799
> email;internet:luis.moreira@xxxxxxxxxxxxxxx
> title:Analista
> tel;work:+351 214168288
> tel;fax:+351 214168092
> tel;cell:+351 964643928
> note:Cliente de mail : Mozilla Thunderbird
> url:http://www.moreiranet.com
> version:2.1
> end:vcard
> 
> 


=====
Patrick Roane
Web design and development
www.franklin-band.com
Fox River Grove, Il.

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux