i started the application to build upon and came to an error, i tried to figure it out but through different procedure here is what i am calling:

print ("<tr><td><a href=morder.php");
print ("?p_id=");
print($row);
print(">");
print($row);
print("</a></td>");

it is calling the id from database, the link shows properly the values of the id as 1,2 etc, now when i clik the link the value is not passed as: NULL


this is te error


SELECT * FROM catalog WHERE id=
Warning: mysql_result(): supplied argument is not a valid MySQL result resource in C:\wamp\www\PPP_Cart\morder.php on line 63

Warning: mysql_result(): supplied argument is not a valid MySQL result resource in C:\wamp\www\PPP_Cart\morder.php on line 64

this is the code:

$query2="SELECT * FROM catalog WHERE id=$p_id";
echo "$query2";

plz help me thanks asap

your links wrong to start with

print ("<tr><td><a href\"=morder.php");
print ("?p_id=");
print($row['id']);
print("\">");
print($row['p_name']);
print("</a></td>");

what is $p_id a number or a string ?

woops i mean

print ("<tr><td><a href=\"morder.php");
print ("?p_id=");
print($row['id']);
print("\">");
print($row['p_name']);
print("</a></td>");

the id passed is the primary key of table quite obious it is int value. also you specified the / in the above code of mine, i changed it but it does not work, you said

what is $p_id a number or a string ?

$p_id is the variable created to fetch the id from the query as

$q1="SELECT * FROM catalog";
$r1=mysql_query($q1);
while($row=mysql_fetch_array($r1))
{
print ("<tr><td><a href=morder.php");
print ("?p_id=");
print ($row);
print (">");
print ($row);
print ("</a></td></tr>");
}

you have to use the escape "\" when entering a " qoutation mark inside a string otherwise it will close the string and you cant write a link without using a qoutation mark i.e.

<A href="...">somwehere</A>

otherwise i dont see how you could link it in the first place ?

and it is a backslash \
not a forward slash /

well here is what is caused as an error:

$q2 = "SELECT * FROM catalog WHERE id='$p_id'";
$r2 = mysql_query($q2);
$p_name = mysql_result($r2, 0, "p_name");

now the error is:

**Warning**: mysql_result() [function.mysql-result](http://localhost/PPP_Cart/function.mysql-result): Unable to jump to row 1 on MySQL result index 5 in C:\wamp\www\PPP_Cart\morder.php on line 82

Edited 3 Years Ago by happygeek: fixed formatting

hmmm i dont see what is actually going wrong. why not print out everything the result returns and see if that works then move on from there ?

while ($row=mysql_fetch_array($r2)){
   foreach ($row as $value) {
      print($value + "<br>");
   }
}

here it is what i am trying to do?

<?php
$query1 = "SELECT * FROM catalog";
$result1 = mysql_query($query1);
while ($row = mysql_fetch_array($result1))
{
print ("<tr><td><a href=morder.php");
print ("?p_id=");
print ($row);
print (">");
print ($row);
print ("</a></td></tr>");
}
?>

in the above code calling the value from catalog which consist of id, p_name etc fields

now

<?php
$q2 = "SELECT * FROM catalog WHERE id='$p_id'";
$r2 = mysql_query($q2);
$p_name = mysql_result($r2, 0, "p_name");
echo "<br>";
echo "$p_name";

the value of the $p_pid shows when i move the mouse over in the status bar correctly but when i clik it

the query is passed as:

select * from catalog where p_id='';

no value being passed.

You should use this instead:
$q2 = "SELECT * FROM catalog WHERE id='".$_REQUEST["p_id"]."'";

FOr the link printing:
echo "<tr><td>";
echo "<a href=morder.php?p_id=".$row.">".$row;
echo ("</a></td></tr>");

This article has been dead for over six months. Start a new discussion instead.