OK I have made a little progress and now face something else. I will paste my code here. OK here goes. I am loading a php page from another page by clicking on a table row. This table is filled with data from mysql. When i click on a row I am sent to http://whatever.net/spoilertable.php?item=7 I use '7' just as an example here. 7 is in a column called 'primary' in the row of my db. Its an incrimental key. OK. When spoilertable.php?item=7 loads I am using the $_get command to store that 7 in a variable so that i can use it to select a piece of data from the row with 7 as the entry under the primary column. now i KNOW the my variable is working because i thre in a echo command just to see what shoed up and when i echo the variable ($local_item) the 7 shows up. now whats NOT workign is either my query..the way i have it set up...or the way im trying to display the results of that query. basically what i have is a table with a story name a chapter a date the stopry chapter takes place on and an overall count of days...none of that really matters but its just background info for u. when i click the row that info is in what im trying to do is bring up a spoiler..a chapter synopsys if you will. that synopsys is in the same db row as the other information i just spoke of as well as the incrimental number i call 'primary' in the db. so can u tell me whats wrong here?
thanks in advance
tanner

<body>
<?php
$local_item=$_GET["item"];
$username="csniccsu_surftan";
$password="Ryanishott@69";
$database="csniccsu_timeline";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$result = mysql_query("SELECT * FROM basicinfo WHERE primary= '$local_item' "); 
$row = mysql_fetch_array($result);
mysql_close(); 
?> 
<p><?php echo $row['spoilers']; ?></p> 
<p><?php echo $local_item; ?>get item should be here</p>
</body>

Recommended Answers

All 3 Replies

try getting rid of the @ and ' around primary number. Numbers shouldn't be quoted in SQL

mysql_select_db($database) or die( "Unable to select database");
$result = mysql_query("SELECT * FROM basicinfo WHERE primary=$local_item");

ive tried that...still doesnt work

well i figured it out. wether this is the BEST way to do it or not i dunno..but i DO know that it works. so hers the code for anyone who may run iinto this same problem!

<?php
$local_item=$_GET["item"];
$username="############";
$password="############";
$database="############";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query = "SELECT * FROM basicinfo WHERE recnum=$local_item" or die ('Error: '.mysql_error ());
$result=mysql_query($query);
if (!$result) {
    $message  = 'Invalid query: ' . mysql_error() . "\n";
    $message .= 'Whole query: ' . $query;
    die($message);
}
while ($row = mysql_fetch_assoc($result)) {
    echo $row['spoilers'];
}

mysql_close(); 
?>

fyi..line one...well actually line two i guess...the GET comand....this page is pulled up via another page and is referenced as http://blah.com/document.php?item=7 (or any number) that number is the incrimented key in my db...so i needed to be able to click on something in one page and have it load data from the same row as the one the info i clicked on i9n page one was in....make sense?
im NOT a php pro AT ALL...but any questions about this u can email me at surfgrommett@yahoo.com and ill TRY to help if i can

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.