Jump to content

How do I send data from 1 page to another?


Pi_Mastuh

Recommended Posts

  • Replies 71
  • Created
  • Last Reply

Top Posters In This Topic

OKay try 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) or die("Unable to run query<br />" . mysql_error());

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);

?>[/code]
Link to comment
Share on other sites

You have a problem with your sockets. I am not exprienced with using sockets. So I wont be able to help you much.

The only thing I can recommend you to do is read the [url=http://dev.mysql.com/doc/refman/5.0/en/can-not-connect-to-server.html]MySQL manual[/url] on this problem.
Link to comment
Share on other sites

It happened to me once, it has to do with a corrupted file where the socket file is suppose to be on your server.  contact your webhost, tell them it seems your sql socket file has been corrupted, this is what I did, they had to replace the file for it to connect again, I don't know if I am right or not, but I know this happened before, and I wasn't very happy about it, ask them to replace the socket file, back into the directory it's suppose to, and tell them if it's already there, to please overright it, with a new version(meaning make sure it works).

Another thing is log into your web host control panle, if it's got a double module type setup
meaning 1 place to create the database, one place to manage it, then I suggest going to where you create the database, and test it, they should have something there to test the database for bugs, if not the play this connect, and select scripts, see if you can even connect, if you can see if you can select the db, You can't ping if you aren't connected so that won't help, try also echoing mysql_error();
if someone hasn't told you to do that already, just to see if it gives a more specific error message.
Link to comment
Share on other sites

Config 3 is

[code]<?
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'];
?>[/code]

The connection info is in dbinfo. Which is:

[code]<?
//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;
?>[/code]
Link to comment
Share on other sites

Try 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, $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);

?>[/code]
Link to comment
Share on other sites

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

Rather than including the database stuff. Try this:
[code]<?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";
}

?>[/code]
Make sure you change where it says ********** with your actual mysql password.
Link to comment
Share on other sites

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:
[code]<?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>[/code]
Link to comment
Share on other sites

You have coded it to do that.

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

to:
[code=php:0]$itemName = $row['itemName'];[/code]


Now find
[code]<font face="Arial, Helvetica, sans-serif" size="3" color="blue"><b><?php print $spacedname; ?></b></font>[/code]
Change that to this:
[code]<font face="Arial, Helvetica, sans-serif" size="3" color="blue"><b><?php print $itemName; ?></b></font>[/code]
Link to comment
Share on other sites

man your site is wierd. Try this:
[code]<?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>[/code]
If it dont show the name I dont know. :(
Link to comment
Share on other sites

[quote=Pi_Mastuh]
Got it! thank you so much!

I have one more question..
[/quote]

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.com/forums/index.php/topic,107050.0.html
Link to comment
Share on other sites

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.