You are currently viewing the MySQL section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Here is basically what I have. I'm trying to query the database to display in a textarea so that I can update the information while looking at it could someone please help me with this topic
$Id = $_GET['Id'];
$query = "SELECT Code FROM AddTable2 WHERE Id = '$Id'";
$result = @mysql_query ($query) or die;
if ($result)
A few things are wrong with your code. One thing is that mysql_query() returns an identifier, not a readable value. Let me write a script for you as an example:
Code:
<?php
//standard connect to database
$query = "SELECT Code FROM AddTable2 WHERE Id='$Id'";
$result = mysql_query($query);
$data = mysql_fetch_assoc($result);
?>
<textarea><?php echo $data['Code']; ?></textarea>
It's saying "query was empty". But I copied and past the select statement, from a previous file that worked, on to the code. Do you think it's a parsing issue
For those who didn't reply or didn't know here is some information for you:
This is how you do it
if (isset($_GET['Id']) && !is_null($_GET['Id']))
$Id = $_GET['Id'];
else
exit('fail');
$query1 = "SELECT Code FROM AddTable2 WHERE Id = '$Id'";
$result1 = @mysql_query ($query1) or die (mysql_error());
$data = mysql_fetch_assoc($result1);
if ($result1)