PHP - I'm Getting A Weird Offset On My Data Output...
I'm not even sure how to explain it. I'm linking a team's roster to its coach. Now I'm getting a weird offset issue when I output the roster. It has something to do with the STATUS.
Down below DIV class="roster_player_list", my Status values are 1, 2, 3, or 4, and each is then assigned a word value. My output should look like this (without the arrow and number) : Returning Starter <---- 1 # # # Key Returner <--- 2 # # Varsity Newcomer <--- 3 # # # Key Freshmen <--- 4 # The last "1" (Returning Starter) disappears from my list on both of my test accounts. I should have four Returning Starters instead of three. I've changed a player's status from a 2 to a 1, and the list changed. That player disappeared, the other appeared. Code: [Select] $sql = "SELECT * FROM players as p INNER JOIN schools as s WHERE s.coachFirst='".$current_first."' AND s.coachLast='".$current_last."' AND s.id = p.tid ORDER BY status, playerLast"; $results = mysql_query($sql); echo '<div class="roster">'; $team = mysql_fetch_assoc($results); echo '<div class="roster_team_info">' . $current_first . ' ' . $current_last . ' <div class="school">' . $team['school'] . '</div> <div class="coach">Coach ' .$team['coachFirst'] . ' ' . $team['coachLast'] .'</div> <div>Sectional: ' . $team['sectional'] . '</div> <div>Class: ' . $team['class'] . 'A</div> '; echo '</div>'; echo '<div class="roster_player_list">'; $currentStatus = false; //Flag to detect change in status while($player = mysql_fetch_assoc($results)) { if($currentStatus != $player['status']) { //Status has changed, display status header $currentStatus = $player['status']; echo '<br><b>'; if ($currentStatus == '1') {echo 'Returning Starters';} elseif ($currentStatus == '2') {echo 'Key Returners';} elseif ($currentStatus == '3') {echo 'Varsity Newcomers';} elseif ($currentStatus == '4') {echo 'Key Freshmen';} echo '</b><br>'; } //Display player info echo $player['playerFirst'] . ' ' . $player['playerLast'] . ', ' . $player['feet'] . '\'' . $player['inches'] . '",' . $player['position'] . ', ' . $player['year'] . ';<br>'; } Similar TutorialsHi guys !. My name is AGustin and I live in argentina. Just wanted to know why I am getting this error: Notice: Undefined offset: 1 in C:\wamp\www\conf.php on line 8 from this code: <?php $link = mysql_connect("localhost","root",""); mysql_select_db("usuarios",$link); $palabra = $_GET["q"]; //$palabra = "agus#carban"; $vector = explode("#",$palabra); $consulta = "SELECT * FROM usuario WHERE nombre='".$vector[0]."' AND pass='".$vector[1]."'"; $querry = mysql_query($consulta,$link); $rdo = "No"; if(mysql_num_rows($querry)>0) { $rdo = "Si"; } echo $rdo; ?> I've done all kind of manual debugging I can't manage to solve this ! Hope I can get it working... I'm inserting some data from a CSV file into a database. I'm using mysql_real_escape_string to escape a string and getting some really weird output. ex. input string = Adobe CS5 output = \0\0A\0d\0o\0b\0e\0 \0C\0S\05 I plugged the string into mb_detect_encoding and it told me it was in ASCII and I did a bunch of searching to find out that \0 is a null byte. The only thing I can't figure out is how to convert it to something that won't give me that garbage when I run it through mysql_real_escape_string. I tried mb_convert_encoding($str,"ISO-8859-1","ASCII") and it didn't do anything. Anyone know something I can try?? I have an auto responder in a php order form with the phrase "Our web sites uses a secure order form for customers to purchase products, and services..." When the message is sent, the word 'services' comes out like this: "...products, and 1s." Each instance of the word 'services' is changed to '1s'. Any ideas?
Hey, was just writing rough code for a news feed script, and this error came up: Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 133693565 bytes) in /Applications/XAMPP/xamppfiles/htdocs/cameo/newsfeed.php on line 17 here's the code <?php require_once("vars.php"); //write the query to get the news feed info from the database $query = "SELECT * FROM news_feed"; $result = mysqli_query($dbc, $query); //create beginning tags for the news data table $output = "<table border=\"0\" cellspacing=\"0\" cellpadding=\"3\" name=\"news_data\">"; //display the news feed data $row = mysqli_fetch_array($result); while($row){ $output .= "<tr>" ."<td><h3>".$row['post_title']."</h3>" ."<br />Posted by: ".$row['posted_by']." on ".$row['date']."</td>" ."</tr>" ."<tr>" ."<td>".$row['post_body']."</td>" ."</tr>"; } $output .= "</table>"; echo $output; ?> and heres my vars file if needed <? //common session variables $username = $_SESSION['username']; $is_admin = $_SESSION['is_admin']; //database connection information variables $server = "localhost"; $user = "root"; $pass = ""; $db = "cameo"; //database function variables $dbc = mysqli_connect($server, $user, $pass, $db); //http header and script return variables $index = "/cameo/index.php"; $self = $_SERVER['PHP_SELF']; ?> Hey guys, newbie here love the site, lots of great info, hopefully one of u guys can help me out. i have adapted code from http://www.singhvishwajeet.com/2009/06/25/using-php-to-get-stock-quotes-from-yahoo-finance/ (which is free to use) i have been working on a way to enter a company code, e.g. BARC -barclays bank, on one page then on another im trying to serahc the yahoo csv for a number of specific numbers that are "live" and then output them on my site, which in turn i shall work with but i cant seem to out put the data, its the $stat bit im struggling with i will attach the files, hopefully someone can help me Hi, I have an image (a weather map) which is created using php which pulls data from a mysql database. I would like to be able to output the result image as a gif or jpg file. Can anyone suggest how this could be done? Many thanks, Simon Hello, I seem to have some problem with my script that has a goal of outputting data about the file size when a filename is queried.
The sql table name is file
The table columns are as followed: id | name | mime | size
The file name is stored in name. The script that i have that gets the file name is:
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html;charset=utf-8" /> <meta name="generator" content="Adobe GoLive" /> <title>File Select</title> <!--The following script tag downloads a font from the Adobe Edge Web Fonts server for use within the web page. We recommend that you do not modify it.--><script>var __adobewebfontsappname__="dreamweaver"</script><script src="http://use.edgefonts.net/aguafina-script:n4:default.js" type="text/javascript"></script> </head> <body> <div id="title"> <h3 align="center">File Upload</h3> </div> <form action="result.php" method="post" name="fileID" target="_self" class="inp" AUTOCOMPLETE="ON"> <h1> <!--Input file name--> <label for="fileID">File Name: </label> <input type="text" name='file1' id='sampleID' list="samp"> </input><br> <datalist id="samp"> <?php $connect = mysql_connect('localhost', 'root', ''); mysql_select_db("test_db"); $query = mysql_query("SELECT * FROM `file` ORDER BY `file`.`name` ASC LIMIT 0 , 30"); WHILE ($rows = mysql_fetch_array($query)): $File_name = $rows['name']; echo "<option value=$File_name>$File_name/option> <br>"; endwhile; ?> </datalist> <input type="submit" class="button" > </form> </body> </html> Hi all, I'm recent working on my php to extract some data from mysql database. Is it possible to output the database data into <a href> turn to the hyperlink instead of using http://mysite.freesite.com/mydatalink.com to this http://mydatalink.com? The script I have made so far is doing something wrong and I can't be able to find the solution. here's the current code: <?php session_start(); define('DB_HOST', 'localhost'); define('DB_USER', 'mydbuser'); define('DB_PASSWORD', 'mydbpass'); define('DB_DATABASE', 'mydbname'); $errmsg_arr = array(); $errflag = false; $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } $db = mysql_select_db(DB_DATABASE); if(!$db) { die("Unable to select database"); } function clean($var) { return mysql_real_escape_string(strip_tags($var)); } $username = clean($_GET['user']); if($errflag) { $_SESSION['ERRMSG_ARR'] = $errmsg_arr; echo implode('<br />', $errmsg_arr); } else { $insert = array(); if(isset($_GET['user'])) { $insert[] = 'username = \'' . clean($_GET['user']) .'\''; } if (count($insert)>0) { $names = implode(',',$insert); if($username) { $qrytable1="SELECT id, links FROM mydatalist WHERE username='$username'"; $result1=mysql_query($qrytable1) or die('Error:<br />' . $qry . '<br />' . mysql_error()); while ($row = mysql_fetch_array($result1)) { echo '<p id="images"> <a href="images.php?id='.$row['id'].'">Images</a></td> | <a href="' . $row["links"] . '">Link</a> </td>'; } } } } ?> I don't want to adding an <a href> into the first echo statement, because I am stored the links in the database which you can see that I am using ['links']. I need to ouput the data from the db to turn into hyperlink. If anyone could assist with this I'd be very grateful! Thanks, Mark trying to create a simpleprogram that will read a text file and output information and calculations using the data in the text file. I have 4 radio buttons which represent an item Number. when one is selected the output form should print to a table the ID,Part,Count, Price, and the inventory Value= ($count * $price), can anyone tell me what i am doing wrong? This is what the .txt file looks like: AC1000:Hammers:122:12.50 AC1001:Wrenches:5:5.00 AC1002:Handsaws:10:10.00 AC1003:Screwdrivers:222:3.00 Here's what i have so far: Code: [Select] <?php $inf = 'infile.txt'; $FILEH = fopen($inf, 'r') or die ("Cannot open $inf"); $inline = fgets($FILEH,4096); $found = 0; //$ptno = //if (isset($_POST['AC1000']) || isset($_POST['AC1000']) || isset($_POST['AC1000']) || isset($_POST['AC1000'])) { while (!feof($FILEH) && !($found)){ list($ptno,$ptname,$num,$price) = split (':', $inline); if ($ptno == $id) { print '<table border=1>'; print '<th> ID <th> Part <th> Count <th> Price'; print "<tr><td> $ptno </td><td>$ptname</td>"; print "<td> $num </td><td> \$price</td><tr>"; print '</table>'; $found = 1; } $inline = fgets($FILEH,4096); } if ($found !=1) { print "Error: PartNo=$id not found"; } fclose ($FILEH); ?> Hey Guys, I'm struggling with some logic of how to do something wondering if anyone can point me in the right direction. Details: I am making a PHP/MySQL game to learn more PHP, I've got my login/logout system created. However I am planning on the game been map based on a 100x100 grid. I have two tables: USERS Username, Password, x, y Test, Test, 1, 1 MAP X, Y, type 0,1,1 0,2,1 0,3,2 0,4,3 0,5,2 etc I am stuck on how to get the user's logged in X and Y coordinates and then compare them with the map table X and Y, to see what type of field to show, 1,2 or 3. Is there a name for this type of function so I can do some research on it? Or could someone give me an example? Would be fantastic if anyone has any advice. Thanks in advance NewcastleFan Hi guys, is there anyway to process this $result from a mysql query inside PHP so that the data below will be formatted to a pivot-like table? The number of rows and columns of the output 'table' will be indefinite. Thanks so much! Data: ID Row Col Name 1 1 A A1 2 2 A A2 3 3 A A3 4 1 B B1 5 2 B B2 6 3 B B3 7 1 C C1 8 2 C C2 9 3 C C3 Results: A1(1) A2(2) A3(3) B1(4) B2(5) B3(6) C1(7) C2( C3(9) Well I have a script that executes a scan on a system set to run infinitely, and I need it to echo out a message each time it loops through, but I don't want it to echo out the message with the next loop message below it, and the next one below that etc... I've tried using the flush(); function and been messing around with that with no luck. For security reasons I don't want to release any of the processing code, but here is the basic construction of the script: <?PHP ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** $RepeatIt = -1; for($g=1; $g!=$RepeatIt+1; $g++) { ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** $ScanMessage = ":.:.: SCANNING THE HITLIST FOR MOBSTER: ".$MobName." (SCAN #$g) :.:.:"."<br/><br/>"; echo $ScanMessage; ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** } ?> At the moment it's returning: :.:.: SCANNING THE HITLIST FOR MOBSTER: DEUS EX DESTROYER (SCAN #1) :.:.: :.:.: SCANNING THE HITLIST FOR MOBSTER: DEUS EX DESTROYER (SCAN #2) :.:.: :.:.: SCANNING THE HITLIST FOR MOBSTER: DEUS EX DESTROYER (SCAN #3) :.:.: :.:.: SCANNING THE HITLIST FOR MOBSTER: DEUS EX DESTROYER (SCAN #4) :.:.: So what I want it to do is just delete the scanning message and replace it with the next scan message so while running this script you would see just the number increment on the same line. Any suggestions? Thanks. hey guys im in a bit trouble trying to use window offset() function.
basically i have a fixed header and what im trying to accomplish is for when the user scroll past a certain point the header content will change...im not sure if im going about this the right way or even sure if it is possible with a fixed header.
any help would be grateful thank you
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> <style type="text/css"> body{ margin:0px; background:#FFFFFF; } .header-cont { width:100%; position:fixed; top:0px; } .header { height:50px; background:#F0F0F0; border:1px solid #CCC; width:960px; margin:0px auto; } .content { width:960px; background: #F0F0F0; border: 1px solid #CCC; height: 2000px; margin: 70px auto; } </style> <script> $(window).scroll(function(){ var position = $('#position').offset().top; if ($(window).scrollTop() > position) { alert('hey'); // Change header content } }); </script> </head> <body> <div class="header-cont"> <div>FIXED HEADER</div> </div> <br /> <div id='position'></div> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> CONTENT HERE! </body> </html> I need the following format for dat and time: date("Y-m-d H:i:s"); Now, I know the time offset and want to adjust the above. Let's say the GMT time offset is 1. How do I adjust it using the code above? I tried as an example date("Y-m-d H:i:s",3600); but that adjusted the time by 8 hours! I have an array, $old_array, that looks like this (each line is a different index): 1|1|0|20|0|0 1|2|0|20|0|0 1|3|0|20|0|0 1|4|0|20|0|0 1|5|0|20|0|0 1|6|0|20|0|0 1|7|0|20|0|0 33|3|0|15|0|0 33|4|0|15|0|0 33|5|0|15|0|0 34|1|0|15|0|0 34|2|3|15|0|0 34|3|2|15|0|0 34|4|3|15|0|0 34|5|0|15|0|0 34|6|2|15|0|0 34|7|0|15|0|0 It is an array of strings, which are exploded to create other arrays. Anyways, then I have a foreach loop like this: foreach($old_array as $val) { $check = substr($val, 0, strpos( $val,'|',strpos($val,'|')+1)); $array_temp[ $check ] = TRUE; } I am getting this error (ONLY IN INTERNET EXPLORER!): Warning: strpos() [function.strpos]: Offset not contained in string in /home/pgagnon/public_html/chores_uni.html on line 131 Line 131 is this one: $check = substr($val, 0, strpos( $val,'|',strpos($val,'|')+1)); Why does this work in Firefox, Opera, Safari, Chrome, but not IE?? Microsoft can eat shit until it dies! instead of js alert displaying the timezone offset, i would like the content of get_time_zone_offset() to be used as a php variable.
<script type="text/javascript"> function get_time_zone_offset( ) { var current_date = new Date(); return -current_date.getTimezoneOffset() / 60; } alert("The local time zone is: GMT " + get_time_zone_offset()); </script> Could someone here explain me the reason for this error in detail..... FYI - i am just more than a fresher in PHP..... Code: [Select] Fatal error: Cannot use string offset as an array Hello, my script worked great with no errors until I had to migrate to a new server, which is using cpanel/WHM, I have run Apache update and ensured curl is installed but I keep getting this in the error log. Here is part of the code, the error is PHP Notice: Undefined offset: 2 in /home/username/public_html/control/ajax/actions/currently_playing.php on line 59 and here is that section of code (line 59 is labled) Code: [Select] // Diaplays when sever is online but no song title } else { $title = str_replace('\'', '`', $split[6]); $title = str_replace(',', ' ', $title); $title = "$title"; // Diaplays song } } if($title) { $tmp = explode(" - ", $title); $artist = trim(str_replace("`", "'", $tmp[0])); $album = trim(str_replace("`", "'", $tmp[1])); $title = trim(str_replace("`", "'", $tmp[2])); //LINE 59 HERE $request = $this->albumGetInfo($artist, $album); $img = $request["album"]["image"][1]["#text"]; When I enable error_reporting this notice appear: Notice: Undefined offset: 1 This is code: function get_value_of($name) { $lines = file("../config.php"); $val = array(); foreach (array_values($lines) AS $line) { list($key, $val) = explode('=', trim($line) ); if (trim($key) == $name) { $val = convEnt($val); return $val; } } return false; } Error is in this line: list($key, $val) = explode('=', trim($line) ); How to fix this? |