mysql_select_db() expects parameter 2 to be resource, object given ... HELP

Dear All

I’m having trouble with a piece of code that I (used to) use daily, but after changing pc I ran into trouble:

in Win xp prof
with
apache 2.2.11
php 5.3.0
mySQL 5.1.36
the below code works fine - but

in Win 8.1
with
apache 2.2.22
php 5.3.13
mySQL 5.5.24

I get these 2 warnings:

Warning: mysql_select_db() expects parameter 2 to be resource, object given in C:\wamp\www\obs_mphp\observations_v2f10.php on line 35

Warning: mysql_query() expects parameter 2 to be resource, object given in C:\wamp\www\obs_mphp\observations_v2f10.php on line 37

Could some one pls help me out?

all the best

Peter

The code:

[php]<?php require_once('Connections/obs.php'); ?>

<?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } mysql_select_db($database_obs, $obs); $query_rsDag = "SELECT DATE_FORMAT(dato, '%d/%m %Y') AS curDato FROM obsf10 ORDER BY dato DESC"; $rsDag = mysql_query($query_rsDag, $obs) or die(mysql_error()); $row_rsDag = mysql_fetch_assoc($rsDag); $totalRows_rsDag = mysql_num_rows($rsDag);mysql_select_db($database_obs, $obs); $query_rsDag = "SELECT DATE_FORMAT(dato, '%d/%m %Y') AS curDato FROM obsf10 GROUP BY curDato ORDER BY dato DESC"; $rsDag = mysql_query($query_rsDag, $obs) or die(mysql_error()); $row_rsDag = mysql_fetch_assoc($rsDag); $totalRows_rsDag = mysql_num_rows($rsDag); ?> Observationer <!-- #datoen { font-family: Verdana, Geneva, sans-serif; font-size: 16px; font-weight: bold; color: #821D1D; }

#vejr1 {
font-family: Verdana, Geneva, sans-serif;
font-size: 12px;
color:#00008B;
font-weight: normal;
}
–>

<?php $dag = ""; do { if ($row_rsDag['curDato'] != $dag) { $dag = $row_rsDag['curDato']; echo "
$dag
"; ?> <?php } ?> <?php $query_rsObs = "SELECT Art, Voous, TRL, Antal, Sex, age "; $query_rsObs .= "FROM obsf10 WHERE DATE_FORMAT(Dato, '%d/%m %Y') = '$dag' ORDER BY Voous ASC"; $rsObs = mysql_query($query_rsObs, $obs) or die(mysql_error()); $row_rsObs = mysql_fetch_assoc($rsObs); $totalRows_rsObs = mysql_num_rows($rsObs); ?>
Vejr:

Obs: <?php do { echo $row_rsObs['Art'] . " " . $row_rsObs['Antal'] . " " . $row_rsObs['Sex'] . " " . $row_rsObs['age'] . " " . $row_rsObs['TRL'] . ", " ; } while ($row_rsObs = mysql_fetch_assoc($rsObs)); ?>

 

 

<?php } while ($row_rsDag = mysql_fetch_assoc($rsDag)); ?>


<?php //mysql_free_result($rsWeather); mysql_free_result($rsObs); mysql_free_result($rsDag); ?>[/php]

That code is obsolete and has been completely removed from Php. You need to use PDO

https://phpdelusions.net/pdo

Sponsor our Newsletter | Privacy Policy | Terms of Service