PHP - Solved. Something Stupid, I'm Sure
I'm sure this is just a stupid mistake, but can someone please help me figure it out?
I have one page with a dropdown that is populated from our database, I have submit to pull through to the next page but nothing shows up on the next page (app/approval). I've tried adding some echo statments, but they all show up blank. Code: [Select] <? require ('includes/getconfig.inc'); require ('includes/auth.inc'); require ('includes/dbfunctions.inc'); include (dirname(__FILE__).'/../includes/menuhead.inc'); include ('apptable_functions.inc'); $sql="SELECT pol_id, pol_policy_number FROM policies"; $result=myload($sql); $items = count($result); $options=""; for($x=0; $x<=$items; $x++) { $id=$result[$x]['pol_id']; $thing=$result[$x]['pol_policy_number']; $options.="<OPTION VALUE=\"$id\">".$thing; } ?> Select a case number to see the payout approval. <br> <form action="app/approval.php" method='post'> <SELECT NAME=pol_policy_number> <?=$options?> </SELECT> <input name="Submit" type="submit" Value="Submit Policy Number"/> </form> <br> Code: [Select] <? require ('includes/getconfig.inc'); require ('includes/auth.inc'); require ('includes/dbfunctions.inc'); $pol_number = $_POST['pol_policy_number']; echo "$pol_number"; ?> Similar TutorialsI'm having problems everything is working fine I have an Include code for php and I put a <div> code in it working with css. It comes up on the page just fine the problem is a strange text that shows up on the page, There was other strange text that it was printing out on the page that I deleted but these two character I can't seem to find where they are in the code looked in the html file, css file and php file: }} maybe it's coming from the css file but I don't know. It shows up on the webpage and kind of is in the way of perfection on the leveling of the page. Anyone have this problem? What should I do? Should I move around the include code in the <body> I just don't know could you help me? EDIT: I solved it! [Edit: Sorry I found my answer by searching for "period", then finding out that it is a string operator, then read about that. Doesn't seem easy to search for ".=" in Google. Thanks] I got some help here earlier, and I can pretty much understand everything, except I don't understand why there is Code: [Select] $recordOptions .= "<option value=\"{$row['id']}\">"; $recordOptions .= " {$row['firstname']} {$row['lastname']}, {$row['gender']}, {$row['dob']}"; $recordOptions .= "</option>\n"; Why does this whole thing break without .= ? I am new to PHP so, sorry if the answer is really obvious. Code: [Select] $recordOptions = ''; $query = "SELECT * FROM people"; $result = mysql_query($query); if(!$result) { $recordOptions = "<option>Error Retrieving Records</option>\n";; } else { while($row=mysql_fetch_assoc($result)) { $recordOptions .= "<option value=\"{$row['id']}\">"; $recordOptions .= " {$row['firstname']} {$row['lastname']}, {$row['gender']}, {$row['dob']}"; $recordOptions .= "</option>\n"; } } ?> <html> <body> <?php echo $confirmMsg; ?><br /> <form action ='' method='post'> I put a snippet up yesterday, and thought it had been solved. It had a typo error, but there is still something wrong. The whole page follows, because it might be easier to see what I am doing. The form successfully inserts a new record OK, but it will not update a record that already exists as is intended. Instead, it always creates another new record. Where can I be wrong? <?php session_start(); // See if logged in member by checking session data if (isset($_SESSION['recid'])) { // Put stored session variables into local php variable $userid = $_SESSION['recid']; $username = $_SESSION['name']; $school = $_SESSION['college']; $payer_email = $_SESSION['payer_email']; $group1 = $_SESSION['group1']; $group2 = $_SESSION['group2']; $group3 = $_SESSION['group3']; $group4 = $_SESSION['group4']; $group5 = $_SESSION['group5']; $group6 = $_SESSION['group6']; } else { ?> <!-- make login box --> <html> <tr> <td> <p> <p> <p></td> </tr> <table style= border align="center" border="1" width="400" height="200"> <td align="center" valign="center">You need to<a href="login_allocate_quiz.php">log in</a>as an administrator to<br /> allocate quizzes to student groups.</td> </table> </html> <?php exit(); } // Set error message as blank upon arrival to page $errorMsg = ""; // Check to see if the form has been submitted if (isset($_POST['equip'])){ //Connect to the database through include include_once "demo_conn.php"; //set variables $equip = $_POST['equip']; $egroup1 = $_POST['egroup1']; $egroup2 = $_POST['egroup2']; $egroup3 = $_POST['egroup3']; $egroup4 = $_POST['egroup4']; $egroup5 = $_POST['egroup5']; $egroup6 = $_POST['egroup6']; //create variables to manipulate filenames in database $lowquip = strtolower($equip); $wordquip = str_replace (" ", "", $lowquip); $bigpic = $wordquip.'big'; $smallpic = $wordquip.'small'; $bigpic = $bigpic.'.jpg'; $smallpic = $smallpic.'.jpg'; $errorMsg = '<font size="-1"><u>ERROR:</u> You have not entered the following required information.'; $nogroup = ((!$egroup1) && (!$egroup2) && (!$egroup3) && (!$egroup4) && (!$egroup5) && (!$egroup6)); $noequip = (!$equip); if ($nogroup) {$errorMsg .= "--- Student Group. (No data was forwarded to the database.)</font>";} else if($noequip) {$errorMsg .= "--- Quiz Name. (No data was forwarded to the database.)</font>";} else {$query = mysql_query("SELECT equip FROM topics WHERE equip = '$equip' AND managerId = '$userid'"); if (mysql_num_rows($query) > 0) mysql_query("UPDATE topics SET egroup1 = '$egroup1', egroup2 = '$egroup2', egroup3 = '$egroup3', egroup4 = '$egroup4', egroup5 = '$egroup5', egroup6 = '$egroup6' WHERE equip = '$equip' AND managerId = '$userid'"); else mysql_query("INSERT INTO topics (managerId, equip, title, url_big, url_small, egroup1, egroup2, egroup3, egroup4, egroup5, egroup6) VALUES ('$userid','$wordquip', '$equip', '$bigpic', '$smallpic', '$egroup1', '$egroup2', '$egroup3', '$egroup4', '$egroup5', '$egroup6')") or die (mysql_error("error 1321")); $URL='make_quiz_list_test4.php'; header ('Location: '.$URL); } } ?> <!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" dir="ltr" lang="en-US" xml:lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /> <meta http-equiv="X-UA-Compatible" content="IE=4"> <!-- IE5 mode --> <meta http-equiv="X-UA-Compatible" content="IE=7.5"> <!-- IE7 mode --> <meta http-equiv="X-UA-Compatible" content="IE=100"> <!-- IE8 mode --> <meta http-equiv="X-UA-Compatible" content="IE=a"> <!-- IE5 mode --> <title>Manager selected quiz list</title> <link rel="stylesheet" href="style.css" type="text/css" media="screen" /> <!--[if IE 6]><link rel="stylesheet" href="style.ie6.css" type="text/css" media="screen" /><![endif]--> <!--[if IE 7]><link rel="stylesheet" href="style.ie7.css" type="text/css" media="screen" /><![endif]--> <script type="text/javascript" src="script.js"></script> </head> <body> <div id="art-page-background-simple-gradient"> <div id="art-page-background-gradient"></div> </div> <div id="art-main"> <div class="art-sheet"> <div class="art-sheet-tl"></div> <div class="art-sheet-tr"></div> <div class="art-sheet-bl"></div> <div class="art-sheet-br"></div> <div class="art-sheet-tc"></div> <div class="art-sheet-bc"></div> <div class="art-sheet-cl"></div> <div class="art-sheet-cr"></div> <div class="art-sheet-cc"></div> <div class="art-sheet-body"> <div class="art-header"> <div class="art-header-png"></div> <div class="art-header-jpeg"></div> <div class="art-logo"> <h1 id="name-text" class="art-logo-name"><a href="#">Safety Testing Online</a></h1> <div id="slogan-text" class="art-logo-text">Safety - The Most Valuable Insurance</div> </div> </div> <div class="art-nav"> <div class="l"></div> <div class="r"></div> <div class="art-nav-center"> <ul class="art-menu"> <li> <a href="../../index.php" class="active"><span class="l"></span><span class="r"></span><span class="t">Home</span></a> </li> <li> <a href="../demo_main.php"><span class="l"></span><span class="r"></span><span class="t">Demonstrations Page</span></a> <ul> </ul> </li> <li> <a href="logout.php"><span class="l"></span><span class="r"></span><span class="t">Admin Logout</span></a> </li> </ul> </div> </div> <div class="art-content-layout"> <div class="art-content-layout-row"> <div class="art-layout-cell art-content"> <div class="art-post"> <div class="art-post-tl"></div> <div class="art-post-tr"></div> <div class="art-post-bl"></div> <div class="art-post-br"></div> <div class="art-post-tc"></div> <div class="art-post-bc"></div> <div class="art-post-cl"></div> <div class="art-post-cr"></div> <div class="art-post-cc"></div> <div class="art-post-body"></div> <div class="art-post-bl"></div> <div class="art-post-br"></div> <div class="art-post-tc"></div> <div class="art-post-bc"></div> <div class="art-post-cl"></div> <div class="art-post-cr"></div> <div class="art-post-cc"></div> <div class="art-post-body"> <div class="art-post-inner art-article"> <table style="table-layout:fixed; width:850px;"> <tr> <td style="text-align:left; width:30px;"> </td> <td style="text-align:left; width:350px;"><font size="+1">Allocation of Woodwork Quizzes to Groups.</font></td> <td style="text-align:left; text-align:center; vertical-align:bottom; width:450px;"><font color="#0000FF">Administrator: <?php echo $username; ?> - <?php echo $school; ?>.</font></td> <td style="text-align:left; width:20px;"></td> </tr> </table> <table style="table-layout:fixed; width:850px;"> <tr> <td style="text-align:left; width:30px;"></td> <td style="text-align:left; vertical-align:bottom; width:800px;"><font color="#FF0000"><?php echo "$errorMsg"; ?></font></td> <td style="text-align:left; width:20px;"></td> </tr> </table> <table style="table-layout:fixed; border:thin; text-align:left; width:850px;"> <tr> <td style="text-align:right; width:35px;"></td> <td style="text-align:left; width:190px;"></td> <td style="text-align:right; width:20px;"></td> <td style="text-align:left; width:210px;"><font color="#FF0000"></font></td> <td style="text-align:right; width:20px;"></td> <td style="text-align:left; width:110px;"></td> <td style="text-align:right; width:20px;"></td> <td style="text-align:right; width:180px;"></td> <td style="text-align:right; width:35px;"></td> </tr> <hr/> <tr> <td rowspan="12"></td> <td rowspan="12"> <br/> <form method="post" enctype="multipart/form-data" action="make_quiz_list_test4.php"> <!--<form method="post" action="< ?php echo $PHP_SELF;?>">--> <select size="25" name="equip" /> <option selected value="">No Quiz Selected</option> <option value="Biscuit Jointer">Biscuit Jointer</option> <option value="Dowelling Machine">Dowelling Machine</option> <option value="Drill Cordless">Drill - Cordless</option> <option value="Drill with Cord">Drill - Power Corded</option> <option value="Pedestal Drill">Drill - Pedestal</option> <option value="Edge Tool Sharpener">Edge Tool Sharpener</option> <option value="General Workshop Safety">General Workshop Safety</option> <option value="Pedestal Grinder">Grinder - Pedestal</option> <option value="Hand Tools">Hand Tools</option> <option value="Jointer">Jointer (fixed)</option> <option value="Jointer Surfacer Combo">Jointer/Surfacer (combo)</option> <option value="Shaper">Shaper (fixed)</option> <option value="Lathe for Wood">Lathe - Wood</option> <option value="Linisher">Linisher</option> <option value="Mortiser with Hollow Chisel">Mortiser - Hollow Chisel</option> <option value="Nailgun for Brads">Nailer - Air (brads)</option> <option value="Planer Portable">Planer - (portable)</option> <option value="Router Portable">Router - Plunge</option> <option value="Router with Sliding Table">Router Table - Slide</option> <option value="Sander Belt">Sander - Belt (fixed)</option> <option value="Sander Disc Belt Combo">Sander - Belt/Disc Combo)</option> <option value="Sander Portable Belt">Sander - Belt (portable)</option> <option value="Sander Disc">Sander - Disc (fixed)</option> <option value="Sander Orbital">Sander - Orbital</option> <option value="Sander Random Orbit">Sander - Random Orbital</option> <option value="Sander Bobbin">Sander - Vertical Spindle</option> <option value="Saw Bandsaw">Saw - Bandsaw</option> <option value="Saw Bench">Saw - Circular (bench)</option> <option value="Saw Portable Circular">Saw - Circular (portable)</option> <option value="Saw Drop or Chop">Saw - Drop (alt Chop)</option> <option value="Saw Drop and Slide">Saw - Drop & Slide</option> <option value="Jigsaw Portable">Saw - Jigsaw (portable)</option> <option value="Saw Panel">Saw - Panel (fixed)</option> <option value="Saw Radial Arm">Saw - Radial Arm</option> <option value="Saw Sabre">Saw - Sabre(portable)</option> <option value="Saw Scroll">Saw - Scroll</option> <option value="Screw Driver Portable">Screwdriver - Portable</option> <option value="Thicknesser">Thickness Planer</option> </td> <td> </td> <td> </td> <td> </td> <td rowspan="7"><br /> <br /> <br /> <input type="checkbox" name="egroup1" value="1" /> <?php echo $group1; ?> <p> <input type="checkbox" name="egroup2" value="1" /> <?php echo $group2; ?> <p> <input type="checkbox" name="egroup3" value="1" /> <?php echo $group3; ?> <p> <input type="checkbox" name="egroup4" value="1" /> <?php echo $group4; ?> <p> <input type="checkbox" name="egroup5" value="1" /> <?php echo $group5; ?> <p> <input type="checkbox" name="egroup6" value="1" /> <?php echo $group6; ?> <p> <input type="submit" value="submit" name="Send Data"> </form> </td> <td></td> <td></td> <td></td> </tr> <tr> <td></td> <td style="border:solid; color:#006600; 1px; padding:10px; text-align:left;"><font size="-1">Select a Quiz Topic from the drop down list on the left. Then go to the check boxes on the right to select all of the groups that are expected to undertake this test. <p>You can select only one quiz each time, but you can select from one to six groups to undertake that quiz. <p>Repeat this process until you have allocated all of the tests that you require each group to complete. <p>If you make a mistake you can delete a quiz allocation <a href="../../under_con.php">here</a> at any time. </font></td> <td></td> <td></td> <td style="color:#006600;"><font size="-1">Go back to the <br /> <a href="member_account.php">main edit page</a>.<br/> <br /> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> </font></td> </tr> <tr> <td></td> <td> <br/> <br/> <br/> <br/></td> <td></td> <td></td> <td></td> </tr> </table> <!-- /article-content --> </div> <div class="cleared"></div> </div> <div class="cleared"></div> </div> </div> </div> </div> </div> <div class="cleared"></div> <div class="art-footer"> <div class="art-footer-inner"> <div class="art-footer-text"> <p><a href="#">Contact Us</a> | <a href="#">Terms of Use</a> | <a href="#">Trademarks</a> | <a href="#">Privacy Statement</a><br /> <?php $time = time () ; //This line gets the current time off the server $year= date("Y",$time); //This line formats it to display just the year echo "Copyright © 2010 - " . $year; //this line prints out the copyright date range, you need to edit 2010 to be your opening year ?> All Rights Reserved.</p> </div> </div> <div class="art-footer-background"></div> </div> <div class="cleared"></div> </div> </div> <div class="cleared"></div> <p class="art-page-footer">Designed by Frank.</p> </div> </body> </html> SOLVED: I'm having trouble with an SQL query via php in building my Viewthread.php file So on the main page you have a list of the Threads and the link I created is like the below <h2><a href='viewthread.php?id='{$row['id']}'> {$row['Title']} </a></h2> Post {$row['id']}<br> If I set the query to an ID that exists the page loads fine $query = mysqli_query($conn, "SELECT * FROM Threads where id='156'") however if I set the id to the GET command the page doesn't load (which should've got the id) $query = mysqli_query($conn, "SELECT * FROM Threads where id=$_GET['id']") I tried casting this to a variable first too $Number = "$_GET['id']" $query = mysqli_query($conn, "SELECT * FROM Threads where id='$Number'") Edited April 2 by Fishcakes I searched the forums and the Internet as a whole looking for more information on this, but all I've turned up is a lot of information on /how/ to use create_function(), not /when/ to use it. For instance: http://en.wikipedia.org/wiki/Lambda_calculus Let me reiterate that I understand how it works in general. However, in several years of PHP programming, even through the development of fairly complex, robust systems, I can only think of one case where I recall creating a dynamic function and even here I feel like it was a design mistake. Of course, I use anonymous functions all the time in JavaScript for callback code. It seems to be used from time-to-time to iterate over and apply transformations to sets, but I don't understand the advantage over foreach() for such a task. So, if someone is so-inclined, would you mind listing a general scenario or two where create_function() is the correct and appropriate solution to the problem? Okay so I've been going over the PHP manual doing test applications as I go along and I came across this issue that honestly totally threw me. I figured it out (after 20 minutes of thinking the world was about to end) so thought I'd post the code and although some experts will simply shake their head others will hopefully see the funny side. So I'm running a simple script iterating through two arrays and outputting some text. Code is below. Code: [Select] <?php for($i = 0;$i < 100;$i++){ for($k =0; $k < 100;$k++){ echo "$i and $k"; } } ?> I'd have expect to get something along the lines of 00 and 01 and 02 and 03 etc... but as you have probably guessed that's not what I was getting. Instead I was getting 0 and 00 and 10 and 20 and 30. Anyway figured it all out now and I'm hanging my head in shame. Code: [Select] $code = array("03","09"); if (!in_array($_POST['CODE'], $code)); message("Sorry, not today"); my $_POST['CODE'] is <input type=hidden name=CODE value='03'> still not being validated.. hmm Quote Notice: Use of undefined constant d - assumed 'd' in /home/rayth/public_html/forum/shout.php on line 11 Strict Standards: date() [function.date]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'UTC' for 'UTC/0.0/no DST' instead in /home/rayth/public_html/forum/shout.php on line 11 Notice: Use of undefined constant F - assumed 'F' in /home/rayth/public_html/forum/shout.php on line 11 Strict Standards: date() [function.date]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'UTC' for 'UTC/0.0/no DST' instead in /home/rayth/public_html/forum/shout.php on line 11 Notice: Use of undefined constant Y - assumed 'Y' in /home/rayth/public_html/forum/shout.php on line 11 Strict Standards: date() [function.date]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'UTC' for 'UTC/0.0/no DST' instead in /home/rayth/public_html/forum/shout.php on line 11 I keep getting this. Line 11: $Date = date(d)." ".date(F)." ".date(Y); Stupid question probably pretty obvious. but.. I am trying to add a href to an image echo And I can't seem to code this right. Here is a text link echo call: Code: [Select] echo '<div id="nav_image_title" align="center" valign="middle" ><a href="'. $sess->url( URL .'index.php?page=shop.browse&category_id=' . $categories[$kp]['category_child_id']). '">'.$categories[$kp]['category_name'].'</a></div>'; And I want to add that "a href" to this image: Code: [Select] echo '<div>'. ps_product::image_tag( $categories[$kp]["category_thumb_image"], "alt=\"".$categories[$kp]["category_name"]."\"", 0, "category") . '</div>'; I not sure if it's just too many hours working today.. But how do I add that link to that image. Thanks for any help anyone can give.. !!! I beleive that my code is "ok" overall, but i am getting a syntax error on lines 6 & 26, pretty sure im making a stupid mistake here, Code is a plugin for a PHP IRC Bot, basically a toggle on/off command via "!radio" to send meta data from the audio stream every 5minutes. <?php require_once('shoutcast_class.php'); $radio = false; class plugRadio{ public static function onCommandRadio( if($radio == false) $radio = true; $dh->reply('3 Info Stream : ON', $event->getName(), $dh->getCommandTrailing()); while($radio == true){ event $event, datahelper $dh = null, $help = 'use !Radio to toggle stream info On/Off') { $display_array = array("Stream Title", "Stream Genre", "Stream URL", "Current Song", "Server Status", "Stream Status", "Listener Peak", "Average Listen Time", "Stream Title", "Content Type", "Stream Genre", "Stream URL", "Current Song"); $radio = new Radio("radio.anonops.ru:8000"); $data_array = $radio->getServerInfo($display_array); $dh->reply('15,1 #RadioPayback | 9,1On Air: '.$data_array[8].' 15,1| 9,1Now Playing: '.$data_array[12].' ', $event->getName(), $dh->getCommandTrailing()); $event->delete(); flush(); sleep(300); } } if($radio == true) $radio = false; $dh->reply('4 Info Stream : OFF', $event->getName(), $dh->getCommandTrailing()); } ?> I am fairly new to php relating to databases so I'm a little uncertain with my current quandry! I am using a component for Joomla to display tables of motorsport results. The programme produces a table in a module position with a number of links, driver name, team name and a view table link. My problem is that my SEO plug-in does not have a compatablity add on for the component and it screws up. I dont need the links, so I am trying to remove them. My question is this: Code: [Select] class TracksHelperRoute { /** * return link to details view of specified event * @param int $id * @param int $xref * @return url */ function getRoundResultRoute($id = 0) { $parts = array( "option" => "com_tracks", "view" => "roundresult" ); if ($id) { $parts['pr'] = $id; } return self::buildUrl( $parts ); } If I remove this bit: Code: [Select] return self::[b]buildUrl[/b]( $parts ); Will that stop the links from being made?? I have removed the link into the application, but I don't want to break the whole component removing code! I'm not sure what I'm doing wrong here. I'm trying to get this to show the schedule for each person in the database. It does show the schedule, but it only shows one day in each box, and it's the last day. So, if the last day is October 28th, it populates every box with the schedule for the 28th. Code: [Select] <?php $query = "SELECT * FROM employees WHERE day > '$current_date' AND day < '$get_date'"; $result = mysql_query($query); while($row = mysql_fetch_array($result)) { $id = $row['id']; $position = $row['position']; $pay_rate = $row['pay_rate']; $total_hours = $row['total_hours']; $total_pay = $row['total_pay']; $start_time = date("g:i a", strtotime($row['start_time'])); $end_time = date("g:i a", strtotime($row['end_time'])); $work_day = date("l", strtotime($row['day'])); $day = date("F j", strtotime($row['day'])); if($end_time == "24:00:00"){ $end_time ="Close";}; $schedule = $start_time ."<br />". $end_time; $first = $row['first_n']; $last = $row['last_n']; if ($work_day == "Monday"){ $name[$last.", ".$first] = $schedule; } if ($work_day == "Tuesday"){ $name[$last.", ".$first] = $schedule; } if ($work_day == "Wednesday"){ $name[$last.", ".$first] = $schedule; } if ($work_day == "Thursday"){ $name[$last.", ".$first] = $schedule; } if ($work_day == "Friday"){ $name[$last.", ".$first] = $schedule; } if ($work_day == "Saturday"){ $name[$last.", ".$first] = $schedule; } if ($work_day == "Sunday"){ $name[$last.", ".$first] = $schedule; } } foreach ($name as $n => $s) { ?> <tr> <td align="left" valign="top"><?php echo $n; ?></td> <td align="left" valign="top"><?php echo $position; ?></td> <td align="center" valign="top"><?php echo $s; ?></td> <td align="center" valign="top"><?php echo $s; ?></td> <td align="center" valign="top"><?php echo $s; ?></td> <td align="center" valign="top"><?php echo $s; ?></td> <td align="center" valign="top"><?php echo $s; ?></td> <td align="center" valign="top"><?php echo $s; ?></td> <td align="center" valign="top"><?php echo $s; ?></td> <td align="right" valign="top"> </td> </tr> <? } ?> Can somebody see what I'm doing wrong? Thanks in advance For some reason both admin and home return home's contents but everything else returns it's own contents... <?php if(!isset($_GET['p'])) { $result = mysql_query("SELECT * FROM body WHERE name='home'"); ?> <script type="text/javascript">alert("home");</script> <?php } else{ $result = mysql_query("SELECT * FROM body WHERE name='" . $_GET['p'] . "'"); ?> <script type="text/javascript">alert("SELECT * FROM body WHERE name='<?php echo $_GET['p']; ?>'");</script> <?php } $row = mysql_fetch_array($result); function changeStuff($str) { $str = str_replace("[link=","<a href='",$str); $str = str_replace("[/link]","</a>",$str); $str = str_replace("[img]http://","<img src='",$str); $str = str_replace("[/img]","' />",$str); $str = str_replace("[b]","<b>",$str); $str = str_replace("[/b]","</b>",$str); return $str; } ?> if(!isset($_GET['p'])) { include("home.php"); } else{ include($_GET['p'] . ".php"); } echo changeStuff($row['content']); ?> There are three rows in my body table. They are as follows 1) (name) = home (content) = this is home page 2) (name) = admin (content) = this is admin page 3) (name) = eq (content) = this is equipment page When $_GET['p'] = home It displays this is home page When $_GET['p'] = admin It displays this is home page When $_GET['p'] = eq It displays this is equipment page The javascript alerts are all displaying the correct information so i don't understand what is fudging it up... Hi. I am making a login script for my website and i want it to also not just check for the username and password but to also check for the value 1 in the field beta. Heres what i got <?php ob_start(); Mysql info // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // Define $myusername and $mypassword $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; // To protect MySQL injection (more detail about MySQL injection) $myusername = stripslashes($myusername); $mypassword = stripslashes($mypassword); $myusername = mysql_real_escape_string($myusername); $mypassword = mysql_real_escape_string($mypassword); $sql="SELECT * FROM $tbl_name WHERE username=md5('$myusername') and password=md5('$mypassword')and beta= '1'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1){ // Register $myusername, $mypassword and redirect to file "login_success.php" session_register("myusername"); session_register("mypassword"); header("location:login_success.php"); } else { echo "Wrong Username or Password Or Not Beta Tester"; } ob_end_flush(); ?> The login fully works but the check for the 1 dont. How whould i do this? all i am doing is trying to left join my column row "to_id" and "from_id" i can successfully left join to_id but once i try to add "from_id" to the "ON" clause it makes all my data blank Code: [Select] SELECT gold_logs.*,name,star FROM gold_logs LEFT JOIN ibf_members ON to_id = ibf_members.id WHERE to_id = 1 That query works fine, but when i try to add my "from_id" column the query works with no error's but no results are shown Code: [Select] SELECT gold_logs.*,name,star FROM gold_logs LEFT JOIN ibf_members ON (to_id = ibf_members.id AND from_id = ibf_members.id) WHERE to_id = 1 So like When somones enter my site it shows them as a guest, but then if they havn't clicked anywere for about 5minutes and then refresh or if somone else refresh it will delete from the active users list because it's been over 5 minutes, but then if that same person refreshes again my script wont catch them as a GUEST AGAIN!! It just shows no one online, none of my if's catch him and put him in the ibf_session table! Code: [Select] //check for cookies //If no username, Is a Guest, Has COOKIE_ID and cookie USER_NAME and COOKIe PASSWORD if(!isset($_SESSION['user_name']) && !isset($_SESSION['is_guest']) && isset($_COOKIE['user_id']) && isset($_COOKIE['user_name']) && isset($_COOKIE['password'])){ $user_cond = "user_name='{$_COOKIE['user_name']}'"; $sql = "SELECT `id`,`user_name`,`approved` FROM users WHERE $user_cond AND `pwd` = '{$_COOKIE['password']}' AND `banned` = '0' "; $result = mysql_query($sql) or die (mysql_error()); $num = mysql_num_rows($result); // Match row found with more than 1 results - the user is authenticated. if ( $num > 0 ) { list($id,$full_name,$approved) = mysql_fetch_row($result); if(!$approved) { echo "YOU FREAKING HACKER"; exit(); } $_SESSION['user_id']= $id; $_SESSION['user_name'] = $full_name; $lol = session_id(); //$minute5 = 30 ? (time() - 30) : (time() - 3600); // mysql_query("DELETE FROM ibf_sessions WHERE running_time < {$minute5}"); mysql_query("INSERT INTO ibf_sessions (id, member_name, member_id, ip_address, running_time, location, member_group) ". "VALUES ('".$lol."', '{$_SESSION['user_name']}', '{$_SESSION['user_id']}', '{$_SERVER['REMOTE_ADDR']}', '".time()."', ". "'Index', '1')") or die(mysql_error()); unset($_SESSION['is_guest']); } } $lol = session_id(); //Thanks if (!$id) { //Create Guest Session ~ if (!isset($_SESSION['user_id']) && @(!$_SESSION['is_guest']) && !isset($_COOKIE['password'])) { //$minute5 = 39 ? (time() - 30) : (time() - 3600); //echo $minute5; // mysql_query("DELETE FROM ibf_sessions WHERE running_time < {$minute5}"); mysql_query("INSERT INTO ibf_sessions (id, member_name, member_id, ip_address, running_time, location, member_group) ". "VALUES ('".$lol."', 'Guest', '0', '{$_SERVER['REMOTE_ADDR']}', '".time()."', ". "'Index', '0')") or die(mysql_error()); $_SESSION['is_guest'] = 'yes'; } } if (isset($_SESSION['user_id']) && !isset($_SESSION['is_guest'])) { mysql_query("UPDATE ibf_sessions SET member_name='{$_SESSION['user_name']}',member_id='{$_SESSION['user_id']}',member_group='1', running_time='".time()."', in_forum='".$f."', in_topic='".$topicid."', location='".$act."' WHERE id='".$lol."'") or die(mysql_error()); } else { mysql_query("UPDATE ibf_sessions SET member_name='Guest',member_id='0',member_group='0', running_time='".time()."', in_forum='".$f."', in_topic='".$topicid."', location='".$act."' WHERE id='".$lol."'") or die(mysql_error()); } Thanks, it might be confusing but re read Hi There I have a simple cms system that I have built but for some reason the login script wont let me login to the cms. Strange thing is the script seems to works on the original database but when I changed the details to a new db it doesnt work. I have made the necessary changes for the connecting to the db etc but it just wont let me login. Can anyone help The url is drmonlinemarketing.com/cms2/loginadmin.php try login with username demo password test thanks shalli Okay, So I have a dropdown box: Code: [Select] <select name="imgsize"> <option value="small">480 x 360</option> <option value="medium">720 x 540</option> <option value="big">1200 x 900</option> <option value="large">1440 x 1080</option> </select> and I have code that gets the size: Code: [Select] $resizeimg = $_REQUEST["imgsize"]; But I cannot get it to work with an if statement: Code: [Select] if ($resizeimg == "large") { } It just comes up with about 50 lines of gibberish. I have used error_reporting(-1); but that is not coming up with any errors. Could anyone help please. Its probably so simple, but my mind is drawing a blank Hi there, Can anyone show me how I can grab the value "c87cc576092fe1a0f5ac3d50091694b4" out of this string, it changes. Also its coming from a socket a $buffer variable, so How can I do this without grabbing everything else aswell, ie all the data after it too Quote $buffer = fgets($fp, 4096); /*** recieve data looks like this - <dd><input type="hidden" name="sid" value="c87cc576092fe1a0f5ac3d50091694b4" /> fclose($fp); } fclose($Handle); If someone could show me how to do this, I think you can do it with the split function, i just dont know how. if someone could show. i'd be SO greatful |