473,473 Members | 1,873 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

getting Warning: mysql_result() expects parameter 2 to be long, string?

127 New Member
Retrieving a data from a table. the table has only one filed.
table name: qupdate
filed: last_update

Expand|Select|Wrap|Line Numbers
  1. $sql4="SELECT * FROM qupdate";
  2. $result4=mysql_query($sql4);
  3. $last_update=mysql_result($result4,"last_update");
  4.  
but I am getting Warning:mysql_result() expects parameter 2 to be long, string...
on this line,
Expand|Select|Wrap|Line Numbers
  1. $last_update=mysql_result($result,"last_update");
the following code not executing...
Expand|Select|Wrap|Line Numbers
  1. if($last_update==$today)
  2. {
  3.     $cqid=mysql_result($result,"cqid");
  4. $update1="update cquestions set showdate='$tomorrow' where showdate='0000-00-00' and cqid!='$cqid' order by cqid limit 2";
  5. mysql_query($update1);
I have run the code on my local server (wamp) php 5.2.5. it runs without any problem.

when I uploaded the code on the web server, (PHP Version 5.5.18) I am getting this warning and the following code not executing.

full code:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. $today=date("Y-m-d");
  4. mysql_query("SET CHARACTER SET utf8");
  5. echo "<form method='post' id='submit' action='checkresult2.php'>";
  6. $sql="SELECT * FROM cquestions where showdate='$today' limit 1,1";
  7. $result=mysql_query($sql);
  8. while ($row = mysql_fetch_array($result)) {
  9. echo "<p>" . $row['cqtext'] . "</p>";
  10. $sql2="SELECT * FROM canswers where cqid=".$row['cqid'];
  11. $result2=mysql_query($sql2);
  12. while($row2=mysql_fetch_assoc($result2))
  13. {
  14. echo "<input type='radio' name='".$row['cqid']."' value='".$row2['cqans']."' />".$row2['aatext'];
  15. echo"<br>";
  16. }
  17. }
  18. $tomorrow= date("Y-m-d", strtotime("tomorrow"));
  19. $sql4="SELECT * FROM qupdate";
  20. $result4=mysql_query($sql4);
  21. $last_update=mysql_result($result4,"last_update");
  22. if($last_update==$today)
  23. {
  24.     $cqid=mysql_result($result,"cqid");
  25. $update1="update cquestions set showdate='$tomorrow' where showdate='0000-00-00' and cqid!='$cqid' order by cqid limit 2";
  26. mysql_query($update1);
  27. $update2="update qupdate set last_update='$tomorrow'";
  28. mysql_query($update2);
  29. $sql3="SELECT * FROM qupdate";
  30. $result3=mysql_query($sql3);
  31. $last_update=mysql_result($result3,"last_update");    
  32. }
  33. echo"<br>";
  34. echo"<br>";
  35. echo "<div align='left' style='padding-left:160px;'>";
  36. echo"<input type='submit' id='submit' name='submit' value='التالي' />";
  37. echo "</div>";
  38. echo "</form>" ;
  39. ?>
how to fix this?
Nov 26 '14 #1
2 6399
Luuk
1,047 Recognized Expert Top Contributor
In the manual it says:
string mysql_result ( resource $result , int $row [, mixed $field = 0 ] )

This means that the second parameter should be an int

If a string is given as second parameter,
then PHP will try to convert this to an int (because it expects an integer),
if that fails, than the warning is shown....

You should read the docs, and probably (i'm not seeing your comlete code) you can change this second parameter to '0' (without the single quotes), Because this second parameter is defined as: "The row number from the result that's being retrieved. Row numbers start at 0. "
Nov 26 '14 #2
impin
127 New Member
that's works. great! thank you.
Nov 26 '14 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Mini Mouse | last post by:
Hiya folks, I'm getting the following error(s) below and I'm at a bit of a loss as to how to correct it. When I give it a parameter it then complains it needs two parameters and the second one...
1
by: malayappa | last post by:
Hi All here is the error what i m getting Warning: domdocument::domdocument() expects parameter 2 to be long, string given in D:\Program Files\Apache Software...
1
Paul NIcolai Sunga
by: Paul NIcolai Sunga | last post by:
what is wrong with my code? $Link = mysqli_connect("localhost","root","tupi"); if (!$Link) { die("Could not connect: " . mysql_error()); }...
1
by: dragos42 | last post by:
m from Romania and I bought the book let yourself, bother with a problem to conduct script 14.2 appear: The file has been uploaded! Warning: mysqli_query() expects parameter 1 to be mysqli,...
3
by: mocha | last post by:
I have this error message --> Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\script.php on line 24 You have an error in your SQL syntax; check the...
1
by: rameshbabu1251 | last post by:
hi i am getting this warning Warning: mysql_fetch_field() expects parameter 1 to be resource, boolean given in :\wamp\www\phpclasses\inserttestdetails.php on line 62 my code is please help me...
1
by: voncolin | last post by:
Warning: mktime() expects parameter 6 to be long any advice would be appreciated im a newbie thanks !! wordpress template on my dashboard error Warning: mktime() expects parameter 6 to be long,...
3
by: Cheyens | last post by:
Hi, This works as long one or both Checkboxes are checked: <?php if( in_array( 'Red', get_field('materiale') ) ) {echo '<a href="' . get_field('download') . '" target="_blank"...
2
by: Bhutan123 | last post by:
<?php if(isset($_POST)) { $regNumber=trim($_POST); $qry="SELECT * FROM tblscore WHERE Registration_Number='$regNumber'"; $run=mysql_query($qry,$connection)or die("Database...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.