Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[PHP] "supplied argument is not a valid MySQL result resource"

Empfohlene Antworten

Veröffentlicht

Hi,

ich wei es gibt bereits ein paar themen damit aber ich kann sie einfach nich auf meinen Fall übertragen, außerdem ist php nich wirklich so mein ding.

Um genau zu sein, das gesamte Paging is nicht von mir, hab es so aus bereits vorhandenen seiten genommen :(

Nun, aufjedenfall bekomme ich diese Fehlermeldungen:

Resource id #1

Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /home/s/snowman-x.free-speicher1.de/public_html/weblog.php on line 30


Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/s/snowman-x.free-speicher1.de/public_html/weblog.php on line 42

http://knueppeldick.de.ms/weblog.php Mein Code:
<?php

echo $connection = mysql_connect('localhost', 'username', 'Passwort');


function getPagerData($numHits, $limit, $page)

       {

           $numHits  = (int) $numHits;

           $limit    = max((int) $limit, 1);

           $page     = (int) $page;

           $numPages = ceil($numHits / $limit);


           $page = max($page, 1);

           $page = min($page, $numPages);


           $offset = ($page - 1) * $limit;


           $ret = new stdClass;


           $ret->offset   = $offset;

           $ret->limit    = $limit;

           $ret->numPages = $numPages;

           $ret->page     = $page;


           return $ret;

       }


	// get the pager input values

    $page = $_GET['page'];

    $limit = 20;

    $result = mysql_query("select count(*) from myTable");

    $total = mysql_result($result, 0, 0);


    // work out the pager values

    $pager  = getPagerData($total, $limit, $page);

    $offset = $pager->offset;

    $limit  = $pager->limit;

    $page   = $pager->page; 


    // use pager values to fetch data

    $query = "select * from blog_test order by id desc limit $offset, $limit";

    $result = mysql_query($query);


    while($row = mysql_fetch_array($result)){

		echo "$row[0] - $row[1] - $row[2] - $row[3]";

    }


    // output paging system (could also do it before we output the page content)

    if ($page == 1) // this is the first page - there is no previous page

        echo "<<";

    else            // not the first page, link to the previous page

        echo "<a href=\"weblog.php?page=" . ($page - 1) . "\"><<</a>";


    for ($i = 1; $i <= $pager->numPages; $i++) {

        if ($i == $pager->page)

            echo "$i";

        else

            echo "<a href=\"weblog.php?page=$i\">$i</a>";

    }


    if ($page == $pager->numPages) // this is the last page - there is no next page

        echo ">>";

    else            // not the last page, link to the next page

        echo "<a href=\"weblog.php?page=" . ($page + 1) . "\">>></a>";


?>

Die Datenbank - zwei einträge zum testen sind drinnen:

ID as int | Datum as varchar | Header as varchar | content as largetext

THX

hat sich erledigt

Das

$page = $_GET['page'];
wurde zu
if (!isset($_GET['page'])) {

		$page = 1;

	}

	else{$page = $_GET['page'];}

Wundert mich, dass er das so ohne zu murren macht, da du ja nichtmal eine Datenbank auswählst, oder ein an eine Datenbank gebundenes Query absetzt.

Aber da es ja geht, wird es wol stimmen *G*

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.