PHP - Unable To Echo A Sum( )
Code: [Select]
<?php function checking_out() { $conn = db_connect(); $nickname=$_SESSION['valid_user']; $query="select sum(price) from preorders where name='".$nickname."'"; $result = $conn->query($query); if ($result) { echo '<h1>'.$result.'</h1>'; } } ?> This is not working, there is no result in the browser, any idea ? Similar Tutorialshow do i get the image to show as the code i have is echoing what i have been told is binary, not confirmed. and not the images. all images are .jpg Code: [Select] $allowed_types = array('png','jpg','jpeg','gif'); $imgdir = '/home/mysite/ftpfolder'; $imgFilesArray = scandir($imgdir); foreach ($imgFilesArray as $imgkey => $imgvalue) { $imgInfo = pathinfo($imgdir . '/' . $imgvalue); $imgExtension = $imgInfo['extension']; if(in_array($imgExtension, $allowed_types)) { readfile($imgdir . '/' . $imgvalue); //echo '<img src = "'. $imgdir .'/'. $imgInfo['basename'].'" alt="" />'; } } images are FTP'd to the ftpfolder and can not be placed anywhere else but this folder due to security reasons. hi there, the code below is suppose to display something like the attachement "code2" but instead it displays something like attachement "code1" please assist in find what is wrong with my echo lines.
<?php $counter = 2; $sqlq="select * from state WHERE status = 0 "; $categorysqlq = mysql_query($sqlq); $varq = mysql_num_rows($categorysqlq); while($catfetchq = mysql_fetch_array($categorysqlq)) { $cnty = $catfetchq[0]; $sqllq="select * from vehicle WHERE country = '$cnty' "; $categorysqllq = mysql_query($sqllq); $numsql = "select * from branchaddr WHERE state = '$cnty' "; $numquery = mysql_query($numsql); $varqa = mysql_num_rows($numquery); $cntyfetchq= mysql_fetch_array($numquery); if($varq != 0){ if($counter == 2){ echo "<tr><td><a href=\"transport2.php?id=".$cntyfetchq['state'].">".$catfetchq[1]."(<span style=\"color:red\">".$varqa."</span>)</a></td>"; $counter--; } else{ echo "<td><a href=\"transport2.php?id=".$cntyfetchq['state'].">".$catfetchq[1]."(<span style=\"color:red\">".$varqa."</span>)</a></td></tr>"; $counter = 2; } } } ?>Attached Files code1.png 12.65KB 0 downloads code2.png 25.34KB 0 downloads OK, have no idea what's going on... I've done this a million times... why wont this output!?? I must have a major brain meltdown and dont know it yet!!! Code: [Select] <?php // this echoes just fine: echo $_POST['testfield']; // but this wont echo: echo if (isset($_POST['testfield'])) { $_POST['testfield'] = $test; } echo $test; /// or even this DOESNT echo either!: $_POST['testfield'] = $test; echo $test; ?> Hi All, I'm trying to echo the response from an SLA query, the query works and returns the data when I test it on an SQL application.. but when I run it on my webpage it won't echo the result. Please help? <?php $mysqli = mysqli_connect("removed", "removed", "removed", "removed"); $sql = "SELECT posts.message FROM posts INNER JOIN threads ON posts.pid=threads.firstpost WHERE threads.firstpost='1'"; $result = mysqli_query($mysqli, $sql); echo {$result['message']}; ?> So I need to echo a row from my database with php, but where i need to echo is already inside an echo. This is my part of my code: $con = mysql_connect("$host","$username","$password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("main", $con); $result = mysql_query("SELECT * FROM Vendor"); while($row = mysql_fetch_array($result)) { //I need to echo right here .................. but I get a blank page when I try this. Please Help. echo '<option value=$row['vendor_id']>'; echo $row['vendor_id']; echo '</option>'; } mysql_close($con); Result: A Blank page. Thanks in advance! I have a log system that allows 10 logs on each side(Left and right). I am trying to make it so that the left side has the 10 most recent logs, then the right as the next 10. Any ideas? Hi
I try to echo out random lines of a html file and want after submit password to whole content of the same html file. I have two Problems.
1st Problem When I echo out the random lines of the html file I don't get just the text but the code of the html file as well. I don't want that. I just want the text. How to do that?
for($x = 1;$x<=40;$x++) { $lines = file("$filename.html"); echo $lines[rand(0, count($lines)-1)]."<br>"; }I tried instead of "file("$filename.html");" "readfile("$filename.html");" But then I get the random lines plus the whole content. Is there anything else I can use instead of file so that I get the random lines of text without the html code?P.S file_get_contents doesn't work either have tried that one. 2nd Problem: As you could see in my first problem I have a file called $filename.html. After I submit the value of a password I want the whole content. But it is like the program did forget what $filename.html is. How can I make the program remember what $filename.html is? Or with other words how to get the whole content of the html file? My code: if($_POST['submitPasswordIT']){ if ($_POST['passIT']== $password ){ $my_file = file_get_contents("$filename.html"); echo $my_file; } else{ echo "You entered wrong password"; } }If the password isn't correct I get: You entered wrong password. If the password is correct I get nothing. I probably need to create a path to the file "$filename.html", but I don't know exactly how to do that. Hello, I've never really used the update command before for mysql and I'm attempting to use it and struggling a little bit. I'm trying to use mysqli prepared statements.. here's the code that I have thus far: if($query = $database->connection->prepare("UPDATE videos SET comments=?, views=?, uploader=? WHERE title = ?")) { $query->bind_param('iiss', $comments, $views, $uploader, $title); $query->execute(); $result = $query->affected_rows; $query->close(); } For some reason I cannot get this working. I have created a modification page for the administrators to be able change any of the values and wanting to update the database to reflect the changes. When using the MySQL UPDATE command do all of the values have to get changed or modified, or am I able to pass back some of the same values? Like with the above code.. if I only wanted to update the views, would I still be able to just pass in the same values for comments and uploader and it would just replace the values? Hi all,
I am not sure why my header is not displaying the header image after using the CSS
I have a png file that repeats horizotally.
Please help
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Wikigets The online store</title> <style type="text/css"> body { margin:0 px;} #pageTop { background: url(style/headerline1.png); height:110 px; } </style> </head> <body> <div id="pageTop"> </div> <div id="pageMiddle"></div> <div id="pageBottom"></div> </body> </html> headerline1.png 2.82KB 0 downloads headerline1.png 2.82KB 0 downloads I get the unable to jump to row zero mysql error. Code: [Select] function is_admin($uid, $cid) { $uid = (int)$uid; $cid = (int)$cid; $sql = "SELECT `users`.`id` AS `uid`, `companies`.`companyid` AS `cid`, `companies`.`adminid` AS `aid` FROM `companies` LEFT JOIN `users` ON `users`.`id` = companies.adminid WHERE `users`.`id` = {$uid} AND `companies`.`companyid` = {$cid}"; $user = mysql_query($sql); return (mysql_result($user, 0) == '1') ? true : false; } Hey guys, After my php script a HTML code follows. But i can't edit the HTML code because it isn't recognised. It does show up, however i can't edit it. Problem: Unable to edit HTML code below php scripts Code: <?php function createNewFile($name,$mail,$subject,$comments,$count,$date,$other="",$up="0") { global $settings; $header=implode('',file('header.txt')); $footer=implode('',file('footer.txt')); $content=' ?> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>'.$subject.'</title> <meta content="text/html; charset=windows-1250"> Thanks in advance I have written my index.php script where after verifying the password the script displays the user's name. But the user name is not displayed by it. Here is my script Hello....I am using ajax,jquery with php to insert data in db.....but the script is not working. form.html: Code: [Select] <!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=utf-8" /> <title>Untitled Document</title> <style type="text/css"> label{ display:block; } </style> <script type="text/javascript" src="jquery-1.5.min.js"> </script> <script type="text/javascript"> $(function() { $('#submit').click(function(){ $('#container').append('<img src="ajax-loader.gif" id="loading" alt="image" />'); var name=$('#name').val(); var email=$('#email').val(); var d=$('#d').val(); var m=$('#m').val(); var y=$('#y').val(); var add=$('#add').val(); var phone=$('#phone').val(); $.ajax({ url: 'process.php', type: 'POST', data: 'name=' + name + '&email=' + email + '&d=' + d + '&m=' + m + '&y=' + y + '&add=' + add + '&phone=' + phone, success: function(result){ $('#response').remove(); $('#container').append('<p id="response">' + result + '</p>'); $('#loading').fadeOut(500,function(){ $(this).remove(); }); } }); return false; }); }); </script> </head> <body> <h2>User Registeration</h2> <form action="process.php" method="POST"> <div id="container"> Name:<br> <input type="text" name="name" id="name" /><br> Email:<br> <input type="text" name="email" id="email" /><br> Date Of Birth:<br> <input type="text" id="d" name="d" size="2" /> <input type="text" id="m" name="m" size="2" /> <input type="text" id="y" name="y" size="4" /><br> Address:<br> <input type="text" id="add" name="add" /><br> Phone:<br> <input type="text" id="phone" name="phone" /><br> <input type="submit" name="submit" id="submit" value="GO!" /> </div> </form> </body> </html> process.php My db id named "jquery" and table is "tab" Code: [Select] <?php $conns=mysql_connect("localhost","root",""); if(!$conns) echo "error in connection"; mysql_select_db("jquery", $conns); $name=$_POST['name']; $email=$_POST['email']; $m=$_POST['m']; $d=$_POST['d']; $y=$_POST['y']; $add=$_POST['add']; $phone=$_POST['phone']; echo $name,"<br>"; echo $email,"<br>"; echo $m, "<br>"; echo $d,"<br>"; echo $y,"<br>"; echo $add, "<br>"; echo $phone,"<br>"; $query="INSERT INTO tab (name,email,d,m,y,add,phone) VALUES ('$name',$email','$d','$m','$y','$add','$phone')"; if(!mysql_query($query,$conns)) echo "Error"; else echo "DATA inserted"; ?> The output shown is: pulkit pulkit@gmail.com 1 26 1991 lucknow 987576787 Error For some values i entered. my firefox won't open up .tpl format im running apache...how can i view that format on my apache please? Hello. I am coding a remember me feature. Everything is working, except i am being logged in using cookies even when i want to use a session. To login using a cookie i must select the checkbox, for sessions i must leave it blank. Here is my code, if someone could spot a mistake i would be really grateful. Login page Code: [Select] <?php ob_start(); // starting session... session_start(); // requiring connection... require("functions.php"); // assigning variables... $username = mysql_real_escape_string($_POST['username']); $password = mysql_real_escape_string($_POST['password']); $submit = mysql_real_escape_string($_POST['submit']); $rememberme = $_POST['rememberme']; // querying database... $query = mysql_query("SELECT * FROM users WHERE username = '$username'"); $numrows = mysql_num_rows($query); if ($numrows != 0) { while ($row = mysql_fetch_assoc($query)) { $db_username = $row['username']; $db_password = $row['password']; } } // verifying login details... if ($submit) { if (!empty($username) && !empty($password)) { if ($username == $db_username && $password == $db_password) { if ($rememberme = "on") { setcookie("username", $username, time() + 7200); header('Location: tablets.php'); } else { $_SESSION['username'] = $db_username; $url = $_SESSION['origin'] ? $_SESSION['origin'] : "main.php"; unset($_SESSION['origin']); header('Location: ' . $url); exit; } } else { echo "Incorrect login details"; } } else { echo "You must type in username and password"; } } ob_end_flush(); ?> Login form Code: [Select] <?php session_start(); require("connect.php"); if (isset($_SESSION['username']) || isset($_COOKIE['username'])) { header('Location: main.php'); } ?> <!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" xml:lang="en" lang="en"> <head> <title>Login</title> <link rel="stylesheet" type="text/css" href="form.css" /> </head> <body> <form method="post" action="login.php"> <div class="box"> <h1>Login</h1> <label> <span>Username</span> <input type="text" class="input_text" name="username" id="name" /> </label> <label> <span>Password</span> <input type="password" class="input_text" name="password" id="password" /> </label> <input type="checkbox" name="rememberme" /> <label> <input type="submit" class="button" value="Login" name="submit" /> </label> </div> </form> </body> </html> Hallo everyone... here is my following code. i am fetching the picture from the file but unable to fetch it.
kindly help me. error in bold underline...
Thanks
<!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>Untitled Document</title> </head> <body> <?php session_start(); $uid=''; include("connection.php"); $query=mysql_query("SELECT * FROM users WHERE uid='".$_GET['uid']."'"); $row=mysql_fetch_array($query); $image=$row['images_path']; ?> <form action="edit.php" method="post"> <table border="1px" align="center" width="85%"> <tr> <td colspan="3"><?php include'header.php' ?></td> </tr> <input type="hidden" name="uid" value="<?=$_GET['uid'];?>" /> <tr> <td colspan="3">Welcome <?php echo $_GET['uid']; ?> </td> </tr> <tr height="30px;"> <td width="37%" style="padding-left:250PX;">User Name</td> <td width="63%"> <input type="text" name="uname" value="<?php echo $row['uname']?>" /></td> </tr> <tr height="30px;"> <td width="37%" style="padding-left:250PX;">User Email</td> <td width="63%"> <input type="text" name="email" value="<?php echo $row['email'];?>" /></td> </tr> <tr height="30px;"> <td width="37%" style="padding-left:250PX;">Mobile</td> <td width="63%"> <input type="text" name="mob" value="<?php echo $row['mob'];?>" /></td> </tr> <tr height="30px;"> <td width="37%" style="padding-left:250PX;">Type</td> <td width="63%"> <input type="text" name="type" value="<?php echo $row['type'];?>" /></td> </tr> <tr height="30px;"> <td width="37%" style="padding-left:250PX;">Status</td> <td width="63%"> <input type="text"name="status" value="<?php echo $row['status'];?>" /></td> </tr> <tr height="30px;"> <td width="37%" style="padding-left:250PX;">Picture</td> <td><?php echo "<img border=\"0\" src=\"".$row['images_path']."\" width=\"102\" alt=\"your name\" height=\"91\">"; ?></td> </tr> </tr> <tr height="50px;"> <td colspan="3" style="padding-left:350px;"><input type="submit" name="submit" /> <input type="reset" value="Clear" /></td> </tr> <tr> <td colspan="3"><?php include'footer.php' ?></td> </tr> </table> <div align="left"><a href="home_users.php">Home</a></div> </form> </body> </html> HI, When I trying to covnert 3gp to FLV I got this error: FFmpeg version SVN-r12665, Copyright (c) 2000-2008 Fabrice Bellard, et al. configuration: --enable-gpl --enable-postproc --enable-swscale --enable-avfilt er-lavf --enable-pthreads --enable-liba52 --enable-avisynth --enable-libfaac --e nable-libfaad --enable-libgsm --enable-memalign-hack --enable-libmp3lame --enabl e-libnut --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --cpu=i686 --extra-ldflags=-static libavutil version: 49.6.0 libavcodec version: 51.54.0 libavformat version: 52.13.0 libavdevice version: 52.0.0 built on Apr 2 2008 22:35:11, gcc: 4.2.3 Seems stream 0 codec frame rate differs from container frame rate: 29.97 (30000/ 1001) -> 15.00 (15/1) Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'uploads/v_1.3gp': Duration: 00:01:03.6, start: 0.000000, bitrate: 189 kb/s Stream #0.0(und): Video: h263, yuv420p, 176x144 [PAR 12:11 DAR 4:3], 15.00 t b(r) Stream #0.1(und): Audio: samr / 0x726D6173, 8000 Hz, mono WARNING: The bitrate parameter is set too low. It takes bits/s as argument, not kbits/s Output #0, flv, to 'uploads/a.flv': Stream #0.0(und): Video: flv, yuv420p, 320x240 [PAR 1:1 DAR 4:3], q=2-31, 20 0 kb/s, 15.00 tb(c) Stream #0.1(und): Audio: libmp3lame, 22050 Hz, mono, 0 kb/s Stream mapping: Stream #0.0 -> #0.0 Stream #0.1 -> #0.1 Unsupported codec (id=73728) for input stream #0.1 What should I do? Thanks Hi All,
I have this issue when upload a file using an uploader i made. For the life of me I cant figure out why it won't write the file.
Error:
[Sat Jun 21 20:45:40 2014] [error] [client xxxxxxx] AH01215: PHP Warning: move_uploaded_file() [<a href='function.move-uploaded-file'>function.move-uploaded-file</a>]: Unable to move '/tmp/phpUsCyXG' to '/home/sites/xxxxxx.co.uk/public_html/yourphotos/uploads/' in /home/sites/xxxxxxx.co.uk/public_html/yourphotos/index.php on line 31My PHP <?php //if they DID upload a file... $message = ''; if($_FILES['photo']['name']) { $valid_file = true; //if no errors... if(!$_FILES['photo']['error']) { //now is the time to modify the future file name and validate the file $new_file_name = strtolower($_FILES['photo']['tmp_name']); //rename file if($_FILES['photo']['size'] > (26214400)) //can't be larger than 25MB { $valid_file = false; $message = 'Oops! Your file\'s size is to large.'; echo $_FILES['photo']['size']; } if($_FILES['photo']['size'] < (1572864)) //can't be smaller than 1.5MB { $valid_file = false; $message = 'Oops! Your file\'s size is to small.'; echo $_FILES['photo']['size']; } //if the file has passed the test if($valid_file) { //move it to where we want it to be move_uploaded_file($_FILES['photo']['tmp_name'], '/home/sites/xxxxxxxx.co.uk/public_html/yourphotos/uploads/'); $message = 'Congratulations! Your file was accepted.'; } } //if there is an error... else { //set that to be the returned message $message = 'Ooops! Your upload triggered the following error: '.$_FILES['photo']['error']; } } ?> <html> <body> <form action="index.php" method="post" enctype="multipart/form-data"> Your Photo: <input type="file" name="photo" size="25" /> <input type="submit" name="submit" value="Submit" /> <?PHP echo $message; ?> </form> </body> </html>I have set the uploads file to have write permissions as well. Sam Edited by samtwilliams, 21 June 2014 - 02:51 PM. First of all, here's what i want it to look:' I just want that the related image must align towards left, and its information is just in front of it. But, what my code does is place the image on above line, and the information on the link below. Here's how it looks with my code. I will be able to make the changes with the File Information. The PHP which is being used is: 1. To fetch if preview is available: Code: [Select] $pre = ''; if ($prew==0) { if ($ext == 'bmp') $pre = 'Impossible Preview <br>'; if ($ext == 'gif' or $ext == 'jpeg' or $ext == 'jpg' or $ext == 'png' or $ext == 'JPG' or $ext == 'GIF' or $ext == 'PNG'or $ext == 'JPEG') $pre = '<img style="align:left;margin: 1px;" src="im.php?bab=1&id='.$file_info['id'].'" alt=""/>'; }2. To insert the preview image: Code: [Select] if($pre!=NULL) echo '<div class="block">'.$pre.'</div>'; 3. And finally the code to fetch file information: Code: [Select] echo '<div class="fileName"><a href="load.php?id='.$file_info[id].'"><font color="red">'.$file_info['name'].''.$extension.'</font></a>|'; if($ext =='txt') { echo '<a href="read.php?id='.$file_info['id'].'&id2='.$id.'"><font color="red">Read</font></a>';} echo $new_info.''; if(!empty($file_info['fastabout'])) echo str_replace("\n", '<br>',$file_info['fastabout']); echo '</div>'; echo '<tr><div class="t_block">'.$ico.'<a href="view.php?id='.$file_info[id].'"><strong>File Info</strong></a></div></tr></td>'; I just can't figure out what to insert with the code. I think it must be some table formatting (TR/TD), but because I'm a noob with PHP, I failed in all my attempts. Please, if anyone could help me out! ==> MySQL version 5.0.91-community So once upon a time I was working on a CMS. I worked on it for 3 months, had to wipe my computer - but didn't worry about it because I backed up the files on a flash drive... which got smushed by some boxes when I moved <.< awesome -.- Anyway, a year later (ie: today), I've decided to start again from scratch. For me - for whatever reason - the simplest things always seem to give me the most trouble. I decided to start with a "user" table - naturally - and began working on the first page: user_view.php and added an include file that connects to the database (connectDB.php). Since I started today, everything is simple - no design elements yet - just good 'ol code. The View Users Page is simply a page that grabs all the rows from Table: users and prints the information to the screen, as if you were viewing a Members page on a forum. This Page works fine. No complaints, does everything I need it to, prints all the rows and cols from Table Users. Then I created the Edit User Page. When I did this a year ago, and I wanted to print out all the data from the table, I used the while loop. When I wanted to only grab certain variables from a table, I just created a new set of variables, as show below. Using the same method from a year ago, I started working on printing various data to the screen (such as "Welcome $username"). 5 minutes of typing... refresh page... nada. So I stripped away just about every tag but the essentials and it still wouldn't work Code: [Select] <?php ... $userID = 3; $sql = "SELECT * FROM users WHERE userID='$userID'"; $result = mysql_query($sql); $rows = mysql_fetch_row($result); echo $rows['username']; ... ?> Normally, this would just grab the username from a row in Table users where the userID = 3 But instead - it does nothing. I just see a blank page. It's a simple 5 lines of code and it's like "im just gonna do w.e the fk i wanna do mmmk thxforplaying" PS: Keep in mind there is nothing wrong with the connection to the database, and as already stated I'm able to print ALL values from the Users Table using this same method: Code: [Select] <?php ... $user_sql = "SELECT * FROM users ORDER BY username ASC"; $user_result = mysql_query($user_sql); while ( $user_rows = mysql_fetch_array($user_result) ) ... ?> |