Jump to content

jcbones

Staff Alumni
  • Posts

    2,653
  • Joined

  • Last visited

  • Days Won

    8

Everything posted by jcbones

  1. No need for a function here, unless you just want it. echo "<td><a href=\"delete.php?mID={$row['mID']}&Title={$row['Title']}\" onclick=\"return confirm('Are you sure you want to delete {$row['Title']} from the Database?')\">"; echo "<img border=0 src='images/delete.gif'>" . "</a></td></tr>";
  2. I get no parse errors on that code.
  3. Your query should look like: mysql_query("DELETE FROM messages WHERE message_id='$id' AND to_user = '$userfinal'");
  4. <?php $i = 29; $j = 11; $m = 10; $j = ($j - 4) / 2; //11 - 4 = 7 divided by 2 = 3.5 ($j is now 3.5) $m += $j * 10; //3.5 multiply by 10 = 35 plus 10 = 45 ($m is now 45) echo "m = ".$m."<br>"; //m = 45 ?> m = 45 not 40.
  5. It should work, that is your server name. You should try $_SERVER['REMOTE_HOST'] or maybe gethostbyaddr()
  6. You are asking it to display all of that data for each message Id there is in the database. Your problem starts here: for($count = 1; $count <= $num_messages; $count++) Find everything that is inside of that loop, and it will display that, everytime the loop runs. Which, like I said, is everytime it finds a message id in the database. PS> Beat by Pik again!
  7. Let me know if it doesn't work, please specify any problems fully. <table width="823" cellspacing="0" id="mytable" summary="User Transactions Summary"> <caption>Transaction Summary</caption> <tr> <th width="136" class="nobg" scope="col" abbr="Merchant Name">Merchant Name</th> <th width="154" scope="col" abbr="Order Value">Order Value</th> <th width="145" scope="col" abbr="Comm">Cash Back</th> <th width="278" scope="col" abbr="Status">Status</th> </tr> <?php $result = mysql_query("SELECT t.*, m.percent FROM transactions JOIN merchants ON t.m_affid = m.m_affid WHERE u_id = '$u_id' ORDER BY t.order_date DESC LIMIT 10 "); echo mysql_error() ; while($row = mysql_fetch_assoc($result)){ $m_name = $row['m_name']; $orderval = $row['order_val']; $status = $row['order_status']; $per = $row['percent']; $com1 = $orderval / 100; $com2 = $com1 * $per; $u_comm = round($com2,2); ?> <tr> <th scope="row" abbr="<?php echo $m_name;?>" class="spec"><?php echo $m_name;?></th> <td class="alt">&pound<?php echo $orderval ;?></td> <td class="alt">&pound<?php echo $u_comm ;?></td> <td class="alt"><?php echo $status ;?></td> </tr> <?php }?> </table>
  8. Refresh sends the data back to the page again. That is why you get a pop up that ask "do you wish to resend the data". or thereabouts. Three things you can do. 1. Re-direct the page to itself after the database insertion. This clears the data out of the headers, so on refresh it will not send the data back to the page. 2. Set a session variable that limits the amount of time between comments. This agitates the user, and they usually don't sit there and wait for the timer to run out. 3. Check the comment against the last one the user supplied to the database, if it is the same, deny it. This creates and extra query to the database. The first one is the most logical, although it creates more server load. On a system that isn't seeing 100's of pages an hour, it is no big deal. This is the way that dreamweaver deals with the problem. And no, the echo loop has nothing to do with it. It is the insertion code you are dealing with.
  9. Yes, those videos will teach you how to build a database optimally.
  10. I suggest a series of videos on data logic modeling, and normalization.
  11. That is not an error, just a warning. Just add: date_default_timezone_set() date_default_timezone_set('America/New_York'); To the top of your script.
  12. For the array problem, use this line. Why do you go to the Gym: <?php echo implode(',',$_POST["whyGym"]); ?><br> For the email problem, use this line: <form action='mailto:<?php echo $Email; ?>?subject=user comments' method='post'enctype='text/plain'>
  13. That is known as a web beacon. Calling a php image file that stores data about the user. Web Beacon
  14. So replace that line: $result = mysqli_query($con,$query) or trigger_error($query . '<br/>MySQL error: ' . mysql_error()); //-----------> error line
  15. Instead of password protecting the directory, just deny it to everyone. No password request will be sent, it will just deny access. Being that PHP is the server, it can still access those files with includes. [.htaccess] order deny, allow deny from all
  16. You are not parsing them in PHP. idName: <?php echo $idName; ?>\n; //etc.
  17. $variable = 'DOUBLE QUOTED STRING'; $str[] = 'This $variable will not be parsed, and will print out to the page.'; $str[] = "This $variable will be parsed, and will print out the contents of the variable to the page."; $str[] = "This {$variable} is the same as above."; echo implode('<br/>',$str); Test it out.
  18. <form method="post" action="test1.php"> <label>TYPE: <select name="field"> <option value = "sid">StudentID</option> <option value = "sname">StudentName</option> </select> </label> <label>WORD: <input type="text" name="searchword" /> </label> <input type="submit" name="submit" value="Submit" /> </form> test1.php <?php if (isset($_POST['submit'])){ $con = mysqli_connect("localhost","root","",'uni'); $field= $_POST['field']; $searchword = $_POST['searchword']; $query = "SELECT * FROM student WHERE $field = '$searchword'"; $result = mysqli_query($con,$query) or die ('error data'); //-----------> error line if(mysqli_num_rows($result) > 0) { echo"<table>"; echo "<tr><th>StudentID</th><th>StudentName</th></tr>"; while($row = mysqli_fetch_array($result,MYSQLI_ASSOC)){ echo "<tr><td>"; echo $row['sid']; echo "</td><td>"; echo $row['sname']; echo "</td></tr>"; } echo"</table>"; } } mysql_close($con); ?>
  19. Just to help you out a little bit. Strings in single quotes are parsed as literal text. Strings in double quotes are checked for variables.
  20. Tested. <?php if(isset($_GET['submit'])) { $day = $_GET['day']; echo date('l F jS, Y',strtotime('last ' . $day)); } ?> <form action=""> <select name="day"> <option>Monday</option> <option>Tuesday</option> <option>Wednesday</option> <option>Thursday</option> <option>Friday</option> <option>Saturday</option> <option>Sunday</option> </select> <input type="submit" name="submit" value="submit"/> </form>
  21. WAMPServer is your friend.
  22. Try: (not sure if it will work). "SELECT * from counts where female=1 and $race_age > age_start"
  23. I would put the items in the session as a multi-dem array, then you just add them to the cart from there. No need to hit the items table. //set the session. $_SESSION['items'][$item][$price] = $quantity; //now just send it to the database; foreach($_SESSION['items'] as $product => $v) { foreach($v as $price => $quantity) { setlocale(LC_MONETARY,'en_US'); $total = money_format("%i",$price * $quantity); $sql = "INSERT INTO cart (userID,products,total,date) VALUES ('$id','$product','$total','$date')"; } Code is for demo purposes only, it is incomplete, and un-tested.
  24. send.php //header redirect. header('Location: http://mydomain.com/index.php?sent=1'); index.php $message = NULL; if(isset($_GET['sent'])) { $message = 'Sent Successfully!'; } //decide on your message location, and echo the request. echo $message; *Warning - while you were typing a new reply has been posted. You may wish to review your post. * And it is amazingly similar.
  25. Why do you drop out of double quotes in order to splice in a variable to the echo statement. Double quotes tell the parser to parse that line, so any variables it finds will be populated. Single quotes are faster in processing as the parser doesn't even look at that line, just spits it out to the browser. Your example <?php ... echo "<table id=GuestBookEntry><tr>" . "<td class=n>$n</td>" . "<td class=d>$d</td>" . "</tr>"; if($s != "none"){ echo "<tr>" . "<td colspan=2 class=s><b>Site: </b><a href=\"$s\">$s</a></td>" . "</tr>"; } echo "<tr><td colspan=2 class=m>$m</td></tr></table>"; ... ?> Just sayin~.
×
×
  • 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.