Resource id #4

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sip3
    New Member
    • Dec 2007
    • 3

    Resource id #4

    Hi all,

    i'm a new user of PHP,

    at the moment, i have queries regarding the "Resource id #4"

    everythings run perfectly but before the script showing the result,
    it shows the "Resource id #4" in front of the result, and i don't have any clue what happend with it.

    Could someone please help me with it.

    thanks a lot,
    regards,
    adi

    here is my code:
    [code=php]
    <?php
    require_once('d bconnect.php');
    $trackID = $_GET['TrackId'];
    $trackName = mysql_query("SE LECT TrackName FROM EHAC_track where TrackId='$track ID'");
    $meetingList = mysql_query("SE LECT MeetingID, MeetingDate FROM EHAC_meeting WHERE TrackId='$track ID' ORDER BY MeetingDate");
    ?>

    <ul>
    <?php
    error_reporting (E_ALL);
    ini_set('displa y_errors', true);
    Echo $trackName;
    $count = 0;
    while ($row = mysql_fetch_arr ay($meetingList )) {
    Echo "<li><a href=raceInform ation.php?Meeti ngID=".$row['MeetingID']." class=\"item-link-1\">".$row['MeetingDate']."</a></li>";
    $count++;
    }
    if($count==0){
    Echo "<span class=\"header-2\">No date available on this track</span>";
    }
    ?>
    </ul>[/code]
    Last edited by pbmods; Dec 16 '07, 08:46 PM. Reason: Added CODE tags.
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    Code:
    <?php
    require_once('dbconnect.php');
    $trackID = $_GET['TrackId'];
    $trackName = mysql_query("SELECT TrackName FROM EHAC_track where TrackId='$trackID'");
    $meetingList = mysql_query("SELECT MeetingID, MeetingDate FROM EHAC_meeting WHERE TrackId='$trackID' ORDER BY MeetingDate");
    
    //instead of stopping the parsing of php just echo-out the <ul>
    echo "<ul>";
    
    error_reporting(E_ALL);
    ini_set('display_errors', true);
    
    //this is the problem line
    Echo $trackName;
    $count = 0;
    while ($row = mysql_fetch_array($meetingList)) {
    Echo "<li><a href=raceInformation.php?MeetingID=".$row['MeetingID']." class=\"item-link-1\">".$row['MeetingDate']."</a></li>";
    $count++;
    }
    if($count==0){
    Echo "<span class=\"header-2\">No date available on this track</span>";
    }
    ?>
    Line 14 is the problem.
    You need to use one of the provided mysql functions
    i.e:
    Code:
    while($track = mysql_fetch_array($trackName)){
        echo $track;
    }
    Hope this helps :)
    Last edited by gits; Jul 5 '19, 12:09 PM. Reason: fix old code tags

    Comment

    • sip3
      New Member
      • Dec 2007
      • 3

      #3
      hi,

      i have tried it, and you are correct that the problem is from line 14 but after i implement it, it shows "array" instead of "resource id#4".

      i don't know why it shows array now.
      i'm really sorry to ask a lot of question because i'm really new in here and this is my assignment for my uni.

      thanks for the help.
      regards,
      adi

      Comment

      • Markus
        Recognized Expert Expert
        • Jun 2007
        • 6092

        #4
        Sorry, i forgot a bit of it.

        Code:
        while($track = mysql_fetch_array($trackName)){
            echo $track;
        }
        needs to be

        Code:
        while($track = mysql_fetch_array($trackName)){
            echo $track[*table_row_name*];
        }
        *table_row_name * needs to be substituted with the appropriate row name.
        :)
        Last edited by gits; Jul 5 '19, 12:10 PM. Reason: fix old code tags

        Comment

        • sip3
          New Member
          • Dec 2007
          • 3

          #5
          You are the star Markus :)

          thank you very much for your help.

          and i might need your help in the near future as i just started my assignment and i believe i will face a lot of trouble in this because i don't have IT background.

          once again,

          thank you.
          regards,
          adi

          Comment

          • Markus
            Recognized Expert Expert
            • Jun 2007
            • 6092

            #6
            No problem at all :)

            post back whenever you need some help

            also, remember to use CODE tags when posting - it helps us work through your code.

            -markus

            Comment

            • nsr7
              New Member
              • Jul 2019
              • 1

              #7
              Hi Markus - Could u plz rectify my code as well??

              Code:
              <?php
              
              if (isset($_POST['verifyotp'])) {
              
              	// Authorisation details.
              	$username = "foo@bar.foobar";
              	$hash = "01993a995a047af1dfe20536da550cf101e571c9f7ba4a05bd6638417d79455f";
              
              	// Config variables. Consult [url]http://api.textlocal.in/docs[/url] for more info.
              	$test = "0";
              	$numbers = $_POST['otpnumber'];
              
              	// Data for text message. This is the text message data.
              	$sender = "TXTLCL"; // This is who the message appears to be from.
              	$numbers = $_POST['otpnumber']; // A single number or a comma-seperated list of numbers
              	$otp = mt_rand(100000,999999);
              	setcookie("otp", $otp);
              	$message = "Dear Subscriber Your OTP is ".$otp;
              	// 612 chars or less
              	// A single number or a comma-seperated list of numbers
              	$message = urlencode($message);
              	$data = "username=".$username."&hash=".$hash."&message=".$message."&sender=".$sender."&numbers=".$numbers."&test=".$test;
              	$ch = curl_init('http://api.textlocal.in/send/?');
              	curl_setopt($ch, CURLOPT_POST, true);
              	curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
              	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
              	$result = curl_exec($ch); // This is the result from the API
              
              	curl_close($ch);
              
              	if ($ch) {
              		echo "CURL Error #: " .$ch;
              	}
              	else
              	{
              		$json = json_decode($result);
              
              		if ($json->type == 'success') 
              		{
              			header('location: otpverified.php');
              		}
              		if ($json->type == 'error') 
              		{
              			echo 'Your OTP is not Verified "'.$json->message.'" ';
              		}	
              
              }
              
              }
              
              ?>
              Last edited by gits; Jul 5 '19, 12:12 PM. Reason: added code tags and replace email/username

              Comment

              Working...