PHP - Warning: Round()!
I am trying to output only 40 of the latest files uploaded on the database server.
But when I am trying to see the files uploaded on the server I am getting this error: Warning: round() expects parameter 2 to be long, string given in C:\wamp\www\mshare\lista.php on line 8 Call Stack The code: Code: [Select] <?php function bytestostring($size, $precision = 0) { $sizes = array('YB', 'ZB', 'EB', 'PB', 'TB', 'GB', 'MB', 'kB', 'B'); $total = count($sizes); while($total-- && $size > 1024) $size /= 1024; return round($size, $precision)." ".$sizes[$total]; } echo '<div class="header">40 last uploaded files:</div>'; $sql = "SELECT * FROM filer order by id desc limit 40"; $q = mysql_query($sql); echo '<table style="width: 100%;">'; while ($r = mysql_fetch_array($q)) { $i++; $id = $r['id']; $filnamn = $r['name']; $filtyp = explode("/", $r['type']); $filtyp = ucwords($filtyp[0]); if($filtyp == "") { $filtyp = "Unkown"; } $filstorlek = bytestostring($r['size'], ""); $a = $i%2; echo'<tr><td class="lista">'; echo ''.$i.'. <td class="lista">'.$filnamn.'<td class="lista">'.$filtyp.' <td class="lista">'.$filstorlek.' <td class="lista"><a href="download.php?id='.$id.'"'.$a.'"><img src="download-icon.jpg" class="imagedow"></a>'; } echo "</table>"; ?> I am new to PHP coding so you guys just know. Similar TutorialsHi Everyone I am having a few issues with my website. I have developed in on my xampp local host and it works ok but when I upload the files and try to renew a membership using stripe I get the following messages. Warning: session_start(): Cannot start session when headers already sent in /customers/a/d/f/mywebsite.co.uk/httpd.www/mywebsite/inc/settings.php on line 2 Warning: Cannot modify header information - headers already sent by (output started at /customers/a/d/f/mywebsite.co.uk/httpd.www/mywebsite/procedures/payments/charge.php:1) in /customers/a/d/f/mywebsite.co.uk/httpd.www/mywebsite/procedures/payments/charge.php on line 141 I have some includes that appear on every page. This is the bootstrap.php file. This file holds the settings.php which connects to my database and other function files. In this settings page I call the session_start() php function and then connect to my database. I call the bootstrap.php file on every page to there for call the session_start() on every page. I am using sessions alot so is this the right thing to do? I have attached the renew_membership payment page which holds the form. The user fills out the payment page and the form data gets sent to a script called charge.php which uses the stripe objects to make the payment. I then want to do a redirect to the paymentSuccess.php page to output to the user that the payment was made successfully. This is where the issues arrise. I have split the charge file into 3 screen shots so it is more readable. Hope someone can help me. Thanks a lot David
Edited April 26 by Irish_Dave I am running to an issue that I have never delt with before and am not sure if there is even a possible solution: I have two files: fileA and fileB fileA contains a loop that loops 30 times each time its called. in the loop there is a 2second delay $i = 1; do { $i++; sleep(2); if(!isset($_SESSION['user']) { break; } } while($i < 31); if fileB i have a simple destroy session $_SESSION = array(); session_destroy(); I call both files via ajax, and that is where i run into my problem. if I call fileA first, then call fileB through ajax, the code in FileB does not execute until fileA has run its course. Is it possible to get around this? Like set the priority of one over the other? <?php if(isset($_POST['submit'])){ $name = $_POST['name']; } ?> <form method="POST" action="hist1.php"> <br /> <input type="hidden" name="name" value="<?php echo $name ?>" /> <?php $q = mysql_query("SELECT * FROM histact1 ORDER BY RAND() LIMIT 1"); while ($r1 = mysql_fetch_array($q)){ $id = $r1[0]; $question1 = $r1[1]; $opt1 = $r1[3]; $opt2 = $r1[4]; $opt3 = $r1[5]; ?> <div class="Qset" id="q1"><br /><br /> <label class="items">1st Question :</label> <br /> <center> <textarea class="textareaQ" name="question1" readonly><?php echo $question1; ?></textarea> </center> <br /><br /> <p class="marA"> <input type="radio" name="rad1" value="<?php echo $opt1; ?>" /> <label class="lbl"><?php echo $opt1 ?></label><br /> <input type="radio" name="rad1" value="<?php echo $opt2; ?>" /> <label class="lbl"><?php echo $opt2 ?></label><br /> <input type="radio" name="rad1" value="<?php echo $opt3; ?>" /> <label class="lbl"><?php echo $opt3 ?></label><br /> </p> </div> <div class="lr"> <center> <br /><br /><br /><br /> <a class="nxt" href="#q2"><label title="Proceed to 2nd Question">Next</label></a> </center> </div> <br /><br /><br /> <center><hr width="90%" /></center><br /> <?php } ?> <br /><br /> <?php $q = mysql_query("SELECT * FROM histact1 ORDER BY RAND() LIMIT 1"); while ($r1 = mysql_fetch_array($q)){ $id = $r1[0]; $question2 = $r1[1]; $opt1 = $r1[3]; $opt2 = $r1[4]; $opt3 = $r1[5]; ?> <div class="Qset" id="q2"><br /><br /> <label class="items">2nd Question :</label> <br /> <center> <textarea class="textareaQ" name="q2" readonly><?php echo $question2; ?></textarea> </center> <br /><br /> <p class="marA"> <input type="radio" name="rad2" value="<?php echo $opt1; ?>" /> <label class="lbl"><?php echo $opt1 ?></label><br /> <input type="radio" name="rad2" value="<?php echo $opt2; ?>" /> <label class="lbl"><?php echo $opt2 ?></label><br /> <input type="radio" name="rad2" value="<?php echo $opt3; ?>" /> <label class="lbl"><?php echo $opt3 ?></label><br /> </p> </div> <div class="lr"> <center> <br /><br /><br /><br /> <a class="nxt" href="#q1"><label title="Proceed to 1st Question">Back</label></a> | <a class="nxt" href="#q3"><label title="Proceed to 3rd Question">Next</label></a> </center> </div> <br /><br /><br /> <center><hr width="90%" /></center><br /> <?php } ?> <br /><br /> <?php $q = mysql_query("SELECT * FROM histact1 ORDER BY RAND() LIMIT 1"); while ($r1 = mysql_fetch_array($q)){ $id = $r1[0]; $question3 = $r1[1]; $opt1 = $r1[3]; $opt2 = $r1[4]; $opt3 = $r1[5]; ?> <div class="Qset" id="q3"><br /><br /> <label class="items">3rd Question :</label> <br /> <center> <textarea class="textareaQ" name="q3" readonly><?php echo $question3; ?></textarea> </center> <br /><br /> <p class="marA"> <input type="radio" name="rad3" value="<?php echo $opt1; ?>" /> <label class="lbl"><?php echo $opt1 ?></label><br /> <input type="radio" name="rad3" value="<?php echo $opt2; ?>" /> <label class="lbl"><?php echo $opt2 ?></label><br /> <input type="radio" name="rad3" value="<?php echo $opt3; ?>" /> <label class="lbl"><?php echo $opt3 ?></label><br /> </p> </div> <div class="lr"> <center> <br /><br /><br /><br /> <a class="nxt" href="#q2"><label title="Proceed to 2nd Question">Back</label></a> | <a class="nxt" href="#q4"><label title="Proceed to 4th Question">Next</label></a> </center> </div> <br /><br /><br /> <center><hr width="90%" /></center><br /> <?php } ?> <br /><br /> <?php $q = mysql_query("SELECT * FROM histact1 ORDER BY RAND() LIMIT 1"); while ($r1 = mysql_fetch_array($q)){ $id = $r1[0]; $question4 = $r1[1]; $opt1 = $r1[3]; $opt2 = $r1[4]; $opt3 = $r1[5]; ?> <div class="Qset" id="q4"><br /><br /> <label class="items">4th Question :</label> <br /> <center> <textarea class="textareaQ" name="q4" readonly><?php echo $question4; ?></textarea> </center> <br /><br /> <p class="marA"> <input type="radio" name="rad4" value="<?php echo $opt1; ?>" /> <label class="lbl"><?php echo $opt1 ?></label><br /> <input type="radio" name="rad4" value="<?php echo $opt2; ?>" /> <label class="lbl"><?php echo $opt2 ?></label><br /> <input type="radio" name="rad4" value="<?php echo $opt3; ?>" /> <label class="lbl"><?php echo $opt3 ?></label><br /> </p> </div> <div class="lr"> <center> <br /><br /><br /><br /> <a class="nxt" href="#q3"><label title="Proceed to 3rd Question">Back</label></a> | <a class="nxt" href="#q5"><label title="Proceed to 5th Question">Next</label></a> </center> </div> <br /><br /><br /> <center><hr width="90%" /></center><br /> <?php } ?> <br /><br /> <?php $q = mysql_query("SELECT * FROM histact1 WHERE question != '$question1' AND question != '$question2' AND question != '$question3' AND question != '$question4' ORDER BY RAND() LIMIT 1"); while ($r1 = mysql_fetch_array($q)){ $id = $r1[0]; $question5 = $r1[1]; $opt1 = $r1[3]; $opt2 = $r1[4]; $opt3 = $r1[5]; ?> <div class="Qset" id="q5"><br /><br /> <label class="items">5th Question :</label> <br /> <center> <textarea class="textareaQ" name="q5" readonly><?php echo $question5; ?></textarea> </center> <br /><br /> <p class="marA"> <input type="radio" name="rad5" value="<?php echo $opt1; ?>" /> <label class="lbl"><?php echo $opt1 ?></label><br /> <input type="radio" name="rad5" value="<?php echo $opt2; ?>" /> <label class="lbl"><?php echo $opt2 ?></label><br /> <input type="radio" name="rad5" value="<?php echo $opt3; ?>" /> <label class="lbl"><?php echo $opt3 ?></label><br /> </p> </div> <div class="lr"> <center> <br /><br /><br /><br /> <a class="nxt" href="#q4"><label title="Proceed to 4th Question">Back</label></a> | <input type="submit" title="Submit Answers" name="submit" class="submit" value=" Submit " onclick="return confirm('Are you sure you want to submit your answers?\nYou can review your answer by click the Back link')" /> </center> </div> <br /><br /><br /> <center><hr width="90%" /></center><br /> <?php } ?> </form> Edited by mac_gyver, 09 October 2014 - 10:51 AM. code in code tags please hello guys, im creating a search result page that uses pagination, and im trying to figure out how many total pages their are going to be in my links with the page numbers. this is probably something really simple, ive been writing scripts for the last few hours and have a bit of a headache, any help would be appreciated here's the coding and the results i want: <?php $per_page = 10; $rows = mysql_query("SELECT COUNT(*) FROM articles WHERE text LIKE $string"); // this will return 31 $pages = $rows / $per_page; // returns 3.1 $total_pages = round($pages); // returns 3, want to round 3.1 up to 4 here ?> hi know who to round a number to the nearest whole number, if i use echo round(9.5); it echo's 10 and if i use echo round(9.2); it echo's 9 i want it so it always rounds up? can anyone help? cheers matt This works echo $data3['value']; But this doesn't echo round($data3['value'], 2); Can someone please advise me as to what I am doing wrong? HOw to get the AVERAGE of my entire database? $query = "SELECT ROUND(AVG(scores)) FROM table"; Thanks! Bickey I need to take a time and convert so it is rounded up or down to the nearest 0 or 5. Code: [Select] function roundMe ($time, $upDown) { if($upDown==1) { //round up } else { //round down } return $x; } echo roundMe("16:22", 1); // returns 16:25 echo roundMe("16:22", 0); // returns 16:20 echo roundMe("16:25", 1); // returns 16:25 echo roundMe("16:59", 1); // returns 17:00 echo roundMe("16:59", 0); // returns 16:55 i have a price i want to add 10%-15% to the base price and that the result will be rounded to 9 in the ones digit place. for example 85 +15%=97.7 $result=99 117+15%=134.55 $result = 139 played with round() and ceil() Code: [Select] $newrating = round($imageinfo['rating'],2); this outputs: 4.49 in my db rating is 4.4884 all i need is the 4.... would i use some type of preg_replace or something just to grab the first 1 before the decimal? (all i need is the first number before the decimal) Hi.. I encountered problem in rounding of numbers into two decimal places. here is my sample code: if($W4_STATUS == 1 AND $DEPENDENTS == 0 AND $TotEarn >= 7917 AND $TotEarn <= 12500) { $TAX = ($TotEarn - 7917); $TAX = (937.50 + ($TAX * .25)); $TAX = number_format($TAX, 2, '.', ''); } for example from this: $TAX = ($TotEarn - 7917); $TAX = (937.50 + ($TAX * .25)); the output is: 1417.615 using this: $TAX = number_format($TAX, 2, '.', ''); the output was : 1417.61 but it should be : 1417.62 Thank you Hey guys, I use the code below to add a corners to an image and it works great but when i add a border to the image it add a square.... any ideas how i can add a border to the rounded image? <?php $image_file = $_GET['src']; $corner_radius = isset($_GET['radius']) ? $_GET['radius'] : 20; // The default corner radius is set to 20px $topleft = (isset($_GET['topleft']) and $_GET['topleft'] == "no") ? false : true; // Top-left rounded corner is shown by default $bottomleft = (isset($_GET['bottomleft']) and $_GET['bottomleft'] == "no") ? false : true; // Bottom-left rounded corner is shown by default $bottomright = (isset($_GET['bottomright']) and $_GET['bottomright'] == "no") ? false : true; // Bottom-right rounded corner is shown by default $topright = (isset($_GET['topright']) and $_GET['topright'] == "no") ? false : true; // Top-right rounded corner is shown by default $imagetype=strtolower($_GET['imagetype']); $backcolor=$_GET['backcolor']; $endsize=$corner_radius; $startsize=$endsize*3-1; $arcsize=$startsize*2+1; if (($imagetype=='jpeg') or ($imagetype=='jpg')) { $image = imagecreatefromjpeg($image_file); } else { if (($imagetype=='GIF') or ($imagetype=='gif')) { $image = imagecreatefromgif($image_file); } else { $image = imagecreatefrompng($image_file); } } $size = getimagesize($image_file); // Top-left corner $background = imagecreatetruecolor($size[0],$size[1]); imagecopymerge($background, $image, 0, 0, 0, 0, $size[0], $size[1], 100); $startx=$size[0]*2-1; $starty=$size[1]*2-1; $im_temp = imagecreatetruecolor($startx,$starty); imagecopyresampled($im_temp, $background, 0, 0, 0, 0, $startx, $starty, $size[0], $size[1]); $bg = imagecolorallocate($im_temp, hexdec(substr($backcolor,0,2)),hexdec(substr($backcolor,2,2)),hexdec(substr($backcolor,4,2))); $fg = imagecolorallocate($im_temp, hexdec(substr($forecolor,0,2)),hexdec(substr($forecolor,2,2)),hexdec(substr($forecolor,4,2))); if ($topleft == true) { imagearc($im_temp, $startsize, $startsize, $arcsize, $arcsize, 180,270,$bg); imagefilltoborder($im_temp,0,0,$bg,$bg); } // Bottom-left corner if ($bottomleft == true) { imagearc($im_temp, $startsize, $starty-$startsize,$arcsize, $arcsize, 90,180,$bg); imagefilltoborder($im_temp,0,$starty,$bg,$bg); } // Bottom-right corner if ($bottomright == true) { imagearc($im_temp, $startx-$startsize, $starty-$startsize,$arcsize, $arcsize, 0,90,$bg); imagefilltoborder($im_temp,$startx,$starty,$bg,$bg); } // Top-right corner if ($topright == true) { imagearc($im_temp, $startx-$startsize, $startsize,$arcsize, $arcsize, 270,360,$bg); imagefilltoborder($im_temp,$startx,0,$bg,$bg); } $newimage = imagecreatetruecolor($size[0],$size[1]); imagecopyresampled($image, $im_temp, 0, 0, 0, 0, $size[0],$size[1],$startx, $starty); // Output final image header("Content-type: image/png"); imagepng($image); imagedestroy($image); imagedestroy($background); imagedestroy($im_temp); ?> hello, if i have the following, how would i display it? Code: [Select] function minutes_round ($hour = "$signintime", $minutes = '5', $format = "H:i") { $seconds = strtotime($hour); $rounded = round($seconds / ($minutes * 60)) * ($minutes * 60); return date($format, $rounded); } Hi there. I am trying to display numbers if they have the numbers like: number_format($price,2) This gives us two decimal places i.e 7.23 Now thats fine, I would like to round the last two decimal places. I would like to make it 7.25, (rounding it from 7.23 to 7.25) Similarly making: 12.44 to 12.45 33.18 to 33.20 52.13 to 52.15 So actually rounding the last two places. Coz obviously customers won't be able to pay 52 dollars 13 cents. So therefore rounding the last cent's (decimal part) making it to 52.15 Thank you. All comments and feedback are welcomed. (d So I am tryting to create a script to upload a CSV file into a MySql DB. It has like 10K records into SQL
My Code is copy below ...
I get the following errors.
Line 16 is the $handle
line 18 is the While Statement
Error:
Warning: fopen(): Filename cannot be empty in C:\local\htdocs\ADPStorage\DemandCSV.php on line 16 Warning: fopen()expects parameter 1 to be resource, boolean given in C:\local\htdocs\ADPStorage\DemandCSV.php on line 18 I use my script for another table and it worked like a charm. Less data and less colums do. Bad Code: (good Code sample below. this one) <?php $today = date("m.d.y.h.m.s"); echo $today; $BPTD_fy = '2014'; $BPTD_updatedate = $today; $conn = mysql_connect("Localhost","root","password") or die (mysql_error()); mysql_select_db("ds_storage",$conn); if(isset($_POST['submit'])) { $file = $_FILES['file']['tmp_name']; $handle = fopen($file, "r"); while(($fileop = fgetcsv($handle, 100000, ",")) !==FALSE) { $BPTD_fy = $fileop[0]; $BPTD_Status = $fileop[1]; $BPTD_Classification = $fileop[2]; $BPTD_ProcureCat = $fileop[3]; $BPTD_Product = $fileop[4]; $BPTD_Project = $fileop[5]; $BPTD_DSCategory = $fileop[6]; $BPTD_Calculated = $fileop[7]; $BPTD_CapacityType = $fileop[8]; $BPTD_Amount = $fileop[9]; $BPTD_Jul = $fileop[10]; $BPTD_Aug = $fileop[11]; $BPTD_Sep = $fileop[12]; $BPTD_Oct = $fileop[13]; $BPTD_Nov = $fileop[14]; $BPTD_Dec = $fileop[15]; $BPTD_Jan = $fileop[16]; $BPTD_Feb = $fileop[17]; $BPTD_Mar = $fileop[18]; $BPTD_Apr = $fileop[19]; $BPTD_May = $fileop[20]; $BPTD_Jun = $fileop[21]; $BPTD_Location = $fileop[22]; $BPTD_Env = $fileop[23]; $BPTD_Requester = $fileop[24]; $BPTD_ServiceArea = $fileop[25]; $BPTD_ServiceGroup = $fileop[26]; $BPTD_DepHead = $fileop[27]; $BPTD_Recgroup = $fileop[28]; $BPTD_RecOwner = $fileop[29]; $BPTD_Entrydate = $fileop[30]; $BPTD_updatedate = $fileop[31]; $sql = mysql_query("INSERT INTO inv_bpt_demand (Status, Classification, ProcureCat, Product, Project, DSCategory, Calculated, CapacityType, Amount, Jul, Aug, Sep, Oct, Nov, Dec, Jan, Feb, Mar, Apr, May, Jun, Location, Env, Requester, ServiceArea, ServiceGroup, DepHead, Recgroup, RecOwner, Entrydate, updatedate) VALUES ('$BPTD_Status', '$BPTD_Classification', '$BPTD_ProcureCat', '$BPTD_Product', '$BPTD_Project', '$BPTD_DSCategory', '$BPTD_Calculated', '$BPTD_CapacityType', '$BPTD_Amount', '$BPTD_Jul', '$BPTD_Aug', '$BPTD_Sep', '$BPTD_Oct', '$BPTD_Nov', '$BPTD_Dec', '$BPTD_Jan', '$BPTD_Feb', '$BPTD_Mar', '$BPTD_Apr','$BPTD_May', '$BPTD_Jun','$BPTD_Location', '$BPTD_Env','$BPTD_Requester', '$BPTD_ServiceArea', '$BPTD_ServiceGroup','$BPTD_DepHead', '$BPTD_Recgroup','$BPTD_RecOwner','$BPTD_Entrydate','$BPTD_updatedate')"); if($sql) { echo 'Data Uploaded Successfully'; } } } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>BPT Demand CSV</title> <link rel="stylesheet" type="text/css" href="file:///C|/local/htdocs/style/style.css" /> <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> </head> <body> <div id="mainWrapper"> <form method="post" action="https://localhost/Storage/DemandCSV.php" enctype="multipart/form-data"> <input type="file" name="file" /> <br /> <input type="submit" name="submit" value="Submit" /> </form> </div><!--end mainWrapper--> </body> </html>Similar Working code (good) <?php $conn = mysql_connect("Localhost","root","password") or die (mysql_error()); mysql_select_db("ds_storage",$conn); if(isset($_POST['submit'])) { $file = $_FILES['file']['tmp_name']; $handle = fopen($file, "r"); while(($fileop = fgetcsv($handle,1000,",")) !==FALSE) { $PC_Num = $fileop[0]; $PC_Name = $fileop[1]; $PC_BPTNUM = $fileop[2]; $PC_busclass = $fileop[3]; $PC_Note = $fileop[4]; $PC_Acro = $fileop[5]; $PC_type = $fileop[6]; ///echo $fileop[1]; $sql = mysql_query("INSERT INTO inv_names (PC_Num, PC_Name, PC_BPTNUM, PC_busclass, PC_Note, PC_Acro, PC_type) VALUES ('$PC_Num', '$PC_Name', '$PC_BPTNUM', '$PC_busclass', '$PC_Note', '$PC_Acro', '$PC_type')"); if($sql) { echo 'Data Uploaded Successfully'; } } } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Upload CSV</title> <link rel="stylesheet" type="text/css" href="file:///C|/local/htdocs/style/style.css" /> <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> </head> <body> <div id="mainWrapper"> <form method="post" action="https://localhost/Storage/Storage_CSV.php" enctype="multipart/form-data"> <input type="file" name="file" /> <br /> <input type="submit" name="submit" value="Submit" /> </form> </div><!--end mainWrapper--> </body> </html>Please help and thx in advance ~J Hey everyone, I have created a simple framework script and Im getting this error inserted into my error_log file in the root folder: Quote [31-Oct-2010 13:14:59] PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20060613/' - /usr/local/lib/php/extensions/no-debug-non-zts-20060613/: cannot read file data: Is a directory in Unknown on line 0 Any ideas guys?? Even though the path is right I am getting a warning: Code: [Select] Warning: include(/php_projects/myproject/controller/registering/register_2.php) [function.include]: failed to open stream: No such file or directory in C:\xampp\htdocs\php_projects\myproject\controller\authentication\login_register.php on line 7 I am trying to include the file register_2.php into login_register.php, and the path is right I double checked it, I am trying to use an absolute path excluding the domain instead of a relative path. This is how I include the login_register.php file: Code: [Select] <?php include ($register_2); ?> And this is the path.php file just to showcase: Code: [Select] // The Login Register Page $register_2 = root . "controller/registering/register_2.php"; $login_2 = root . "controller/authentication/login_2.php"; And the define function: Code: [Select] define('root', '/php_projects/myproject/'); With other paths this method does work, but it does not seem to work with paths which are a bit deeper in the structure. And I am wondering, why? Even using the domain, which means, putting the localhost in front of it does not work. Only a relative path will work. hello i keep getting the Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/cookbook/public_html/forum/index.php on line 26 for my code <?php session_start(); include_once "../scripts/connect_to_mysql.php"; // Connect to the database $sql = mysql_query("SELECT * FROM forum_sections ORDER BY ordered ASC LIMIT 10"); $displayList = ""; // Initialize the display variable here while($row = mysql_fetch_array($sql)){ $sectionID = $row["id"]; $sectionTitle = $row["title"]; $displayList .= '<br /><a href="section.php?id=' . $sectionID . '"><img src="style/sectionPic.jpg" width="61" height="23" alt="Section" /> ' . $sectionTitle . '</a><br /><hr />'; } ?> <!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" /> <link href="style/style.css" rel="stylesheet" type="text/css" /> <title>Web Intersect Forum</title> </head> <body> <?php include_once("template_header.php"); ?> <table style="background-color: #F0F0F0; border:#069 1px solid; border-top:none;" width="900" border="0" align="center" cellpadding="12" cellspacing="0"> <tr> <td width="731" valign="top"> <div id="breadcrumbs"><a href="http://www.webintersect.com">Web Intersect Home</a></div> <div id="sectionLinks"><ul><?php echo $displayList; ?></ul></div></td> <td width="189" valign="top"><div style=" width:160px; height:600px; background-color: #999; color: #CCC; padding:12px;"> <br /><br /><br /> <h3>Ad Space or Whatever</h3> </div></td> </tr> </table> <?php include_once("template_footer.php"); ?> </body> </html> can anyone please tell me why i get this? mysql_result() : supplied argument is not a valid result in ..... Code: [Select] function previously_liked ($article_id) { $article_id = (int) $article_id; return (mysql_result(mysql_query("SELECT COUNT(`like_id`) FROM `likes` WHERE `like_id` = " .$_SESSION['user_id']. " AND `article_id` = $article_id"), 0) == 0 ) ? false : true; // this is the line with the error. } I have the following code Code: [Select] $hidden_client_id_query = mysql_query("SELECT id from `pdp_client_info` WHERE lead_id='$post_lead_id'"); $hidden_client_id=mysql_fetch_assoc($hidden_client_id_query); $this->view->hidden_client_id=$hidden_client_id['id']; I get the following error for the above code. I wonder where I am wrong. I am getting the $post_lead_id as expected. Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean |