Jump to content

Recommended Posts

Sorry messed up the code while editing. Try again with this please.

 

<?php 
require_once("includes/session.php");
include('includes/connection.inc.php');
include('includes/corefuncs.php');
$conn = dbConnect('query');
  

$min = 42;
	$max = 118;
	$disallowed = array(117);

function mt_rand_n($min="1",$max,$disallowed) {
    if (!is_array($disallowed)) return false;
    $numbers = array_values(array_diff(range($min,$max),$disallowed));
    if (count($numbers) < 1) return false;
    return $numbers[mt_rand(0,count($numbers) - 1)];
    }

    $id_rand = mt_rand_n($min, $max, $disallowed);
    var_dump($id_rand);
    $sql = "SELECT feed_id,user_nickname,gender,image_normal,user_age,user_location,user_status FROM feed WHERE feed_id='$id_rand' ";
$result = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_assoc($result);


?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>fresaOno | <?php echo $row['user_nickname']; ?>'s home page</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<!--[if IE 5]>
<style type="text/css">
/* place css box model fixes for IE 5* in this conditional comment */
.thrColFixHdr #sidebar1 { width: 180px; }
.thrColFixHdr #sidebar2 { width: 190px; }
</style>
<![endif]--><!--[if IE]>
<style type="text/css">
/* place css fixes for all versions of IE in this conditional comment */
.thrColFixHdr #sidebar2, .thrColFixHdr #sidebar1 { padding-top: 30px; }
.thrColFixHdr #mainContent { zoom: 1; }
/* the above proprietary zoom property gives IE the hasLayout it needs to avoid several bugs */
</style>
<![endif]-->
<style type="text/css">
<!--
.style2 {
/*
color: #FF00FF;*/
color: #DC143C;
font-weight:bold;
font-family: Geneva, Arial, Helvetica, sans-serif;
font-size: 14px;
background-color:transparent;
}
.style3 {
color:	#4169E1;
font-family: Geneva, Arial, Helvetica, sans-serif;
font-weight:bold;
font-size:12px;
background-color:#ECF1EF;
}

div #dude {
color:pink;
font-family: Geneva, Arial, Helvetica, sans-serif;
font-weight:bold;
font-size:16px;
background-image:url(images/me4.png);
background-repeat:no-repeat;
width:480px;
}
.style6 {
font-family: Geneva, Arial, Helvetica, sans-serif;
font-weight: bold; }

div #score {
font-family: Geneva, Arial, Helvetica, sans-serif;
font-weight:bold;
font-size:30px;
color:#FF3300;
}
div #links, #links1, #links2{
font-family: Geneva, Arial, Helvetica, sans-serif;
font-size:14px;
font-weight:bold;
background-image:url(images/banner12.png);
background-repeat:no-repeat;
padding-bottom:1%;
/* border-bottom:dotted;*/
}


table, td, tr,th {
background-color:transparent;
}

a{
text-decoration: none;
}

a:link {
color: #0063DC;
}

a:visited {
   color: #0063DC;
}
a:active {
color:red;
}
a:hover {
background-color:#0063DC;
color:white ;
}
.style1 {color: #FF0084}

-->
</style>
</head>

<body>
<body class="thrColFixHdr">

<div id="container">
<div id="header">
  <!-- end #header -->
</div>
<div id="sidebar1">
  
  <form id="logoutForm" name="logoutForm" method="post" action="">   
      <input name="logout" type="submit" id="logout" value="Log out" />
  </form>
  
</div><!-- end #sidebar1 -->
<div id="sidebar2">
</div>
<div id="mainContent">
  <!-- Start change by Edgar November 3 2008-->
<?php 

  // echo "my current session ID: $current_session";   
  // run this script only if the logout button has been clicked
  if (array_key_exists('logout', $_POST)) {
// empty the $_SESSION array
$_SESSION = array();
// invalidate the session cookie
if (isset($_COOKIE[session_name()])) {
  setcookie(session_name(), '', time()-86400, '/');
}

// end session and redirect
session_destroy();
header('Location: http://localhost/');
exit;
}
?>
     
  <!--End change by Edgar October 13 2008-->
    <!-- end #mainContent -->


<div id="dude">
<form id="rating" name="rating" method="post" >
<!--<input type="hidden" name="image_id" value="$image_id" />-->
<center>freseando </center>
  
  <p>
  
  <input type="radio" name="rating" value="1" onClick="this.form.submit()" />good
  <input type="radio" name="rating" value="2" onClick="this.form.submit()" />really good
  <input type="radio" name="rating" value="3" onClick="this.form.submit()" />awesome</p>
  </form>
  </div> <!--controls border at the end of the page --!>
<!-- This clearing element should immediately follow the #mainContent div in order to force the #container div to contain all child floats -->
<div>
  <table width="412" >
    <tr bgcolor="#CCCCCC">
      <td width="317" align="left" valign="top" bgcolor="#FFFFFF" >
      <p><?php echo $row['user_nickname']; ?> / <?php echo $row['user_age'];?> / <?php echo $row['user_status'];?>/
         <?php echo $row['user_location'];?></p>
         <img src="<?php echo $row['image_normal']; ?>"  />      
         <p><?php echo $row['user_feed']; ?></p></td>
      <td width="83" align="left" valign="top" bgcolor="#FFFFFF">
      feed_id : <?php echo $row['feed_id']; ?> 
  
<form id="comment" name="comment" method="post">
      <label for="article" class="style2">Que cuentas</label>
      feed_id : <?php echo $row['feed_id']; ?> 
      <p><textarea name="article" cols="35" rows="4" class="style3" id="article"></textarea></p>
      <p><input type="submit" name="comment" id="comment" value="comment" />
        <input name="message_for" type="hidden" id="message_for" value="<?php echo $row['feed_id'];?>"/>
      </p>
  </form>
<?php
//**************************************************************************
if (array_key_exists('comment', $_POST)) { 

// create database connection
$conn = dbConnect('admin');
  // remove backslashes
  nukeMagicQuotes();
   
  // prepare an array of expected items
  $expected = array('carry_user_id','feed_id','article', 'message_for');
  // make $_POST data safe for insertion into database
  foreach ($_POST as $key => $value) {
    if (in_array($key, $expected)) {
      ${$key} = mysql_real_escape_string($value);
      }
    }
var_dump($article);
  // initialize error array
  $comment_message = array();
  // check length of usecomment

  if (empty($article)) {
    $comment_message[] = 'Please enter your comment';
}

//if (!$comment_message) {
	if ($row['feed_id'] ) {

  	// prepare the SQL query
  	$sql_comment = "INSERT INTO journal (carry_user_id, article, created, message_for)
         			VALUES('$user_id', '$article', NOW(),'$feed_id'')";
        var_dump($sql_comment);

  	// process the query
  	$comment_result = mysql_query($sql_comment) or die(mysql_error());
  	 		}
  }
//******************************************************************
?>
     </td></tr><tr bgcolor="#CCCCCC">
     <th align="left" valign="top" bgcolor="#FFFFFF" >
     
      </th>
      <td align="left" valign="bottom" bgcolor="#FFFFFF">
      
      </td>
    </tr>
  </table>
  
  </div>
  <br class="clearfloat" /> 
  <?php include('includes/footer.php'); ?>

Link to comment
https://forums.phpfreaks.com/topic/157104-mt_rand/page/2/#findComment-828150
Share on other sites

that's ok I did check it still shows the same.

 

fuction generation id 98 and the number insert to message for is 0 (zero) when var_dump($sql_comment); echo this back I get this

 

string(5) "hi 98" string(126) "INSERT INTO journal (carry_user_id, article, created, message_for) VALUES('1', 'hi 98', NOW(),'')"

 

ps: thanks for sticking whit me on this I'm really grateful

Link to comment
https://forums.phpfreaks.com/topic/157104-mt_rand/page/2/#findComment-828164
Share on other sites

sure

var_dump($id_rand);// ----->int(69) 
var_dump($article); //---nothing at all
var_dump($sql_comment);//--->string(0) "" string(121) "INSERT INTO journal (carry_user_id, article, created, message_for) VALUES('1', '', NOW(),'')" 

//but i change var_dump($article) to var_dump($expected) and print the array
array(4) { [0]=>  string(13) "carry_user_id" [1]=>  string(7) "feed_id" [2]=>  string(7) "article" [3]=>  string(11) "message_for" } 

Link to comment
https://forums.phpfreaks.com/topic/157104-mt_rand/page/2/#findComment-828185
Share on other sites

1. put session_start() at the very top of your script.

2. both $article and $row['feed_id'] are empty? Hmm... so does that mean you didn't type anything in the article field? Under $row = mysql_fetch_assoc($result); can you put -

echo $row['feed_id'];

 

You can take out all my var_dumps now.

Link to comment
https://forums.phpfreaks.com/topic/157104-mt_rand/page/2/#findComment-828246
Share on other sites

that is correct I didn't type anything but even if i did the first 3 values are ok just the last one message_for is been a pain...

 

and when i echo back echo $row['feed_id']; after $row = mysql_fetch_assoc($result);

it shows the same value as $id_rand.

 

and I'm using session already because in order for the user to leave a message they must register

require_once("includes/session.php");

//this is the code i have if you want to check it out
<?php
session_start();
ob_start();
// set a time limit in minutes
$timelimit = 40 * 90;
// get the current time
$now = time();
// where to redirect if rejected
$redirect = 'http://localhost/main4.php';
// if session variable not set, redirect to login page
if (!isset($_SESSION['authenticated'])) {
  header("Location: $redirect");
    exit;
  }
// if timelimit has expired, destroy session and redirect
elseif ($now > $_SESSION['start'] + $timelimit) {
  // empty the $_SESSION array
  $_SESSION = array();

  // invalidate the session cookie
  if (isset($_COOKIE[session_name()])) {
    setcookie(session_name(), '', time()-86400, '/');
  }
  // end session and redirect with query string
  session_destroy();
  header("Location: {$redirect}?expired=yes");
  exit;
  }
// if it's got this far, it's OK, so update start time
else {
  $_SESSION['start'] = time();
  $mysession = session_id();
  $session_name = $_SESSION['authenticated'];
  $user_id = $_SESSION['user_id'] ;
  }
?>

Link to comment
https://forums.phpfreaks.com/topic/157104-mt_rand/page/2/#findComment-828465
Share on other sites

because that session.php is another file is just to show you what im using

this are the first few line on the other file msg.php that i posted previously

<?php 
require_once("includes/session.php");
include('includes/connection.inc.php');
include('includes/corefuncs.php');
$conn = dbConnect('query');
.
.
.

Link to comment
https://forums.phpfreaks.com/topic/157104-mt_rand/page/2/#findComment-828476
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.