Jump to content

Reponse wrong


Recommended Posts

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


	}
}
}


?>

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.