PHP - Fieldset And Legend Not Working
Alright so what im trying to say probably wont make much sense so I have also setup a live demo that I will explain at the end.
I have a file upload form (that works). While uploading the file it tests agains a few things but mainly to see if the file has already been uploaded into the database by anyone. If it has I want to return an error inside a fieldset with a legend that says "Error". The problem is the fieldset or legend do not show up and I dont know why. The demo: I have created a test account for this, you will need to go to: http://www.nipnotes.com/login.php and login with the username: test and password: test then click on upload note at the top of the page go through the processs uploading anything (.rtf .doc .docx .txt format). Then try and upload that exact same file again and you will see an error in red text. I want that error to be inside the fieldset with the legend "Error". I dont know if my tired eyes missed something small or I just completly fked it up but ill post the code for that section below. Code: [Select] <div id="container" class="clear"><!-- ####################################################################################################### --> <div id="content"> <?php // Edit the uploader into here $query = "SELECT * FROM catagories ORDER BY name ASC"; $uploadLocation = $_SERVER ['DOCUMENT_ROOT'] . "/uzEr Upl0ds/"; ?> <form id="upload" action="<?php echo $_SERVER ['PHP_SELF']; ?>" method="post" name="fileForm" class="login" enctype="multipart/form-data"> <?php if ($session->logged_in) { ?> <table class="uploadForm"> <tr> <td><label>Select The Program The Note Is For:</label></td> </tr> <? $res = mysql_query ( $query ) or die ( mysql_error () ); ?> <tr> <td><select name="drop_1" id="drop_1"> <option value="" selected="selected" disabled="disabled">Select a Program</option> <?php getTierOne (); ?> </select></td> </tr> <tr> <td><label for="code">Select The Course Code/Name</label></td> </tr> <tr> <td><span id="wait_1" style="display: none;"> <img alt="Please Wait" src="images/ajax-loader.gif" /> </span> <span id="result_1" style="display: none;"></span> </tr> </td> </td> </tr> <tr> </tr> <tr> </tr> <tr> <td><label> Note Title eg. Police Foundations</label></td> </tr> <tr> <td><input name="title" type="text" /></td> </tr> <input type="hidden" name="author" value="<? $session->username; ?>" /> <tr> <td><input name="upfile" type="file" size="36".></td> </tr> <tr> <td align="center"><br /> <input class="login" type="submit" name="submitBtn" value="Upload" /></td> </tr> </table> </center> <?php } else { //user is not logged in echo "<p>Sorry, but you must be logged in to upload notes. If you already have account you can login <a href=\"login.php\">here</a>. If you do not yet have an account you can register a free account <a href=\"register.php\">here</a> its fast and enables all the features this website has to offer."; } if (isset ( $_POST ['submitBtn'] )) { if ($_FILES ['upfile'] ['tmp_name'] != "") { if (! empty ( $_POST ['title'] )) { ?> <div id="caption">RESULT</div> <div id="icon2"> </div> <div id="result"> <table width="100%"> <fieldset><legend>Error</legend> <?php //run basic md5 check now to quick flush out options $newmd5 = md5_file ( $_FILES ['upfile'] ['tmp_name'] ); switch (firstMd5Check ( $newmd5, $session->username )) { case 1 : $target_path = $uploadLocation . basename ( $_FILES ['upfile'] ['name'] ); $ext = end ( explode ( '.', $_FILES ['upfile'] ['name'] ) ); function generatePassword($length = 8) { // start with a blank password $password = ""; // define possible characters - any character in this string can be // picked for use in the password, so if you want to put vowels back in // or add special characters such as exclamation marks, this is where // you should do it $possible = "_12346789abcdfghjkmnpqrtvwxyzABCDFGHJKLMNPQRTVWXYZ"; // we refer to the length of $possible a few times, so let's grab it now $maxlength = strlen ( $possible ); // check for length overflow and truncate if necessary if ($length > $maxlength) { $length = $maxlength; } // set up a counter for how many characters are in the password so far $i = 0; // add random characters to $password until $length is reached while ( $i < $length ) { // pick a random character from the possible ones $char = substr ( $possible, mt_rand ( 0, $maxlength - 1 ), 1 ); // have we already used this character in $password? if (! strstr ( $password, $char )) { // no, so it's OK to add it onto the end of whatever we've already got... $password .= $char; // ... and increase the counter by one $i ++; } } // done! return $password; } $filename = generatePassword (); $filename = $filename . "." . $ext; $filelocation = $_SERVER ['DOCUMENT_ROOT'] . "/uzErUpl0ds/" . $filename; $allowed = "doc docx rtf txt pdf xls"; $allow = explode ( " ", $allowed ); if (in_array ( $ext, $allow )) { if (move_uploaded_file ( $_FILES ['upfile'] ['tmp_name'], $filelocation )) { //TODO: Insert date regex format and make the catagory selection auto// $uid = $_POST ['catagory']; $name = $_POST ['title']; $author = $session->username; $pid = $_POST ['drop_1']; $cat = $_POST ['tier_two']; $dt1 = date ( "Y-m-d" ); $size = filesize ( $filelocation ); $query = "INSERT INTO newnotes (uid, name, catagory, location, author, date, filesize,pid,md5) VALUES ('$uid', '$name', '$cat', '$filename', '$author', '$dt1','$size','$pid','$newmd5')"; //die ($query); $res = mysql_query ( $query ) or die ( mysql_error () ); echo "<div style=\"color:#057820\";>The file: " . basename ( $_FILES ['upfile'] ['name'] ) . " has been uploaded! It will be reviewed and if possible you will be granted credits within the next 24 hours."; } else { echo "There was an error uploading the file, please try again!"; } } else { //invalid extenion type echo "<div style=\"color: #F00\";>It appears that you have tried to upload an invalid file type. We accept the types " . $allowed . " if this appears to be a mistake on our end or you have a file type that should be allowed you can contact us <a href=\"contact.php\">here</a></div>"; } break; case 2 : //file is already in newnotes could be a possible double click $query = "UPDATE users SET warnings = warnings + 100 WHERE username = '" . $session->username . "'"; if (mysql_query ( $query ) or die ( mysql_error () )) { echo "<p style=\"color: #F00\";> The file you are trying to upload is already in the queue to be verified. This could be the result of double click and for which we will not ban you. This has been noted and if in the future your account continues to encounter this issue further action will be taken. Please make sure you are only clicking the submit button. If you have any issues you can contact us <a href=\"contact.php\">here</a></p>"; } break; case 0 : //user uploaded a file that either he has uploaded or has downloaded ban him. $query = "UPDATE users SET warnings = warnings + 1 WHERE username = '" . $session->username . "'"; if (mysql_query ( $query ) or die ( mysql_error () )) { $reason = "You have tried to upload a note that has either been uploaded previously by you or that you have downloaded before in the past."; if (banUser ( $session->username, $reason )) { echo "<div style=\"color: #F00\";> " . $reason . " As a result your account has been banned. You may appeal to have your account unbanned once by going he <a href=\"appeal.php\">appeal</a> It is recommended you bookmark that link until you are ready to apeal because you will not find it anywhere else.</div>"; } } break; ?> <?php } } else { //no file name was gi echo "<div style=\"color: #F00\";>You either forgot to enter a note name or entered one to short, please go back and try again.</div>"; } } else { echo "<div style=\"color: #F00\";>You forgot to select a file to upload, please try again.</div>"; } echo "</fieldset></form></table></div>"; } else { echo "</form>"; } ?> <!-- Content Ending Div --> </div> Similar Tutorials I wish to display a text field with two buttons under it, and I want one of the button on the leftmost part (that’s very easy because that's the default), and the other on the rightmost part (this I don’t really know how to implement this). I am currently using something like this : <!DOCTYPE html> <html> <head> <title>Title</title> </head> <body> <fieldset> <input name="words" type="text" id="words" size="60" /><br><br> <input type="button" id="lb" name="leftbutton" value="leftbutton" /> <input type="button" id="rb" name="rightbutton" value="rightbutton" /> </fieldset> </body> </html> With this kind of code, I can adjust the number of to make the other button fit on the far right, but that’s obviously not the right way to do things. Perhaps I should use a table ? How ? http://paste.ee/p/OhiWv
The above is a link to a readable version of my code. The XMLHTTPREQUEST worked, and the array was pulled down. Was able to print out the undecoded/unparsed array. However, immediately afterwards, all code stops working.
<script> var xhr; if (window.XMLHttpRequest) { // Mozilla, Safari, ... xhr = new XMLHttpRequest(); } else if (window.ActiveXObject) { // IE 8 and older xhr = new ActiveXObject("Microsoft.XMLHTTP"); } xhr.open("POST", "PHPLibrary/selectMemberResults.php", true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.send(); xhr.onreadystatechange = display_data; var $phparray function display_data() { if (xhr.readyState == 4) { if (xhr.status == 200) { //alert(xhr.responseText); $phparray = xhr.responseText; document.getElementById("suggestion").innerHTML = $phparray; // // //......................................................? // The above line of code is the last thing to print or // to do anything that returns to the browser.... //.......................................................? // All lines below do nothing............................? // } else { //alert('There was a problem with the request.'); } } } document.write("Length of phparray Array :" + $phparray.length + "<"); var output = JSON.parse($phparray, function (key,val) { if ( typeof val === 'string' ) { // regular expression to remove extra white space if ( val.indexOf('\n') !== -1 ) { var re = /\s\s+/g; return val.replace(re, ' '); } else { return val; } } return val; } ); document.write("Length of Array :" + $output.length + "<"); for (var i=0; i < $output.length; i++) { document.getElementById("suggestion").innerHTML = $output[i].MEMBER_NAME; } </script> i dont understand what is wrong plz help me.
here is code
$name = "img/".rand(1,9999999).".png"; $myFile = $name; $fh = fopen($myFile, 'w') or die("can't open file"); $stringData = $html; fwrite($fh, $stringData); fclose($fh); $file=$name; $fst=file_get_contents($file); $im=imagecreatefromstring($fst); imagefilter($im, IMG_FILTER_GRAYSCALE); imagefilter($im, IMG_FILTER_NEGATE); //Convert to Grey Scale for($i=0;$i<123;$i++){ for($j=0;$j<50;$j++){ $px=imagecolorat($im,$i,$j); if($px<0x303030){ imagesetpixel($im,$i,$j,0); }else{ imagesetpixel($im,$i,$j,0xffffff); } } } $database = unserialize(@file_get_contents("db.txt")); if($database === false) $database = array(); // modify the database if needed if($_SERVER['REQUEST_METHOD'] == 'POST'){ if($_POST['submit'] == 'Add') $database[$_POST['ident']] = substr($_POST['letter'], 0, 1); if($_POST['submit'] == 'Del') unset($database[$_POST['ident']]); if($fh = @fopen('db111.txt', 'w+')){ fwrite($fh, serialize($database)); fclose($fh); } }else{ $newimage = true; } $width = 130; $height = 40; $captcha_gridstart =1; $captcha_gridspace =2; $letters = findletters($im, $width, $height, $captcha_gridstart, $captcha_gridspace); $count = count($letters); $cellw = ($count > 0) ? intval(100 / $count) : 0; //dispeckle the image and GET co-ordinates of the characters of captcha image and return them. function findletters($image, $width, $height, $gridstart, $gridspace){ $offsets = array(); $o = 0; $atstartx = true; for($x = 0; $x < $width; $x++){ $blankx = true; for($y = 0; $y < $height; $y++){ if(imagecolorat($image, $x, $y) == 0){ $blankx = false; break; } } if(!$blankx && $atstartx){ $offsets[$o]['startx'] = $x; $atstartx = !$atstartx; }else if($blankx && !$atstartx){ $offsets[$o]['endx'] = $x; $atstartx = !$atstartx; $o++; } } $count = $o; for($o = 0; $o < $count; $o++){ for($y = 0; $y < $height; $y++){ $blanky = true; for($x = $offsets[$o]['startx']; $x < $offsets[$o]['endx']; $x++){ if(imagecolorat($image, $x, $y) == 0){ $blanky = false; break; } } if(!$blanky){ $offsets[$o]['starty'] = $y; break; } } for($y = $height-1; $y > $offsets[$o]['starty']; $y--){ $blanky = true; for($x = $offsets[$o]['startx']; $x < $offsets[$o]['endx']; $x++){ if(imagecolorat($image, $x, $y) == 0){ $blanky = false; break; } } if(!$blanky){ $offsets[$o]['endy'] = $y; break; } } } for($o = 0; $o < $count; $o++){ $offsets[$o]['ident'] = ""; for($x = $offsets[$o]['startx'] + $gridstart; $x < $offsets[$o]['endx']; $x += $gridspace){ for($y = $offsets[$o]['starty'] + $gridstart; $y < $offsets[$o]['endy']; $y += $gridspace){ $offsets[$o]['ident'] .= ((imagecolorat($image, $x, $y) == 0) ? "0" : "1"); #echo $offsets[$o]['ident'].'<br>'; } } } return $offsets; } $a=""; foreach($letters as $letter){ $asciiletter = $database[$letter['ident']]; if(!empty($asciiletter)) { $a.=$asciiletter; } } I need bit of help, so I am looking into a plugin created for newsletter where default is it shows ad but it has option to remove ads by checking the check box. Default is to send ads in newsletter but if you don't want to send ads through newsletter then check the box. The problem is, it seems like checkbox selected is not being picked up. Some help would be appreciated. The custom field in wp:
'label' => 'Hide newsletter ads', 'name' => 'hide_ads', 'type' => 'checkbox', 'instructions' => 'Checking the checkbox will remove ads', 'required' => 0, 'conditional_logic' => 0, 'wrapper' => array( 'width' => '', 'class' => '', 'id' => '', ), 'choices' => array( 'Hide newsletter ads' => 'Hide newsletter ads', ), 'allow_custom' => 0, 'default_value' => array( ), 'layout' => 'block', 'toggle' => 0, 'return_format' => 'value', 'save_custom' => 0, ),
This is the php code for it: <!doctype html> <html lang="en-GB"> <head> <meta name="viewport" content="width=device-width" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta name="x-apple-disable-message-reformatting"> <title><?php the_title(); ?></title> <style> <?php require ABSPATH . 'path/newsletter.css'; ?> </style> <!--[if mso]> <style type="text/css"> .outlook-fallback-font { font-family: 'Lucida Bright', 'Cambria', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; } </style> <![endif]--> </head> <?php $hide_newsletter_ads = get_field('hide_ads'); echo $hide_newsletter_ads; ?> <body itemscope itemtype="http://schema.org/EmailMessage"> <div class="wrap"> <?php if (!$hide_newsletter_ads) { include ABSPATH . 'path/ad-banner.php'; } ?> <div class="header"> <a href="<?php bloginfo( 'url' ); ?>"> <img src="<?php echo get_home_url().'logo.png' ?>" alt="News" /> </a> </div> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <?php if ( get_field( 'newsletter_summary' ) ) { ?> <div class="newsletter-summary"><?php the_field( 'newsletter_summary' ); ?></div> <?php } ?> <?php if ( have_rows( 'newsletter_content' ) ) : ?> <?php // Loop through the ACF blocks $count = 0; while ( have_rows( 'newsletter_content' ) ) : the_row(); if ( get_row_layout() === 'story' ) : ?> <?php if ( 0 === $count ) { ?> <span class="date outlook-fallback-font"><?php the_time( 'd M Y' ); ?></span> <?php } ?> <?php if ( get_sub_field( 'story_heading' ) ) : ?> <h1><?php the_sub_field( 'story_heading' ); ?></h1> <?php endif; ?> <div class="content"> <?php the_sub_field( 'story_content' ); ?> </div> <?php endif; if ( 'post_list' === get_row_layout() ) : ?> <?php $posts = get_sub_field( 'post_list' ); if ( $posts ) : ?> </div> <div class="story-list"> <h2><span class="wrap"><?php the_sub_field( 'post_list_heading' ); ?></span></h2> <div class="wrap-table"> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <?php // Output story cards foreach ( $posts as $i => $post ) { if ( 0 === $i % 2 ) { echo '<tr>'; } $class = ( 0 === $i % 2 ) ? 'odd' : 'even'; $image_src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), array( 640, 345 ) ); $image_srcset = wp_get_attachment_image_srcset( get_post_thumbnail_id( $post->ID ) ); echo sprintf( '<td class="story-cell %4$s" valign="top"> <a href="%1$s" class="story-card outlook-fallback-font"> <img src="%3$s" alt="" height="120" style="height: 150px; object-fit: cover;" /> <span>%2$s</span> </a> </td>', esc_url( get_permalink( $post->ID ) . '?utm_source=newsletter&utm_medium=email&utm_campaign=newsletter' ), // permalink esc_html( get_the_title( $post->ID ) ), // title // esc_attr( $image_src[0] ), // image - src esc_attr( $image_src[0] ), // image - src esc_attr( $class ) // class ); if ( 0 !== $i % 2 || count( $posts ) === ( $i + 1 ) ) { echo '</tr>'; } } ?> </table> </div> </div> <div class="wrap"> <?php endif; endif; if (!$hide_newsletter_ads) { (0 === $count) { include ABSPATH . 'path/mpu-1.php'; } if (1 === $count) { include ABSPATH . 'path/mpu-2.php'; } } $count++; endwhile; endif; ?> <div class="footer"> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <td align="left"> © <?php echo esc_html( date( 'Y' ) ); ?> </td> <td class="footer-link"> <a href="<?php echo get_permalink( get_page_by_path( 'privacy-policy' ) ); ?>">Privacy Policy</a> · <a href="%unsubscribe_url%">Unsubscribe</a> </td> </tr> </table> </div> </div> <?php endwhile; endif; ?>
When I echo the POST, it echoes the correct value. The MySQL portion seems to just ignore it all together. I've tried changing the dropdown option to just a text field, same thing occurred. I have text fields right above this particular one that update just fine with the SAME exactly scripting. if POST, update query, done. Works. This one for some reason will not. MySQL portion: if ($_POST['bUpdate']){ mysql_query("UPDATE `Patients` SET `b` = '$_POST[bUpdate]' WHERE `id` = '".$_GET['id']."'"); } echo $_POST['bUpdate']; Form Portion: Code: [Select] <tr onmouseover="color(this, '#baecff');" onmouseout="uncolor(this);"> <td width="310" colspan="2" align="center"><span class="fontoptions">Postcard Status </span><br /> <? if ($data['b'] == 1){ echo '<select name="bUpdate"><option value="1" selected>Yes</option><option value="0">No</option></select>'; } else { echo '<select name="bUpdate"><option value="1">Yes</option><option value="0" selected>No</option></select>'; } ?> </td> </tr> I'm trying to turn this while loop into a for loop and am unable to get my result set to display properly in the for loop. The while works fine I just want to be able to have more control over which information is shown in my table as I loop and was wanting to use a for loop that way I can take advantage of the counter variable while i"m displaying my information. Any help would be appreciated. while ($row = mysql_fetch_assoc($data_result_set)) { echo "<td>".$row["product_id"]."</td>"; echo "<td>".$row["city"]."</td>"; echo "<td>".$row["quantity"]."</td>"; } *** I'm wanting it to look like something like this but can't figure out how to properly work in which row to display with the $i variable. $count=mysql_num_rows($data_result_set); for($i = 0; $i <= $count; $i++){ echo "<td>".mysql_fetch_assoc[$i]["product_id"]."</td>"; echo "<td>".mysql_fetch_assoc[$i]["city"]."</td>"; echo "<td>".mysql_fetch_assoc[$i]["quantity"]."</td>"; } I know the syntax for the for loop is totally off with the method mysql_fetch_assoc just dropped in there like a jerk but I'm just kinda pseudoing it out. Any help would be appreciated. Thanks in advance. Hi, I have the following file structure /.htaccess /index.php /displaypage.php All files are on root. I have following written in .htaccess file Options FollowSymLinks RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([a-z0-9-]+)$ displaypage.php?page=$1 [NC,L] I have following written in displaypage.php echo $_GET["page"]; Now when I run http://localhost/ then it shows index.php page which is correct. If I run http://localhost/something then it shows a blank page. Previously it used to display that "page" variable on screen. mod_rewrite is enabled and I am using Windows with XAMPP. What am I doing wrong? Thanks I just did a huge import from an app I have been working on. No issues except for this. I uploaded & imported all files & databases from my wampserver (localhost, local server) to my main online server. Before I continue with the problem, I have to give you info on how the files work. I am using a "controller" to view the files. Meaning, from index.php, I call all the files. For example, instead of mysite.com/register.php, its mysite.com/index.php?page=register. The index defines the doctype & html tags etc. The other files that are called through index.php are just pure php code, it does not contain the head & body tags etc. So, the issue is , when the surfer submits a form, i need to set a cookie. this cookie is VERY important. I cannot get it to work. I am getting the header warnings after submit Of course, this is to be expected. But I tried it on my local server, & it worked. I am not very familiar with cookies, this is a side of PHP i never really even touched. I know almost everything but that. So the php code is before the html code on the page, so I figured it was worth a shot. Im guessing the problem here is, since the code being outputted as index.php code + the form page code. So the cookie is being set after the html tags. How can I fix this? I need it to work thru the controller. I cannot just make it a single file, all files on the site needs to be thru this controller, otherwise it will mess everything up. Ino I could just add the code from index.php plus the form page code & just run the php code before all of the html tags, but like I said it has to be called thru index.php. I appreciate your replies, & I hope you guys dont think im an idiot & can understand my question, im terrible with words! this wont display there name Code: [Select] $sql = mysql_query("SELECT firstname,lastname FROM myMembers WHERE id='$logOptions_id' LIMIT 1"); while($row = mysql_fetch_array($sql)){ $fn = $row["firstname"]; $ln = $row["lastname"]; $name=("$fn,$ln"); } I'm getting error unknowing colum 'solidsoul' in Where clause why is it refering $player = solidsoul to a colum instead of searching the colum username for solidsoul? <?php //start progress bar check to see if the systemkey on server is greater than the passwordcracker or equal if it is let it go if not stop it $db = mysql_connect ("localhost","removed","removed") or die ("Could Not Connect To Database"); $select = mysql_select_db ('heaven_users') or die ("Could Not Select Database"); $query = mysql_query ("SELECT systemkey FROM members WHERE IPaddress=$ip") or die (mysql_error()); $query2 = mysql_query ("SELECT * FROM members WHERE username=$player") or die (mysql_error()); while ( ($row1 = mysql_fetch_assoc($query)) && ($row2 = mysql_fetch_assoc($query2)) ) { $systemkey = $row['systemkey']; $passwordcracker = $row2['passwordcracker']; } echo $systemkey; echo $passwordcracker; ?> I want to use css and PHP together Let say I have simple PHP page: Code: [Select] <html> <head> <title>Coupon Sample </title> </head> <body> <div id="test"> <?php echo ("Test"); ?> </div> </body></html> Now if I want to add css to this I have two options 1. add css code in head tag 2. add external css file with <link> tag My simple css is Code: [Select] #test { color:orange; } if I am using first option like Code: [Select] <html> <head> <title>Coupon Sample </title> #test { color:orange; } </head> Its working fine, for second option Code: [Select] <title>Coupon Sample </title> <link rel="stylesheet" type="type/css" href="simple.css"/> </head> where simple.css contain css code but its not working.. it shows text in black color instead of orange Does anyone has idea about it. or is their other way to add css in this situation. Thanks in advance Alrighty, I have been working on a simple hit counter and I can't quite get it to work, I am having trouble getting the system to actually display the amount of hits, here is the code for review. This code below is located within the file I call 'count_processor.php' <?php $myfile = "counter/hits.txt"; if(file_exists($myfile)) //Check for file { $var = fopen('$myfile,\'r+\''); //opens in read and write mode our file $visits = fread($var,filesize($myfile)); //puts the content of the file for its whole lenght rewind( $var ); //resets the file position indicator to the beginning $visits++; //increments the actual number of vists by 1 fwrite($var, $visits); //writes in the variable the actual (incremented) value fclose($var);//closes our file reference } else { print "File $myfile doesn't exist..."; Die(); //if the file doesn't exist prompts a warning and kills the script } $message = sprintf("%s recent visitors",$visits); //saves our visits message in a variable ($message) that will be used as output print $message; ?> Now, this small snippet of code is located on the page I want to count hits for, which is the index.php file. This calls upon the above code and in turn renders the data onto the page, but all that is showing up on the index.php page is 'recent visitors' which is the text after the numerical value of visitors is displayed, i.e. "137 recent visitors" <?php include 'counter/count_processor.php'; ?> Any ideas? Thanks! Also, you will notice I am using a flat-file system (.txt), no MySQL database. Hi There, I am trying to create a webpage that displays tasks that need to be completed on specific days. For example, every tuesday, every Friday etc etc. I am finding problems though then I try to display tasks that need to be done on, for example, the first working day of the month. Is there any way that PHP can work out the first working day of the month? Our working days are Monday to Friday. I have a database backend to this that has the following columns if that helps: TASK_NAME TASK_SUMMARY TASK_WEEKDAY TASK_DAY_IN_MONTH TASK_MONTH Happy to change the DB if I need to as it is empty at the moment. Thanks in advance Matt I can't remember a time where I got \n to work since I started PHP a month ago. I'm reading the book PHP and MySQL Web Development, and I'm following a tutorial where the author uses the new line break, I'm doing it just like him, for him it works for me it doesn't. This one for example doesn't work for me: <?php echo "test test test \n Test test test"; ?> And on this one, which is from the book tutorial, the \t WORKS, but the \n doesn't: $outputstring = $date."\t".$tiregty." tires \t".$oilgty." oil\t" .$sparkgty." spark plugs\t\$".$totalamount ."\t". $address."\n"; Did something happen with a PHP update, or is it because of my php.ini file settings? I'm using XAMPP with default settings. And I have PHP version 5.3.1 and the book I'm reading is written for PHP 5.3. Can someone help me get this working <?php include "sessionStore.php"; $userfinal = get_username($_SESSION['user_id']); if ($userfinal[username]) { //checks user is logged in switch ($_GET[friends]) { //allows multiple pages default: $get = mysql_query( "SELECT * FROM `friend_requests` WHERE `username` = '$userfinal' "); //gets requests while ($reqs = mysql_fetch_array($get)) { echo ( "Friend Requests $reqs[by] wants to be friends with you. <a href='newfriends.php?friends=accept&user=$reqs[by]'>Accept</a><br/> <a href='newfriends.php?friends=delete&user=$reqs[by]'>Delete</a>" ); //displays requests and shows accept delete links } break; case 'accept': //accept page if ($_GET[user]) { //get username $add = mysql_query( "INSERT INTO `friends` (`friendname` , `username`, `added`) VALUES ('$_GET[user]' , '$userfinal' , '1') "); // add to your friends list $delete = mysql_query( "DELETE FROM `friend_requests` WHERE `by` = '$_GET[user]' "); // deletes friend request echo ( "$_GET[user] has been added as a friend and the request has been deleted" ); // echos the completion } break; //ends accept page case 'delete': // delete page if ($_GET[user]) { //gets username $delete = mysql_query( "DELETE FROM `friend_requests` WHERE `by` = '$_GET[user]' "); // deletes friend request echo ( "$_GET[user]'s request has been deleted" ); // echos completion } break; //ends delete page } // ends switch } else { echo ( "You need to be logged in" ); // not logged in } ?> OK, i've used it before, but for some reason it's not working. I have 2 pages PAGE 1 (bfbc2.php) Code: [Select] <?php $url = 'http://api.bfbcs.com/api/pc'; $value = $_GET['playername']; $postdata = "players=$value&fields=basic"; $ch = curl_init($url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata); $data = curl_exec($ch); curl_close($ch); $data = json_decode($data,true); $player = $data['players']; $stuff = $player['0']; $rank = $stuff['rank']; echo ('<img src="http://www.oskgaming.com/images/bfbc2ranks/'.$rank.'.jpg" />'); ?> PAGE 2 (test.html) Code: [Select] <img src="http://www.oskgaming.com/images/bfbc2.php?playername=Lark.s"> if I type http://www.oskgaming.com/images/bfbc2.php?playername=Lark.s I get the image requested if type http://www.oskgaming.com/test.html I get a broken image. Any ideas? Did I make a mistake somewhere? I mean come on. It's going to be some comma or misplaced period. I"m getting the following error: Quote Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/jwrbloom/public_html/metroindybasketball.com/resources/11league.php on line 28 Line 28 is the WHILE statement. : ( Code: [Select] $query = 'SELECT * FROM fallLeague10 WHERE confirm = "y" ORDER BY team,feet DESC,inches DESC,nameLast'; $results = mysql_query($sql) or trigger_error('MySQL error: ' . mysql_error()); $currentTeam = false; while($line = mysql_fetch_assoc($results)) { if($currentTeam != $line['team']) { //Status has changed, display status header $currentStatus = $line['team']; echo '<tr><td colspan="6"><hr></td></tr>'; } echo '<tr> <td></td> <td><b>' . $line['nameFirst'] . ' ' . $line['nameLast'] . '</b></td> <td><center>'. $line['feet'] . '\'' . $line['inches'] . '"</center></td> <td><center>'. $line['grade'] . '</center></td> <td>'. $line['school'] . '</td>'; echo '<td><b>'. $line['college'].'</b></td>'; echo '</tr>';} echo '</tbody></table>'; HELP This isnt working , what did i do wrong? Code: [Select] else if (isset($_SESSION['idx']) && $logOptions_id == $id) { // If SESSION idx is set, AND it does equal the profile owner's ID $interactionBox = '<br /><br /><div class="interactionLinksDiv"> <a href="#" onclick="return false" onmousedown="javascript:toggleInteractContainers(\'friend_requests\');">Friend Requests</a> </div><br />'; $the_blab_form = ' <textarea id="add-status"class="status" onkeyup="limitText(this,350,'.character-count');detect_url(this.value);" onclick="limitText(this,350,'.character-count');detect_url(this.value);"></textarea><div><input class="button post" type="button" value="Post" id="<?php print $session?>" onClick="add_post(this.id)"/><div class="character-count">350</div> '; hello, the following is pulling all my records. is it written wrong? Code: [Select] $result4 = mysql_query("SELECT * FROM schedule WHERE eid = '$posteid' AND status = 1 OR status = 2 ORDER BY date, starttime"); |