|
This one line of code in the head part of the HTML works for me:
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon" />
assuming the icon file "favicon.ico" (IIRC the name matters) is in the server's "images" folder.
When in doubt, look at the "page source" of any web page that gets you interested.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
You can look at the page source of codeproject.com and search for favicon:
I recommend to use the whole path to the image like "http://www.codeproject.com/favicon.ico" if you want to work in subdirectories and you want to use .htaccess.
|
|
|
|
|
Thank you very much, however I discovered that many years ago and am using it myself, see my reply above.
You are replying to the wrong person.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
You can look at the page source of codeproject.com and search for favicon:
<link rel="icon" href="/favicon.ico" type="image/ico">
I recommend to use the whole path to the image like "http://www.codeproject.com/favicon.ico" if you want to work in subdirectories and you want to use .htaccess.
I hope that I am answering to the right person now
|
|
|
|
|
Thank alot for your help
it work right
|
|
|
|
|
<b> I have an exercise in python but I have any Idea to do it : </b>
It is about the last two exercise of chapter 4 of the book how to think like a computer scientist.
the adress is <a href="http://openbookproject.net/thinkCSpy/ch04.html">http://openbookproject.net/thinkCSpy/ch04.html</a>[<a href="http://openbookproject.net/thinkCSpy/ch04.html" target="_blank" title="New Window">^</a>]
|
|
|
|
|
i got an simple code as below, after run once, it results insert twice in mysql database.
I had googled for the whole day struggling for this, I couldnt figured out what happen to this code. It runs perfectly at localhost but after move to server, problem occured. Anyone faced it before? Got some idea on how to resolve this problem?
***FULL CODES***:
***RESULT***:
result=1
1 -- testing -- 1298185509
2 -- testing -- 1298185511
|
|
|
|
|
i think code is right ....try to remove
$result=mysql_query($sql);
echo "result=".$result;
before INSERT any data check the total record in database maybe added something and you don't know...
and use this only
mysql_query($sql);
if it works let me know ...
|
|
|
|
|
Subject is pretty self explanatory. This is what I have for code and then I'll try to explain it.
<?php
echo "Login page";
?>
<form action="rememberMe.php" method="post">
<div style="width: 30em;">
<label for="name">Please Enter Your Name:</label>
<input type="text" name="name" id="name" value="" />
<br />
<label for="location">In what location do you work<br />(Portland/Brewer)?</label>
<input type="text" name="location" id="location value="" />
<div style="clear: both;">
<input type="submit" name="sendInfo" value="sendInfo" />
</div>
</div>
</form>
and then
<?php
$name = $_POST["name"];
$location = $_POST["location"];
$cookie = $name. "," . $location;
setcookie( "thomasEmployee", $cookie, time() + 60 * 60 * 24 * 365), "/", ".linuxserver", false, true);
if (isset($_COOKIE['thomasEmployee'])) {
var_dump($_COOKIE);
}
else {
header( 'Location: index.html' ) ;
}
?>
This is the page where I'm trying to "write" the cookie. The name I'm trying to use for the cookie is thomasEmployee, using the variable I created ($cookie) to hold the value, setting it for a year (though I'm sure it'll get deleted before then), and the domain (part I'm not sure about) is linuxserver. This is for a intranet site, the url for the indexpage is typed linuxserver/index.html so I'm guessing the domain is linuxserver?
What I have right now doesn't seem to be writing anything as when I go to look for it, it's not there and when I try to get to my test page, it brings me right back to the login page.
<?php
if (isset($_COOKIE["thomasEmployee"])) {
}
else {
header( 'Location: login.php' ) ;
}
?>
<html>
<head>
That's the top of the page where I currently have it checking for the cookie.
I'm sure it's something stupid, so thanks in advance!!!
|
|
|
|
|
First guess is that you've run into the old "too late to send headers" problem. Quoting from the PHP manual:
setcookie() defines a cookie to be sent along with the rest of the HTTP headers. Like other headers, cookies must be sent before any output from your script (this is a protocol restriction). This requires that you place calls to this function prior to any output, including <html> and <head> tags as well as any whitespace. <br />
Note the last few words. A single space or newline can break your code.
HTH
Peter
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
ok I have changed the code to this:
<?php
$name = $_POST["name"];
$location = $_POST["location"];
$cookie = $name. "," . $location;
setcookie("thomasEmployee",$cookie,time() + 60 * 60 * 24 * 365,"/","linuxserver",false,true);
header('Location: http://linuxserver/index.html');
?>
I have also tried:
setcookie("thomasEmployee",$cookie,time() + 31536000,"/","linuxserver",false,true);
and
setcookie("thomasEmployee",$cookie,time()+31536000,"/","linuxserver",false,true);
but only this seems to work:
setcookie("thomasEmployee",$cookie,time()+31536000);
granted this is a intranet site so not a huge deal, but it would be nice to know why the rest isn't working.
Also this will be available to all pages from this site correct? I'm pretty sure the answer is yes, but I'd like to be sure.
|
|
|
|
|
MacRaider4 wrote: it would be nice to know why the rest isn't working.
All I can suggest is adding the remaining optional parameters one at a time and see what happens with, say, Firebug, and a peek into the server logs.
MacRaider4 wrote: Also this will be available to all pages from this site correct? I'm pretty sure the answer is yes, but I'd like to be sure.
I'm pretty sure too. Suck it and see, in with the testing I suggested above.
Cheers,
Peter
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
Have you tried to change your code to this?
|
|
|
|
|
three suggestions:
1.
read the documentation (it may be there), and use Google (others may have encountered the same problem).
2.
the function has a return value; always check the return value when there is one, it is there for a reason.
3.
the domain parameter seems to expect a domain name (or a partial one, starting with a period), not a host name.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Not quite a month since I've worked on this (this is a side project). Anyways, I think I'll have some time this week to get back to PHP and the web. I'll go through what you guys wrote and if I have any further questions or get it "working" I'll let you know. Thanks again!!
|
|
|
|
|
We use the following to store the users ID when they logon...
setcookie("UID", $_REQUEST['cuser'], time()+2592000, "/");
...this allows us to remember a users ID, BUT it is only available after the page is reloaded. So after the above line you could add...
header("Location: $http_url");
You could then check to see if it has been set.
...or you could push the value into the Session as well...
$_SESSION['UID'] = $_REQUEST['cuser'];
Hope this helps.
|
|
|
|
|
|
I just tried that link and it doesn't go anywhere...
|
|
|
|
|
I am doing a project that i feel stuck especially on data normalization. i.e my data is so wide that i am cofused on how to arrange them i.e primary key,forign key,e.t.c. a sample of my data is;
I have project code, project name,financial year, sector, amount allocated, amount spent,activity to be done and remarks.
|
|
|
|
|
Mutugi from Nairobi wrote: I am doing a project that i feel stuck especially on data normalization
Not the most easiest of subjects. You might want to work through this[^] documentation.
It'd be helpfull if you post follow-ups in the database-forum
I are Troll
|
|
|
|
|
Can any body help me to write small script to get google photo result by php.
That is meaning I need to write script to get the result from google photo search so these information I get it I can after that use it on other things.
|
|
|
|
|
Hello all.
Am having a major problem with my code.I cant find an error in the code but i keep getting this messages
"Warning: mysql_query() expects parameter 2 to be resource, null given in C:\xampp\htdocs\nicks\includes\database.php on line 223
Warning: mysql_query() expects parameter 2 to be resource, null given in C:\xampp\htdocs\nicks\includes\database.php on line 202
Warning: mysql_num_rows() expects parameter 1 to be resource, null given in C:\xampp\htdocs\nicks\includes\database.php on line 203
Warning: mysql_query() expects parameter 2 to be resource, null given in C:\xampp\htdocs\nicks\includes\database.php on line 251
Warning: mysql_query() expects parameter 2 to be resource, null given in C:\xampp\htdocs\nicks\includes\database.php on line 194
Warning: mysql_num_rows() expects parameter 1 to be resource, null given in C:\xampp\htdocs\nicks\includes\database.php on line 195
Warning: mysql_query() expects parameter 2 to be resource, null given in C:\xampp\htdocs\nicks\includes\database.php on line 261
Warning: mysql_query() expects parameter 2 to be resource, null given in C:\xampp\htdocs\nicks\includes\database.php on line 202
Warning: mysql_num_rows() expects parameter 1 to be resource, null given in C:\xampp\htdocs\nicks\includes\database.php on line 203"
and the php code is
<?php
require_once("constants.php");
class MySQLDB
{
var $connection;
var $num_active_user;
var $num_active_guests;
var $num_members;
function MySLQDB()
{
$this->connection = mysql_connect(DB_SERVER, DB_USER, DB_PASS) or die (mysql_error());
mysql_select_db(DB_NAME, $this->connection) or die(mysql_error());
$this->num_members = -1;
if(TRACK_VISITORS)
{
$this->calcNumActiveUsers();
$this->calcNumActiveGuests();
}
}
function confirmUserpass($username, $password)
{
if(!get_magic_quotes_gpc())
{
$username = addslashes($username);
}
$q = "SELECT password FROM members WHERE username = '$username'";
$result = mysql_query($q, $this->connection);
if(!$result || (mysql_num_rows($result) < 1))
{
return 1;
}
$dbarray = mysql_fetch_array($result);
$dbarray['password'] = stripslashes($dbarray['password']);
$password = stripslashes($password);
if($password == $dbarray['password'])
{
return 0;
}
else
{
return 2;
}
}
function confirmUserID($username, $userid)
{
if(!get_magic_quotes_gpc())
{
$username = addslashes($username);
}
$q = "SELECT id FROM members WHERE username = '$username'";
$result = mysql_query($q, $this->connection);
if(!$result || (mysql_num_rows($result) < 1))
{
return 1;
}
$dbarray = mysql_fetch_array($result);
$dbarray['id'] = stripslashes($dbarray['id']);
$userid = stripslashes($userid);
if($userid == $dbarray['id'])
{
return 0;
}
else
{
return 2;
}
}
function usernameTaken($username)
{
if(!get_magic_quotes_gpc())
{
$username = addslashes($username);
}
$q = "SELECT username FROM members WHERE username = '$username'";
$result = mysql_query($q, $this->connection);
return (mysql_num_rows($result) > 0);
}
function usernameBanned($username)
{
if(!get_magic_quotes_gpc())
{
$username = addslashes($username);
}
$q = "SELECT username FROM members WHERE username = '$username'";
$result = mysql_query($q, $this->connection);
return (mysql_num_rows($result) > 0);
}
function addNewUser($username, $password, $email)
{
$time = time();
if(strcasecmp($username, ADMIN_NAME) == 0)
{
$ulevel = ADMIN_LEVEL;
}
else
{
$ulevel = USER_LEVEL;
}
$q = "INSERT INTO members VALUES ('$username', '$password', '0', $ulevel, '$email', $time)";
return mysql_query($q, $this->connection);
}
function updateUserField($username, $field, $value)
{
$q = "UPDATE members SET ".$field." = '$value' WHERE username = '$username'";
return mysql_query($q, $this->connection);
}
function getUserInfo($username)
{
$q = "SELECT * FROM members WHERE username = '$username'";
$result = mysql_query($q, $this->connection);
if(!$result || (mysql_num_rows($result) < 1))
{
return NULL;
}
$dbarray = mysql_fetch_array($result);
return $dbarray;
}
function getNumMembers()
{
if($this->num_members < 0)
{
$q = "SELECT * FROM members";
$result = mysql_query($q, $this->connection);
$this->num_members = mysql_num_rows($result);
}
return $this->num_members;
}
function calcNumActiveUsers()
{
$q = "SELECT * FROM active_users";
$result = mysql_query($q, $this->connection);
$this->num_active_users = mysql_num_rows($result);
}
function calcNumActiveGuests()
{
$q = "SELECT * FROM active_guests";
$result = mysql_query($q, $this->connection);
$this->num_active_guests = mysql_num_rows($result);
}
function addActiveUser($username, $time)
{
$q = "UPDATE members SET timestamp = '$time' WHERE username = '$username'";
mysql_query($q, $this->connection);
if(!TRACK_VISITORS) return;
$q = "REPLACE INTO active_users VALUES ('$username', '$time')";
mysql_query($q, $this->connection);
$this->calcNumActiveUsers();
}
function addActiveGuest($ip, $time)
{
if(!TRACK_VISITORS) return;
$q = "REPLACE INTO active_guests VALUES ('$ip, '$time')";
mysql_query($q, $this->connection);
$this->calcNumActiveGuests();
}
function removeActiveUser($username)
{
if(!TRACK_VISITORS) return;
$q = "DELETE FROM ACTIVE_USERS WHERE username = '$username'";
mysql_query($q, $this->connection);
$this->calcNumActiveUsers();
}
function removeActiveGuest($ip)
{
if(!TRACK_VISITORS) return;
$q = "DELETE FROM ACTIVE_GUESTS WHERE ip = '$ip'";
mysql_query($q, $this->connection);
$this->calcNumActiveGuests();
}
function removeInactiveUsers()
{
if(!TRACK_VISITORS) return;
$timeout = time()-USER_TIMEOUT*60;
$q = "DELETE FROM ACTIVE_USERS WHERE timestamp < $timeout";
mysql_query($q, $this->connection);
$this->calcNumActiveUsers();
}
function removeInactiveGuests()
{
if(!TRACK_VISITORS) return;
$timeout = time()-GUEST_TIMEOUT*60;
$q = "DELETE FROM ACTIVE_GUESTS WHERE timestamp < $timeout";
mysql_query($q, $this->connection);
$this->calcNumActiveGuests();
}
function query($query)
{
return mysql_query($query, $this->connection);
}
};
$database = new MySQLDB;
?>
any help will be appreciated thanks
|
|
|
|
|
I can't be 100% sure but it sounds like the constructor method is never actually called. I believe this because $this->connection is null when passed to the mysql_query method. The only reason I can think of is if the constructor is not called, if it had been and failed to initialize you would get an invalid resource exception.
Try renaming it to:
function __construct()
{
}
|
|
|
|
|
here's my code... this is intended to display a query result in a table but i am getting unwanted characters and no table was displayed... what could be wrong with my codes? here it is... thanks in advance..
<html>
<body>
<?php
if (isset($_POST['btnSearch'])) {
//connection to the database
$connection = mysql_connect('localhost', 'root', '');
if (!$connection)
die(mysql_error());
//select database
if (!mysql_select_db('bbs', $connection))
die(mysql_error);
$SearchOpt = $_POST['SearchOption'];
if (empty($SearchOpt))
die("You did not select field.");
$SearchKey = $_POST['txtKey'];
if (empty($SearchKey))
die("You did not enter a keyword.");
$sqlQuery = mysql_query("SELECT * FROM t_board WHERE $SearchOpt LIKE '%$SearchKey%' ORDER BY registerTime DESC;");
if(!$sqlQuery)
die(mysql_error());
if (mysql_num_rows($sqlQuery)) {
echo "<tbody>";
$recs = mysql_fetch_array($sqlQuery) or die(mysql_error());
foreach($recs as $rec) {
echo "<tr>";
echo "<th>" . $rec['index'] . "</th>";
echo "<th>".$rec['subject']."</th>";
echo "<th>".$rec['writer']."</th>";
echo "<th>".$rec['registerTime']."</th>";
echo "</tr>";
}
echo "</tbody>";
}
}
?>
</body>
</html>
|
|
|
|
|
You might want to try changing this:
$sqlQuery = mysql_query("SELECT * FROM t_board WHERE $SearchOpt LIKE '%$SearchKey%' ORDER BY registerTime DESC;");
to this:
$sqlQuery = mysql_query("SELECT * FROM t_board WHERE $SearchOpt LIKE '%" . $SearchKey . "%' ORDER BY registerTime DESC;");
Also, make sure your request is POSTing the correct parameters:
How many records exist in $recs after you run the query? Try print count($recs);
|
|
|
|
|