Jump to content

Recommended Posts

That's pretty much what I was afraid of  ;D

I'd change the FORM code so that instead of sending the item name, it sent the itemid

[code]<input type="hidden" name="itemID" value="$itemID">[/code]

Then I'd change the second page so it retrieved itemID and I'd use itemID in the query.
  • Replies 71
  • Created
  • Last Reply

Top Posters In This Topic

You have the advantage over me here, because I can't see the first page code.  The error you're seeing almost surely results from how ' and " are used in your code in the area around where the form is being output.  If you post a few relevant lines, we can fix the error you're seeing.
This is the entire first page:

[code]         
 
  <table width="484" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#CC3300">
  <tr>
          <td width="480" align="center" valign="top"> <table width="500" border="0" cellspacing="0" cellpadding="0">
              <tr>
               
          <td bgcolor="#FF9900">
            <div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><strong>My
              Items </strong></font></div></td>
              </tr>
              <tr>
                <td>    <table width=100% border="0" cellspacing="0">
        <tr>
          <td><div align="center"></div></td>
        </tr>
        <tr>   

<?


$query_myItems = "SELECT * FROM myitemschibi WHERE userID = '$preuserID' and itemQty > '0'";

$result_myItems = mysql_query($query_myItems, $connection);

$query_data = mysql_fetch_array($result_myItems);

$numberItems = mysql_num_rows($result_myItems);








$i = 0;



if ($numberItems < 1)

{

print "<td><CENTER><P>You have no items.</CENTER>";

}

else

{

$rowcount = 0;

while ($numberItems > $i)

{

if ($rowcount == 3)

{

echo "</tr>\n<tr>";

$rowcount = 0;

}



//$monopetImage1 = mysql_result($result2,$i,"monopetImage1");



$itemName = mysql_result($result_myItems,$i,"itemName");
//$itemDesc = mysql_result($result_myItems,$i,"itemDesc");
$itemQty = mysql_result($result_myItems,$i,"itemQty");
    $petPointsValue = mysql_result($result_myItems,$i,"petPointsValue");
//$itemSpecial1 = mysql_result($result_myItems,$i, "itemSpecial1");
//$itemSpecial2 = mysql_result($result_myItems,$i, "itemSpecial2");

//$isequippable = mysql_result($result_myItems,$i, "isequippable");

//$itemNumUses = mysql_result($result_myItems,$i, "itemNumUses");

//$itemAttackValue = mysql_result($result_myItems,$i, "itemAttackValue");

$itemID = mysql_result($result_myItems,$i, "itemID");

$image = str_replace(" ", "", $itemName);

$spacedname = str_replace(" ", "%20", $itemName);





print '<td width=150 height=150>

<center><font face=Arial, Helvetica, sans-serif size=2>';


// only display image if image exists (no broken images)

if(file_exists('../images/items/'.$image.'.jpg'))

{

echo '<img src=../images/items/'.$image.'.jpg>';

} else {

echo '<br><br><b>No Image<br>Available<br></b>';

}



print"<br>


<form action=../reg/secure/itemdetails.php method=post>

<input type=hidden name='itemID' value=$itemID>

<input type=image src=../images/details.jpg></FORM><br>



";



if($isequippable == '1')

{

echo '<br><i><B>Equippable</b>';

if($itemAttackValue > 0)

{

echo '<br>'.$itemAttackValue.' Attack Power';

} else {

echo '<br>'.abs($itemAttackValue).' Healing Power';

}

echo '<br>'.ucwords($itemNumUses).' Uses Remaining';

}



echo '</font></td>

';



$i++;

$rowcount++;

}

}







///////
?>
      </tr>
            </table> </tr>
            </table>
            <div align="center"></div></td>
  </tr>
      </table>
[/code]
OK, there's a hidden input field that contains the value of itemID so change the second page to retrieve it as I suggested.

[code]<?php
$itemID = $_POST['itemID'];
include ("secure/config3.php");
$SQL = "SELECT * FROM myitemschibi WHERE itemID ='$itemID'";[/code]

Give it try and report back on the outcome.
Ok. It worked I guess but theres another problem.

Now It's not fetching the info again. Wen I look at the URL of the picture it says http://www.net-petz.com/reg/images/items/.jpg Here's how i have it coded:

<img src="../images/items/<?echo$image;?>.jpg">

Here's some other snippets of code that relate:

$image = str_replace(" ", "", $itemName);

$spacedname = str_replace(" ", "%20", $itemName);

Which I have under

$itemID = $_POST['itemID'];
include ("secure/config3.php");
$SQL = "SELECT * FROM myitemschibi WHERE itemID ='$itemID'";
On your first page, you have this code:

[code]<form action=../reg/secure/itemdetails.php method=post>
<input type=hidden name='itemID' value=$itemID>[/code]

Take a look at the generated html code and post here exactly what you see when you view the html source code.

That form will send the value of itemID to the itemdetails.php page where this line retrieves it.

[code]$itemID = $_POST['itemID']; // retrieve itemID from form data[/code]

[quote]I think the problem is that none of the data is reaching the page for some reason.[/quote]
Can you provide a more explicit description of the problem than that. Why do you think so? What happens, doesn't happen, etc.
All the HTML code is in the page I posted before, except the actual htm page which is only

              <? include ("secure/config.php");
include ("secure/itemdetails.php");

?>

I think it's not reaching it because it's simply a blank table, and again the image is showing up as /items/.jpg. If the data were reaching it the name would show up and the imge would show up as $itemname.jpg.
Sorry, let me explain. I/we don't want to see the [b]code[/b] from the first page, I/we want to see what the browser generates based on that code (view source of the generated page). Then it will be obvious exactly what values have been placed in the form code, e.g. it will say name="itemID" value="12" or something like that.  If the value is blank then the problems in the first page.  If the value is a good one, then the reason why the second page doesn't work will lie in the code for the second page (and I think there's no problem there). 

The second page snippet you just posted clearly shows that whatever value should be there for the image name isn't there so I'm thinking there's a problem with your first page and how it generates the form.  If not, we can work on fixing whatever isn't happening on the second page.
Just post the code over at pastebin.com and provide a link to the posted code. That way we can see your code. Or a better option would be to attach the file to your post (Reply button > Additional Options... link > clik browse button to attach a file to the post.)

You can probide a demo account yes, as that way we can see whats going on
[code]<form action=../reg/secure/itemdetails.php method=post>
<input type=hidden name='itemID' value=40>
<input type=image src=../images/details.jpg></FORM><br>[/code]

That's the html code generated. Since it clearly contains a value for itemID, either there's something wrong with the reg/secure/itemdetails.php page or there's nothing in the database where itemID is 40.

If you're certain that there is something in the database with itemID of 40 (don't assume, check it please), then there's a problem with the itemdetails.php script that's on your server right now.  Make sure that the thing is always called itemID in queries and the database etc. since all this stuff is case-sensitive.  Guess we need to see the complete code for mydetails.php exactly as it presently exists on your server if none of the above actually points you at the problem and solution.
Yes, itemID 40 exists. Belongs to userID 29, itemName is spicy pepper pizza.

here's the whole itemdetails.php code:

[code]<?
session_start();
$session=session_id( );

$itemID = $_POST['itemID'];
include ("secure/config3.php");
$SQL = "SELECT * FROM myitemschibi WHERE itemID ='$itemID'";

$image = str_replace(" ", "", $itemName);

$spacedname = str_replace(" ", "%20", $itemName);
?>

<html>

<head>

<title><? print $itemName; ?></title>

</head>

<body>

<BR>
<table width="227" border="0" cellspacing="0" cellpadding="0" height="104" style="border-collapse: collapse" bordercolor="#111111">

  <tr>

    <td height="104" valign="top" width="227" bordercolorlight="#000080">

      <table width="200" border="1" cellspacing="0" cellpadding="0" bgcolor="#6699FF" bordercolor="#000066">

        <tr>

          <td align=center>

            <table width="200" border="0" cellspacing="0" cellpadding="0">

              <tr align=center bgcolor="blue">

                <td align=center bgcolor="blue">

                  <div align="center"><font face=Arial, Helvetica, sans-serif size=3 color="blue"><b>

                    <? print "$spacedname"; ?>

                    </b></font></div>

                </td>

              </tr>

              <tr bgcolor="#FFFFFF" align="center">

<img src="../images/items/<?php echo $image;?>.jpg">



<br>

              </tr>

            </table>

          </td>

        </tr>

      </table><BR>

      <table width="205" border="1" cellspacing="0" cellpadding="0" bordercolor="#000099">
        <tr>

          <td><table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%">
            <tr bgcolor="#FFCCFF">
              <td height="20" colspan="2" bgcolor="#0000FF" bordercolor="navy"><div align="center">
              <font face="Arial, Helvetica, sans-serif" size="2" color="#FFFFFF"><b>Item Info:</b></font></div></td>
            </tr>
            <tr>
              <td width="99" height="10" bordercolor="navy"><font face="Arial, Helvetica, sans-serif" size="1">&nbsp;Type:</font></td>
              <td width="101" height="10" bordercolor="navy"><font face="Arial, Helvetica, sans-serif" size="1"><? print "$type"; ?>
</font></td>
            </tr>
            <tr>
              <td height="19" bordercolor="navy"><font face="Arial, Helvetica, sans-serif" size="1">Use:</font></td>
              <td height="19" bordercolor="navy"><font face="Arial, Helvetica, sans-serif" size="1">&nbsp; </font>                        </tr>
          </table></td>
        </tr>
      </table><br>

    </td>

   

</table>


   

</html>[/code]
Well theres your problem. Your not running the query ($sql) at all. All you are doing is assign $sql the string "[i]SELECT * FROM myitemschibi WHERE itemID ='$itemID'[/i]" which wont do nothing. Or am I missing something here?
Change this:
[code]<?php
session_start();
$session=session_id( );

$itemID = $_POST['itemID'];
include ("secure/config3.php");
$SQL = "SELECT * FROM myitemschibi WHERE itemID ='$itemID'";

$result = mysql_query($sql);
$row = mysql_fetch_assoc($result);

extract($row);

$image = str_replace(" ", "", $itemName);

$spacedname = str_replace(" ", "%20", $itemName);
?>[/code]
To:
[code]<?php
session_start();
$session = session_id();

$itemID = $_POST['itemID'];

include ("secure/config3.php");

$SQL = "SELECT * FROM myitemschibi WHERE itemID ='$itemID'";

$result = mysql_query($SQL);
$row = mysql_fetch_assoc($result);

echo '<pre>' . print_r($row, true) . '</pre>';

die();

$image = str_replace(" ", "", $itemName);

$spacedname = str_replace(" ", "%20", $itemName);

?>[/code]
Post what it returns here. Dont panic if your page doesnt display correctly, I have made it do that.
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.