<?php
$id=$_Get['id'];
$user="blah"; // need to change to session later
$host="--------------";
$username="---------";
$password="---------";
$db_name="---------";
$tbl_name="---------";
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$sql="SELECT * FROM $tbl_name Where id='$id'";
$result=mysql_query($sql);
$row = mysql_fetch_row($result);
echo $row['sender'];
?>
Not outputting selected values?
Started by zeroradius, May 15 2008 05:00 PM
5 replies to this topic
#1
Posted 15 May 2008 - 05:00 PM
Hi, I am curently working on a private messaging system in php. I started working on the final page (the view mail) and have ran into a snag. When you select the message it sends you to a page name view_sent.php?id="id here" it takes me to the new page and the corect Id shows in the address bar and no errors come out but the page does not return any information. right now i just have it returning the value of sender so i can get it working before i code the layout and return all of the information. Here is my code for the view_sent
|
|
|
#2
Posted 15 May 2008 - 06:57 PM
Does
echo $sqldisplay what you are expecting? Does
$result=mysql_query($sql) or die("Query Error: " . mysql_error()); provide you with an error? What does print_r($result)yield?
#3
Posted 17 May 2008 - 05:57 AM
1) Returns half of the sql statement cutting off at $id
2) No result
3) Resource id #2 (googleing this now, so far no usefull results)
Edit:
Hey John thanks for all the help. I got it working. I went and got the code from an old project from back when i used tutorials (now I make the schema and try to do it all myself)
the code looks simular and i still dont see what the problem was hertrs the working code
2) No result
3) Resource id #2 (googleing this now, so far no usefull results)
Edit:
Hey John thanks for all the help. I got it working. I went and got the code from an old project from back when i used tutorials (now I make the schema and try to do it all myself)
the code looks simular and i still dont see what the problem was hertrs the working code
$id=$_GET['id']; $sql="SELECT * FROM $tbl_name WHERE id='$id'"; $result=mysql_query($sql); $rows=mysql_fetch_array($result); echo $rows['sender'];(i had tryed array befor i posted and it was not working)
Edited by zeroradius, 17 May 2008 - 06:44 AM.
#4
Posted 24 May 2008 - 06:52 AM
I know the problem.
you used mysql_fetch_row() instead of mysql_fetch_array()
mysql_fetch_row() makes an array with index numbers only, mysql_fetch_array() makes an named array with fieldnames as keys to the field information.
it's simple, but hard to find in code.
then, you wrote $_Get first, and now $_GET, don't know if that makes difference ...
you used mysql_fetch_row() instead of mysql_fetch_array()
mysql_fetch_row() makes an array with index numbers only, mysql_fetch_array() makes an named array with fieldnames as keys to the field information.
it's simple, but hard to find in code.
then, you wrote $_Get first, and now $_GET, don't know if that makes difference ...
Edited by Orjan, 24 May 2008 - 06:59 AM.
#5
Posted 24 May 2008 - 08:43 AM
as i said in my last post i had tried array before i posted here, and the capitals in get may have made a diffrence, but i do not think it will
#6
Posted 26 May 2008 - 02:02 PM
well, as $id was empty before, I think the capital thing was the matter :-)


Sign In
Create Account


Back to top









