Re: help with sessions please
Posted: Wed Jan 12, 2011 10:17 am
still with the original problem ...
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
<?php
session_start();
$_SESSION['int'] = 1;
$_SESSION['string'] = "String";
$int = $_SESSION['int'];
$string = $_SESSION['string'];
if ($int == 1) {
echo "Saw the int";
} else {
echo "No int :(";
}
if ($string == "String") {
echo "Saw the string";
} else {
echo "No string :(";
}
?>
Code: Select all
if ($string = "String") {Code: Select all
if ($string == "String") {I literally posted it and pressed edit as soon as it was posted noticing this one, you guys give me no time lol.Benjamin wrote:Note the missing =Should be:Code: Select all
if ($string = "String") {Code: Select all
if ($string == "String") {
This one wasn't my fault, i had aCode: Select all
echo "No int <img src="./images/smilies/icon_sad.gif" alt=":(" title="Sad" />"; } if ($string == "String") { echo "Saw the string"; } else { echo "No string <img src="./images/smilies/icon_sad.gif" alt=":(" title="Sad" />";
Code: Select all
<?php
session_start();
$_SESSION['int'] = 1;
$_SESSION['string'] = "String";
$int = $_SESSION['int'];
$string = $_SESSION['string'];
if ($int == 1) {
echo "Saw the int.";
} else {
echo "No int found.";
}
if ($string == "String") {
echo "Saw the string.";
} else {
echo "No string found.";
}
?>
Code: Select all
<?php
session_start();
// I have put this equal to 'french' I assume that this is a valid username in rsusername, if not please change!
$_SESSION['string'] = "french";
$username = $_SESSION['string'];
$query = "SELECT userid FROM rsusername WHERE username='$username';";
$result = mysql_query($query);
if (!$result) {
echo "Got nothing";
} else {
echo "Got something";
}
?>
Code: Select all
<?php require_once('Connections/recommendingpeople.php'); ?>Code: Select all
<?php require_once('Connections/recommendingpeople.php'); ?>
<?php
mysql_select_db($database_recommendingpeople, $recommendingpeople);
$query_username = "SELECT * FROM username";
$username = mysql_query($query_username, $recommendingpeople) or die(mysql_error());
$row_username = mysql_fetch_assoc($username);
$totalRows_username = mysql_num_rows($username);
session_start();
// I have put this equal to 'french' I assume that this is a valid username in rsusername, if not please change!
$_SESSION['string'] = "french";
$username = $_SESSION['string'];
$query = "SELECT userid FROM username WHERE username='$username';";
$result = mysql_query($query);
if (!$result) {
echo "Got nothing";
} else {
echo "Got something";
}
mysql_free_result($username);
?>Yes sorry I forgot about connections, good spot.timoteo wrote:had to include at top:Code: Select all
<?php require_once('Connections/recommendingpeople.php'); ?>
Is this not done in 'Connections/recommendingpeople.php'? lol.timoteo wrote: mysql_select_db($database_recommendingpeople, $recommendingpeople);
Code: Select all
<?php
require_once('Connections/recommendingpeople.php');
mysql_select_db($database_recommendingpeople, $recommendingpeople);
session_start();
// I have put this equal to 'french' I assume that this is a valid username in rsusername, if not please change!
$_SESSION['string'] = "french";
$username = $_SESSION['string'];
$query = "SELECT userid FROM rsusername WHERE username='$username';";
$username = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_assoc($username);
if (!$result) {
echo "Got nothing";
} else {
echo $row['userid'];
}
?>Code: Select all
<?php require_once('Connections/recommendingpeople.php'); ?>
<?php
mysql_select_db($database_recommendingpeople, $recommendingpeople);
$query_username = "SELECT * FROM username";
$username = mysql_query($query_username, $recommendingpeople) or die(mysql_error());
$row_username = mysql_fetch_assoc($username);
$totalRows_username = mysql_num_rows($username);
session_start();
// I have put this equal to 'french' I assume that this is a valid username in rsusername, if not please change!
$_SESSION['string'] = "french";
mysql_select_db($database_recommendingpeople, $recommendingpeople);
$query_username = "SELECT * FROM username";
$username = mysql_query($query_username, $recommendingpeople) or die(mysql_error());
$row_username = mysql_fetch_assoc($username);
$totalRows_username = mysql_num_rows($username);
$username = $_SESSION['string'];
$query = "SELECT userid FROM username WHERE username='$username';";
$result = mysql_query($query);
if (!$result) {
echo "Got nothing";
} else {
echo "Got something";
}
?>Code: Select all
<?php
require_once('Connections/recommendingpeople.php');
// I have put this equal to 'french' I assume that this is a valid username in rsusername, if not please change!
$username = "french";
mysql_select_db($database_recommendingpeople, $recommendingpeople);
$query = "SELECT * FROM username WHERE username='$username';";
$result = mysql_query($query, $recommendingpeople) or die(mysql_error());
$row = mysql_fetch_assoc($result);
if (!$result) {
echo "Got nothing";
} else {
echo $row['userid'];
}
?>