PHP - $a = Mysql_result( $b, 0, $c); - Does Not Work
i am wanting to use the following code but it is not working as i thought it would.
instead of hard coding the field name in the script i wish to have it insert using a variable like below. what is the correct way i should do this. Code: [Select] $c= "fieldname"; $a = mysql_result( $results, 0, $c); Similar Tutorialsmysql_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. } Code: [Select] <?php $liked = ("SELETCT SUM(user_id) as totaluser_id FROM liked WHERE `user_id`='26762'"); $liked_results = mysql_query($liked); $sum_liked = mysql_result($liked, 0); // <--- Error echo $sum_liked; ?> i got this error Warning: mysql_result(): supplied argument is not a valid MySQL result resource in can sombady help? Hi Everyone, Sorry I am a complete newbie and am trying to secure my code using MySQLi but I am stuck at mysql_result since there is no equivalent in mysqli. Can someone help me with my code please ?
$total_results = mysqli_query($mysqli,"SELECT COUNT(*) FROM gallery_photos WHERE category_name='" . addslashes($category_name) . "'"); if (!$total_results) { die('Could not query:' . mysqli_error()); } $total_results = mysql_result($total_results, 0);When I use this I am getting an error Warning: mysql_result() expects parameter 1 to be resource, object given in C:\wamp\www\viewgallery.php on line 182 As a solution I was told to use $row = $mysqli_result->fetch_row(); $the_count = $row[0];But I do not know how to add this to my code to make it work. I am sorry if this is too elementary ... don't know what to do next with this error popping up,,,any help? <?php //set up the variables $loguser = $_POST['loguser']; $logpass = md5($_POST['logpass']); $login = $_get['login']; //connect with the server and the database mysql_connect("localhost","root","") or die("Can't connect with the Server!"); mysql_select_db("comp3project") or die("Can't connect with the database!"); if($login="yes") { $get = mysql_query("SELECT count(cid) FROM customer_data WHERE username = '$loguser' and password = '$logpass'"); $result = mysql_result($get,0); if($result!=1){print "Login Failed!";} else {print "Login Successful!";} } ?> Hi there I am having a problem with this warning message being thrown "Warning: mysql_result() expects parameter 1 to be resource, boolean given in C:\wamp\www\css\rnfunctions.php on line 302" and again for line 303 Here is the code function receiveuserchange() { if (isset($_POST['level'])){ $query = "SELECT * FROM users"; $result=mysql_query($query) or die("Invalid Query : ".mysql_error()); $num=mysql_numrows($result); $i=0; while ($i < $num) { ////////////////here are lines 302 and 303/////////////////////////////// $user=mysql_result($result,$i,"user"); $id=mysql_result($result,$i,"id"); ///////////////////////////////////////////////////////////////////////////// if (isset($_POST["$user"])){ $level = ($_POST["$user"]); $query = "update profiles set level='$level' where pid='$id'"; $result=mysql_query($query) or die("Invalid Query : ".mysql_error()); ViewUsers('viewusers.php'); }else{ echo "$user not recieved"; } $i++; } Can anyone see what the problem is? I have this code Code: [Select] $id = $_GET['esitysid']; $esitysnimi = mysql_query("SELECT * FROM varasto WHERE id = '".$id."", $yhteys); print "esitysnimi $esitysnimi"; $esitysnim = mysql_result($esitysnimi, "0", "nimi"); varasto: Code: [Select] nimi hinta maara id lippuja Esitys Nimi 1 10 14 0 5 Esitys Nimi 2 120 5 1 0 Esitys Nimi 3 950 5 2 0 and it says Code: [Select] Warning: mysql_result() expects parameter 1 to be resource, boolean given How can I fix it? Thank you for help Hi.., I use below method to export data to excel. header('Content-type: application/ms-excel'); header('Content-Disposition: attachment; filename=abc.xls'); if I run the script from the server. (http://localhost/export.php) it is work. (pop-up window if i want save or open the file) but if i run the script from the client (http://192.168.1.5/export.php) it is not work. (nothing happen) any idea how to solve this? This one requires lots of up front information: I have a page, for this example that I will call page.php. It takes get parameters, and for this example I'll call the parameter "step". So I have a URL like this: page.php?step=1 This page has a form with an action of page.php?step=1. The code on the page validates the posting information. If the information is bad, it returns the user to page.php?step=1; if it is good, it takes the user to page.php?step=2 via header( "location:page.php?step=2" ). So redirection is done by relative path, not full URLs. This all works as expected. Now what I've done is set .htaccess to be HTTPS for this page, via this code: # Turn SSL on for payments RewriteCond %{HTTPS} off RewriteCond %{SCRIPT_FILENAME} \/page\.php [NC] RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L] This works (initially). However, once you try to post the form, it just redirects back to the step=1 version of the page. I really don't know how or why that would be. I'm not sure how else I can explain this or what other information you may have. But it's frustrating to not get a page working in HTTPS that works in HTTP. Very odd. Any suggestions? (I don't even really know the best location to figure out when/why it's redirecting back to the original page.) require_once 'includes/upload.class.php'; $upload = new uploads(); $details = $upload->getFileInformation($id); <?php echo $details['upload_desc']; ?> then here the class. require_once 'db.class.php'; class uploads extends database { private $uploadData; function uploadFile() { public function getFileInformation($id) { $this->uploadData = $this->readData("uploadfiles", "upload_id", $id); return $this->uploadData; } But it wont work! Some of you may have seen one of my many posts about email issues. Some users don't get them, and I have determined it is probably because we are marked as spam.
We are a service that grades sales team members on their phone skills. Listening to pre-recorded calls, grading and uploading them to our site, and then another part of our business looks them over and sometimes leaves a message that then get's forwarded to this persons work email.
I have determined there is ways to get marked as spam as default by not having an opt out link. This is not an option, these sales members employer has opted in, and the emails are going to work related accounts hosted at that employer. Also, if one of these staff members is not so bright, or disgruntled they may mark us as spam anyways. The bottom line is that we have very little control over whether we are or are not marked as spam.
So we want to start looking into sending text messages and this is where I start to question how good of an idea this is.
First off, if it was me, and the messages where being sent to a device that my employer did not provide, I would in no way want work related text messages coming to me. Unless there is a vested interest in getting them. IE, I'm the boss at this place and am always on the clock. What if you are on the bottom? It's just a job for you.
What if it is a pre-paid device, text messages cost money. What then? What if they don't even have, or want a cell phone?
The short of it is this. If I'm at a job that is just another job, and this employer tells me that I have to get these messages. I'm going to look for another job. I see the organizations having continuous issues and complaints from their employees. Thus us as a business having issues keeping clients.
What am I getting into here? What are your opinions on this matter? What are your recommendations as to alerting users of something on our site that we can rest assured are being received 100% of the time?
Thanks!
Nick
Hi there, As the question says i tried several things but i can't work it out and my knowledge about php isn't that well. i need help trying to get this delete feature to work its not deleting from the database (by the way i took out my database names and passwords at the top of the file) is it possible someone could help me, ive been working on this for like a week and cant figure out the problem. thanks! you can email me at spr_spng@yahoo.com picture 2.png is showing what it looks like Code: [Select] <?php $host="localhost"; // Host name $username="username"; // Mysql username $password="password"; // Mysql password $db_name="database_name"; // Database name $tbl_name="table_name"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM $tbl_name"; $result=mysql_query($sql); $count=mysql_num_rows($result); ?> <style> /*table affects look of the whole table look */ table { margin-left: auto; margin-right: auto; border: 1px solid #330000; border-collapse:collapse; width:70%; border-width: 5px 5px 5px 5px; border-spacing: 1px; border-style: outset outset outset outset; border-color: #330000 #330000 #330000 #330000; border-collapse: separate; background-color: #330000; #800517 f535aa #330000 school color #9A0000 school color2 #991B1E school color3 #CCCC99 school color4 #9A0000 } /*th is table header */ th { text-align: left; height: 2.5em; background-color: #330000; color: #FC0; font-size:1.5em; } /*td is table data or the cells below the header*/ td { text-align: left; height:1.0em; font-size:1.0em; vertical-align:bottom; padding:10px; border-width: 5px 5px 5px 5px; padding: 8px 8px 8px 8px; border-style: outset outset outset outset; border-color: #9A0000 #9A0000 #9A0000 #9A0000; background-color: #CCCC99; -moz-border-radius: 0px 0px 0px 0px; } </style> <table width="400" border="0" cellspacing="1" cellpadding="0"> <tr> <td><form name="form1" method="post" action=""> <table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td bgcolor="#FFFFFF"> </td> <td colspan="4" bgcolor="#FFFFFF"><strong>Pick Which Rows you want to delete, Then press delete.</strong> </td> </tr> <tr> <td align="center" bgcolor="#FFFFFF"><strong>Id</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Name</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Lastname</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Email</strong></td> <td align="center" bgcolor="#FFFFFF">delete</td></tr> <?php while($rows=mysql_fetch_array($result)){ ?> <tr> <td bgcolor="#FFFFFF"><? echo $rows['id']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['name']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['lastname']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['email']; ?></td> <td align="center" bgcolor="#FFFFFF"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $rows['id']; ?>"></td> </tr> <?php } ?> <tr> <td colspan="5" align="center" bgcolor="#FFFFFF"><input name="delete" type="submit" id="delete" value="Delete"></td> </tr> <? // Check if delete button active, start this // edited if($delete){ for($i=0;$i<$count;$i++){ $del_id = $checkbox[$i]; $sql = "DELETE FROM $tbl_name WHERE id='$del_id'"; $result = mysql_query($sql); } // if successful redirect to delete_multiple.php if($result){ echo "<meta http-equiv=\"refresh\" content=\"0;URL=delete_multiple.php\">"; } } mysql_close(); ?> </table> </form> </td> </tr> </table> Well, for those of you who use facebook, if you move pages from messages, to feed, to events or anything like that, you will notice the entire page doesn't load. At first, I though there must be some Ajax involved but then I realised that the page url is changing with new GET variables. So what is going on? What are they doing? Hi everybody *asian accent*, im trying to figure out how to display xml in php i know how to do things like <condition> <conditionId>4000</conditionId> <conditionDisplayName>Very Good</conditionDisplayName> </condition> for each blah blah as $item $condition = $item->condition->conditionId echo $condition; BUT........how do i get these values in XML to display in php this <searchResult count="2"> I want to get the value of count to display help please So I wanted to use a \ in order to stop PHP from registering my quotes. For some reason it does not seem to work. I am running PHP version 5.3.8. What am I doing wrong? Code: [Select] <?php $path = "www.DOMAINHERE.com/images/showlogos/".$showNAME."_logo.jpg"; if (file_exists($path)){ echo "YES"; ?> <a href="index.php"><img src="/images/showlogos/<?=$showNAME?>_logo.jpg" width="190" height="62" /></a><br /><br /> <?php } else { echo "NO!"; echo $path; } ?> the result is echoing out NO! which means the file doesnt exist... however when i c+p the echo'd $path into my address bar, it shows the image.. Thanks Ok strange one. I have an image upload script. It works fine and the image uploads and puts its name in my database. I also then post the name to the next page. Here is the image uploader <?php if (isset($_POST['insert_image'])) { $folder = "../../images/image_box/"; move_uploaded_file($_FILES["photo"]["tmp_name"] , "$folder".$_FILES["photo"]["name"]) or die(mysql_error()); //connect to database include('../../Connections/database.php'); $photo = $_FILES["photo"]["name"]; $qInsert = "INSERT INTO `photos` (`photo_name`) VALUES ('".$photo."')"; $rInsert = mysql_query($qInsert) or die(mysql_error()); //Tells you if its all ok if ($rInsert) { $url = "add_image_to_album.php?image_name='".$photo."'" or die(mysql_error()); header("Location: ".$url.""); } else { $errors = "There was an error inserting the image into the database"; } } ?> Notice I then post the image name to the next page. Now on the next page I have only this <?php include('../../Connections/database.php'); session_start();?> <?php echo '".$_GET['image_name']."' ;?> But there is an error at line one but I have tested the connection and its fine so its erroring displaying for example; landscape.png Does it have something to do with the .png in the name? If so how do i solve this? Hi I am having trouble with a login code which keeps producing a true value even when the password is incorrect. Just spent 4 hours writing code and I think I've gone a bit coo coo: Code: [Select] <h1>Login</h1> <p>If you are an existing member please login below. If you are new to this site please register to obtain your unqiue login and password by <a href="register.php">clicking here.</a></p> <?php require_once('common.php'); $error = '0'; if (isset($_POST['login'])){ // Get user input $username = isset($_POST['username']) ? $_POST['username'] : ''; $password = isset($_POST['password']) ? $_POST['password'] : ''; // Try to login the user $error = loginUser($username,$password); } ?> <?php if ($error != '') {?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="loginform"> <table width="100%"> <tr><td>Username:</td><td> <input name="username" type="text" /></td></tr> <tr><td>Password:</td><td> <input name="password" type="password" /></td></tr> <tr><td colspan="2" align="center"><input type="submit" name="login" value="Login" /></td></tr> </table> </form> <a href="register.php">Register</a> <?php } if (isset($_POST['login'])){ ?> <table width="100%"><tr><td><br/> <?php if ($error == '') { echo "<h1>Welcome $username! <br/>You are logged in!</h1><br/><br/>"; echo '<a href="browse_index.php"><h2>Now you can start shopping! ---CLICK HERE---</h2></a>'; } else echo $error; ?> <br/><br/><br/></td></tr></table> <?php } ?> Code for Common.php: ?php function loginUser($user,$pass){ $errorText = ''; $validUser = false; // Check user existance $pfile = fopen("users.txt","r"); rewind($pfile); //$counter=0; while (!feof($pfile)) { $line = fgets($pfile); $temp = explode(':', $line); if ($temp[5] == $user) { // User exists, check password if (trim($data[0]) == trim(md5($pass))){ $validUser= true; $_SESSION['userName'] = $user; //$counter = $counter + 1; //echo $data; } break; } } fclose($pfile); if ($validUser != false) $errorText = "Invalid username or password!"; if ($validUser == true) $_SESSION['validUser'] = true; else $_SESSION['validUser'] = false; return $errorText; } function logoutUser(){ unset($_SESSION['validUser']); unset($_SESSION['userName']); } function checkUser(){ if ((!isset($_SESSION['validUser'])) || ($_SESSION['validUser'] != true)){ header('Location: login.php'); } } ?> I'm sorry if this maybe is an obvious understanding for you, but i can't understand one thing with URL's. If i create my page called "index.php" and put it in a folder called "folder" then the URL in the address bar would be: http://www.website.com/folder/index.php But then i deside to add a few more pages with like next and previous links to scroll through them. I put those pages in a folder called "pages" within the folder "folder". Now the URL's would something look like this! http://www.website.com/folder/pages/page1.php http://www.website.com/folder/pages/page2.php etc... Thats the only way i know URL's are created and look like. But now too my question.. This is a few URL's i've seen on a site and every URL leeds to a new page but there is no slashes indicating new folders? How do you do that? Here is some examples of how the URL's could look like: http://www.website.com/index.php http://www.website.com/index.php?p=new http://www.website.com/index.php?p=new&page=121 http://www.website.com/merge.php http://www.website.com/merge.php?id=20381 And every URL was a comnpletly new page? |