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
https://forums.phpfreaks.com/topic/160570-reponse-wrong/
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
https://forums.phpfreaks.com/topic/160570-reponse-wrong/#findComment-847427
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.