papillonstudios Posted June 2, 2009 Share Posted June 2, 2009 I am trying to make my site grab the site name and url from a database table called info. but when i do that i get a message Resource id #6 AND Resource id #7 //Connect to the database $connect = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if (!$connect) echo 'There was an error connecting to the database'; mysql_select_db(DB_NAME); //Path to index.php file , no following slash //Eg, if the index file were located at http://iscripting.net/isus/index.php - you would enter http://iscripting.net/isus $siteurl = mysql_query("SELECT * FROM info WHERE siteurl = '$siteurl' "); //Your Website name, not the <title> $sitename = mysql_query("SELECT * FROM info WHERE sitename = '$sitename' "); heres my code for wheres it's being displayed <?php //Checks to see if theyre allowed to edit their profile if ($uCan['admin']) { //Double security incase the admin hasn't set a guest membergroup if ($uId) { //If the form hasn't been submitted, show it. if (!$_POST['update']) { ?> <form method="post"> <table width="75%"> <tr><td>Site Name <input type="text" size="25" maxlength="25" name="sitename" value="<?php echo "$sitename"; ?>"> </td></tr> <tr><td>Site URL <input type="text" size="25" maxlength="25" name="siteurl" value="<?php echo "$siteurl"; ?>"> </td></tr> <tr><td>Site Description <input type="text" size="25" maxlength="200" name="sitedesc" value="<?php echo "$sitedesc"; ?>"> </td></tr> <tr><td>Admin Email <input type="text" size="25" maxlength="50" name="aemail" value="<?php echo "$aemail"; ?>"> </td></tr> <tr><td>Contact Email Link <input type="text" size="25" maxlength="50" name="emailink" value="<?php echo "$emailink"; ?>"> </td></tr> <tr><td><input type="submit" name="update" value="Change Settings"></td></tr> </table> </form> <?php } //Or else it has been submitted... else { //Get information from the forms secure it all. $sitename = secure($_POST['sitename']); $siteurl = secure($_POST['siteurl']); $sitedesc = secure($_POST['sitedesc']); $aemail = secure($_POST['aemail']); $emailink = secure($_POST['emailink']); $update = @mysql_query("UPDATE info SET emailink = '$emailink', sitename = '$sitename', sitedesc = '$sitedesc', aemail = '$aemail', siteurl = '$siteurl' WHERE id = '1'"); if ($update) echo 'The settings has been changed'; else echo "Error message = ".mysql_error(); //A query to update everything } } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/160570-reponse-wrong/ Share on other sites More sharing options...
Alex Posted June 2, 2009 Share Posted June 2, 2009 The problem is obviously that you're selecting all the columns, you have to choose which one you want. But I don't understand what you're trying to do.. You have the sitename and you want to select the sitename? Quote Link to comment https://forums.phpfreaks.com/topic/160570-reponse-wrong/#findComment-847424 Share on other sites More sharing options...
Andy-H Posted June 2, 2009 Share Posted June 2, 2009 It sounds to me like you aren't fetching the data before using the variables pulled from the query. (echoing the query without using mysql_fetch_???) Quote Link to comment https://forums.phpfreaks.com/topic/160570-reponse-wrong/#findComment-847426 Share on other sites More sharing options...
Alex Posted June 2, 2009 Share Posted June 2, 2009 In your code it seems like you're only updating row '1'. To fetch the info for only row 1 it would be like this: $result = mysql_query("SELECT sitename, siteurl FROM `info` WHERE id='1' LIMIT 1"); $row = mysql_fetch_assoc($result); echo $row['sitename']; //sitename echo $row['siteurl']; //siteurl Quote Link to comment https://forums.phpfreaks.com/topic/160570-reponse-wrong/#findComment-847427 Share on other sites More sharing options...
papillonstudios Posted June 2, 2009 Author Share Posted June 2, 2009 Thanks guys for the help and the fast reponses. Just to explain the table info only has 1 row because it holds the information for the site like Name url, admin, email etc. Quote Link to comment https://forums.phpfreaks.com/topic/160570-reponse-wrong/#findComment-847464 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.