3
Contributors
9
Replies
10
Views
6 Years
Discussion Span
Last Post by diafol
0

Please help out

Please place your code in code tags so it is easier to read.

Does the echoed $sql give you what you expected to see? Does the thing below look right when echoed to the screen?

UPDATE `farmlogin` SET `doc` = '$i' WHERE `cowid` = '$latest'

If so, try running the sql in the SQL window of phpmyadmin. It should give you an idea of where the query's going wrong.

0

yes, `doc`='' is showing blank... thats why its not running.. but how to resolve it..

0
$i = $_GET['y'];
$sql = "UPDATE `farmlogin` SET `doc` = '$i' WHERE `cowid` = '$latest'";

Ok, maybe you're sending data to this page by a form as opposed to a querystring. It is best to send forms via POST method as opposed to the GET method. Maybe you need to change that...

$i = $_POST['y'];
0

I am not posting variable 'y'.It's the variable containing doctor's ID that i am assigning in assigndoc.php..and retreiving it in farmmgmt.php . Look at this line in assigndoc.php

echo "<td><a href=farmmgmt.php?y={$row['docid']}>Assign</a></td>";
0

I am not posting variable 'y'.It's the variable containing doctor's ID that i am assigning in assigndoc.php..and retreiving it in farmmgmt.php . Look at this line in assigndoc.php

echo "<td><a href=farmmgmt.php?y={$row['docid']}>Assign</a></td>";

Just want to add that.. I am getting this 'y' value appended with the URL. but shows blank in the query.Have no clue where am i making mistake.

0

In the row

echo "<td><a href=farmmgmt.php?y={$row['docid']}>Assign</a></td>";

you need to add the cowid, or you won;t know which cow to assign the doctor to.

echo "<td><a href=farmmgmt.php?y={$row['docid']}&amp;cowid={$latest}>Assign</a></td>";

Edited by NettSite: n/a

0

OK, I see you have to use $_GET. My oversight, sorry.
AFAICS the whole thing revolves around getting the 'y' value from the querystring (url) and placing it into the $i variable, which is then used in your query.

echo out the $i variable to the screen, e.g.

echo "The value of i is $i";

This should tell you where the passing of information is going wrong.

Is the value of y an integer? If not, it could be that you have some odd symbols in it?? THis shouldn't really make a difference, but non-escaped quotes can sometimes cause a problem. You can cirumvent this by cleaning/sanitizing your post and get variables, thus:

$i = mysql_real_escape_string($_GET['y']);

In fact, you should do this to all your passed variables anyway.

0

Tried it..the value of y is still showing blank.

It's because it is running before any doctor get assigned only.Unless an until it gets the value of y from assigndoc.php, it shouldn't run only.
Once I allocate a doctor, its only after that,it should get the value in $i and proceed to run the update query...

Hopefully.. I am thinking correct, but don't know how to get this done.

Would Appreciate your help ardav..

0
$i = $_GET['y'];

This is independent of anything else that happens on your page. This is absolute. If your page url is something like: page.php?y=128, then $i will be 128. I can't see how this is not the case.

Just thinking, you are sending this info (y=128) to the page before you try to access the 'y' value ($_GET) right?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.