LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   PHP urgent help needed! (https://www.linuxquestions.org/questions/programming-9/php-urgent-help-needed-299595/)

xemous 03-09-2005 10:33 AM

PHP urgent help needed!
 
OK! finally i update; as follows is the error and code
thanks in advance for all help!

the error:

Connecting to database: jamesgpsware
Your details are:

befoer resultResource id #3after result
Fatal error: Call to undefined function: msql_fetch_object() in /var/www/localhost/htdocs/james/status.php on line 38

the code

Code:

<html>
<head>
<title> Status Page </title>
</head>
<body>

<hr>

<?php
if (isset($_POST['action']) && $_POST['action'] == 'submitted') {

$host = "localhost";
$user = "james";
$pass = "e200";
$database = "jamesgpsware";

//Selects the database, or gives error if it cannot be found
/*$test="select * from `Customers` c, `Orders` o  WHERE c.customerID = o.Orderid";
//mebe another = after o.Orderid (o.Orderid = $usequerynum)
echo "testing: .$test"; */

echo "<strong>Connecting to database: </strong>$database <br><hr>";
$link = mysql_connect("$host", "$user", "$pass")
    or die("Could not connect : " . mysql_error());
mysql_select_db("$database") or die("Could not select database");

echo "<strong><div align=center>Your details are: <br><br>";


//select * from Customers where CustomerID = $value <-- value =

$query = "SELECT * FROM Customers WHERE Name = '$_POST[name]' OR Zip = '$_POST[zip]'";
$result = mysql_query($query) or die("Query failed : " . mysql_error());

echo "befoer result";
echo $result;
echo "after result";
while($row = msql_fetch_object($result))
{
echo $row->CustomerID;
}

echo '<table border="12">';
echo "<tr>
  <td><strong><div align=center>Customer ID</td>
  <td><strong><div align=center>Name</td>
  <td><strong><div align=center>Street</td>
  <td><strong><div align=center>City</td>
  <td><strong><div align=center>State</td>
  <td><strong><div align=center>Zip</td>
  <td><strong><div align=center>Card Type</td>
  <td><strong><div align=center>Card Holder</td>
  <td><strong><div align=center>Card #</td>
  <td><strong><div align=center>Expiry Month</td>
  <td><strong><div align=center>Expiry Year</td>
  </strong>
        </tr>";

while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
    echo "\t<tr>\n";
    foreach ($line as $col_value) {
        echo "\t\t<td><div align=center>$col_value</td>\n";
    }
    echo "\t</tr>\n";
}
echo "</table>\n";

//order code here

$query2 = "SELECT * FROM Orders WHERE Orderid = $id";
$result2 = mysql_query($query2) or die("Query failed : " . mysql_error());

echo '<table border="1">';
echo "<tr>
  <td><strong><div align=center>Customer ID (dw)</td>
  <td><strong><div align=center>Order ID</td>
  <td><strong><div align=center>GoMap 1.0 Price</td>
  <td><strong><div align=center>GoMap 1.0 Qty</td>
  <td><strong><div align=center>Drive Planner 2.0 Price</td>
  <td><strong><div align=center>Drive Planner 2.0 Qty</td>
  <td><strong><div align=center>Hiker 1.0 Price</td>
  <td><strong><div align=center>Hiker 1.0 Qty</td>
  <td><strong><div align=center>G-Receiver I Price</td>
  <td><strong><div align=center>G-Receiver I Qty</td>
</tr>";


echo "\n<hr>";
echo "<br>";
echo "<strong>Customers orders: </strong>";
echo "<br><br>";
while ($line2 = mysql_fetch_array($result2, MYSQL_ASSOC)) {
    echo "\t<tr>\n";
    foreach ($line2 as $col_value2) {
        echo "\t\t<td><div align=center>$col_value2</td>\n";
    }
    echo "\t</tr>\n";
}
echo "</table>\n";

$id = mysql_fetch_row ($result);
echo $id;
//echo $id->CustomerID;

/* Free resultset */
mysql_free_result($result);

/* Closing connection */
mysql_close($link);

    echo '<pre>';
    /*print_r($_POST); this line prints the submitted stuff (array)*/
    echo '<a href="'. $_SERVER['PHP_SELF'] .'">Please try again</a><br>';
    echo '<a href="index.html">Back to Homepage</a>';
    echo '</pre>';
} else {
?>

To check your profile enter your details:<br>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
    First Name:&nbsp;<input name="name" type="text" tabindex="1">&nbsp;&nbsp;&nbsp;
 Zip:&nbsp;<input name="zip" tabindex="2"><br>
    <input type="hidden" name="action" value="submitted" />
    <input type="submit" name="submit" value="submit me!" />
</form>

<?php

}

?>

<hr>

</body>
</html>


TheLinuxDuck 03-09-2005 11:00 AM

Unless I'm misunderstanding, the error is a missing 'y' in the command:
PHP Code:

  while($row msql_fetch_object($result)) 

Perhaps it should be:
PHP Code:

  while($row mysql_fetch_object($result)) 


xemous 03-10-2005 07:27 AM

!!!
another typo :(

thanks alot , problem is fixed, for now....


All times are GMT -5. The time now is 01:35 PM.