Jump to content


Photo

How do I send data from 1 page to another?


  • Please log in to reply
71 replies to this topic

#61 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 04 September 2006 - 11:32 PM

Does the rest of the site use a mysql database? My code shouldn't affect your mysql connection. Whats in secure/config3.php is this where you connect to the database? Check that you have the correct information for connecting to mysql in that file.

#62 Pi_Mastuh

Pi_Mastuh
  • Members
  • PipPipPip
  • Advanced Member
  • 233 posts
  • LocationMN

Posted 05 September 2006 - 12:37 AM

Config 3 is

<?
include ("htm/siteinfo.htm"); 
//connection information
include ("dbinfo.php");

//end connection information

 $SQL = "SELECT * FROM chibifriends WHERE preuserID = '$preuserID'";


   	$result = mysql_query($SQL,$connection);
	$query_data = mysql_fetch_array($result);
	$preuserID = $query_data['preuserID'];
	$points = $query_data['preuserDigitalCredits'];
?>

The connection info is in dbinfo. Which is:

<?
//connection information
$db_name = "db175253437";
$table_name = "chibifriends";
$connection =mysql_connect("db491.perfora.net", "dbo175253437" ,"**********") or die("Couldn't connect");
$db = mysql_select_db($db_name, $connection) or die("Couldn't select Database1.");
$connection2 = $connection;
?>

Schroedinger's Cat walks into a bar.
And doesn't.

#63 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 05 September 2006 - 12:01 PM

Try this:
<?php
session_start();
$session = session_id();

$itemID = $_POST['itemID'];

include ("secure/config3.php");

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

$result = mysql_query($sql, $connection) or die("Unable to run query<br />" . mysql_errno($connection) . ': ' . mysql_error($connection));

if(mysql_num_rows($result) == 1)
{
    $row = mysql_fetch_assoc($result);

    echo '<pre>' . print_r($row, true) . '</pre>';
}
else
{
    echo "Item ID '" . $itemID . "' was not found";
}

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

?>


#64 Pi_Mastuh

Pi_Mastuh
  • Members
  • PipPipPip
  • Advanced Member
  • 233 posts
  • LocationMN

Posted 05 September 2006 - 09:03 PM

Unable to run query
:
Schroedinger's Cat walks into a bar.
And doesn't.

#65 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 05 September 2006 - 10:01 PM

What the hell!  This is some weird c**p

Rather than including the database stuff. Try this:
<?php
//session_start();
//$session = session_id();

$db_name    = "db175253437";

$conn = mysql_connect("db491.perfora.net", "dbo175253437" ,"**********", true) or die("Couldn't connect");

mysql_select_db($db_name, $conn) or die("Couldn't select Database1.");

$itemID = $_POST['itemID'];

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

$result = mysql_query($sql, $conn) or die("Unable to run query - <code>{$sql}</code><br />" . mysql_error($conn));

if(mysql_num_rows($result) == 1)
{
    $row = mysql_fetch_assoc($result);

    echo '<pre>' . print_r($row, true) . '</pre>';
}
else
{
    echo "Item Id " . $itemID . " was not found";
}

?>
Make sure you change where it says ********** with your actual mysql password.

#66 Pi_Mastuh

Pi_Mastuh
  • Members
  • PipPipPip
  • Advanced Member
  • 233 posts
  • LocationMN

Posted 06 September 2006 - 01:13 AM

It shows this above the blank table:

Array
(
    [itemID] => 40
    [userID] => 29
    [petID] => 0
    [itemName] => Spicy Pepper Pizza
    [itemQty] => 1
    [petPointsValue] => 0
    [itemStoreID] => 1579
    [food] => 0
)
Schroedinger's Cat walks into a bar.
And doesn't.

#67 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 06 September 2006 - 01:48 AM

The code is now working! For some reason it wasnt connecting to the database when you was including config3.php

So all you need to do now is put in the relevent HTML/PHP code in to display the page correctly. Which I think is this:
<?php
session_start();
$session = session_id();

$db_name = "db175253437";

$conn = mysql_connect("db491.perfora.net", "dbo175253437" ,"**********", true) or die("Couldn't connect");

mysql_select_db($db_name, $conn) or die("Couldn't select Database1.");

$itemID = $_POST['itemID'];

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

$result = mysql_query($sql, $conn) or die("Unable to run query - <code>{$sql}</code><br />" . mysql_error($conn));

if(mysql_num_rows($result) == 1)
{
    $row = mysql_fetch_assoc($result);

    $image = str_replace(" ", "", $row['itemName']);
    $spacedname = str_replace(" ", "%20", $row['itemName']);
}
else
{
    die("Item Id " . $itemID . " was not found");
}

?>

<html>
<head>
<title><?php 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><?php 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"><?php 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>
                </td>
              </tr>
          </table>

        </td>
      </tr>
    </table>

    <br>

    </td>
  </tr>
</table>

</body>
</html>


#68 Pi_Mastuh

Pi_Mastuh
  • Members
  • PipPipPip
  • Advanced Member
  • 233 posts
  • LocationMN

Posted 06 September 2006 - 02:00 AM

Yes! Cept the only thing is that the name shows up as Spicy%20Pepper%20Pizza instead of Spicy Pepper Pizza. What's the corrdect code for spaces?
Schroedinger's Cat walks into a bar.
And doesn't.

#69 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 06 September 2006 - 02:04 AM

You have coded it to do that.

What you'll want to do is change
$spacedname = str_replace(" ", "%20", $row['itemName']);

to:
$itemName = $row['itemName'];


Now find
<font face="Arial, Helvetica, sans-serif" size="3" color="blue"><b><?php print $spacedname; ?></b></font>
Change that to this:
<font face="Arial, Helvetica, sans-serif" size="3" color="blue"><b><?php print $itemName; ?></b></font>


#70 Pi_Mastuh

Pi_Mastuh
  • Members
  • PipPipPip
  • Advanced Member
  • 233 posts
  • LocationMN

Posted 06 September 2006 - 02:08 AM

Now the name doesnt show up at all  :-\
Schroedinger's Cat walks into a bar.
And doesn't.

#71 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 06 September 2006 - 02:24 AM

man your site is wierd. Try this:
<?php
session_start();
$session = session_id();

$db_name = "db175253437";

$conn = mysql_connect("db491.perfora.net", "dbo175253437" ,"**********", true) or die("Couldn't connect");

mysql_select_db($db_name, $conn) or die("Couldn't select Database1.");

$itemID = $_POST['itemID'];

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

$result = mysql_query($sql, $conn) or die("Unable to run query - <code>{$sql}</code><br />" . mysql_error($conn));

if(mysql_num_rows($result) == 1)
{
    $row = mysql_fetch_assoc($result);

    $image = str_replace(" ", "", $row['itemName']);
    $itemName1 = $row['itemName'];
}
else
{
    die("Item Id " . $itemID . " was not found");
}

?>

<html>
<head>
<title><?php echo $itemName1; ?></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>
                  <font face="Arial, Helvetica, sans-serif" size="3" color="white"><b><?php echo $itemName1; ?></b></font>
                </td>
              </tr>
              <tr bgcolor="#FFFFFF" align="center">
                <td><img src="../images/items/<?php echo $image; ?>.jpg"></td>
              </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"><?php echo $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>
                </td>
              </tr>
          </table>

        </td>
      </tr>
    </table>

    <br>

    </td>
  </tr>
</table>

</body>
</html>
If it dont show the name I dont know. :(

#72 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 06 September 2006 - 03:47 AM

Got it! thank you so much!

I have one more question..


Pi_Mastuh, since you said the problem is fixed, and you have asked a new question, I think the wisest thing here would be to close this thread and start a new thread. I took the liberty of splitting this thread and making a new thread out of your post (the post where you said this problem was solved). You can see it here:

http://www.phpfreaks...c,107050.0.html
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users