Osorene Posted July 6, 2007 Share Posted July 6, 2007 I´m connecting to a table in my database and receiving a notice instead of the expected information I use this code to make the connection to the database (kindly corrected in this forum) <?php $db = mysql_connect("localhost"," * "," * "); mysql_select_db("campover_dbcv",$db); if (isset($_GET['id'])) { $id = mysql_real_escape_string($_GET['id']); $requete = "SELECT * FROM cont_hist_05 WHERE ID=".$id; if ($result = mysql_query ($requete,$db)) { if (mysql_num_rows($result)) { $article = mysql_fetch_object($result); mysql_free_result($result); } } } ?> Then I try to call the information this way <?php echo $article->b ?> And this is what I get Notice: Undefined variable: article in c:\archivos de programa\easyphp1-8\www\public_html\prepa\conf_cont_hist33.php on line 69 Thanks for all your help. Quote Link to comment Share on other sites More sharing options...
MemphiS Posted July 6, 2007 Share Posted July 6, 2007 Whats on Line 69? and a line above it... Try this anyhow echo "$article->b"; ?> Quote Link to comment Share on other sites More sharing options...
per1os Posted July 6, 2007 Share Posted July 6, 2007 <?php $db = mysql_connect("localhost","campover","osorene"); mysql_select_db("campover_dbcv",$db); $article = ""; if (isset($_GET['id'])) { $id = mysql_real_escape_string($_GET['id']); $requete = "SELECT * FROM cont_hist_05 WHERE ID=".$id; if ($result = mysql_query ($requete,$db)) { if (mysql_num_rows($result)) { $article = mysql_fetch_object($result); mysql_free_result($result); } } } ?> Should solve the problem. Quote Link to comment Share on other sites More sharing options...
Osorene Posted July 6, 2007 Author Share Posted July 6, 2007 Thank for your help, specially to frost110. I don't receive the notice anymore but still I can't see the information, is something wrong in the way I'm trying to display it using the echo function? Is there another way? I have some text here... then I place this to retrieve the information from the table <?php echo $article->b ?> more text comes after and so on... Thanks again. Quote Link to comment Share on other sites More sharing options...
per1os Posted July 6, 2007 Share Posted July 6, 2007 Are you sure it is entering all of the if statements. Since you do not have any else statements to show an error message you are not sure. I would throw in some else statements so you can see where it is failing. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.