Denian00 0 Denunciar post Postado Maio 7, 2015 Galera eu to com um problema em php no meu código está aparecendo esse erroWarning: mysqli_query() expects parameter 1 to be mysqli, string given in [/size]C:\Program Files (x86)\EasyPHP-DevServer-14.1VC11\data\localweb\projects\testingsite\AddPages.php on line 71Aqui está o meu código <?php require_once('Connections/cms.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; } } $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "AddPagesForm")) { $insertSQL = sprintf("INSERT INTO pages (PageName) VALUES (%s)", GetSQLValueString($_POST['NewPage'], "text")); mysqli_select_db($database_cms, $cms); $Result1 = mysql_query($insertSQL, $cms) or die(mysql_error()); $insertGoTo = "AddPages.php"; if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $insertGoTo)); } if ((isset($_POST['deletePagehiddenField'])) && ($_POST['deletePagehiddenField'] != "")) { $deleteSQL = sprintf("DELETE FROM pages WHERE ID=%s", GetSQLValueString($_POST['deletePagehiddenField'], "int")); mysql_select_db($database_cms, $cms); $Result1 = mysql_query($deleteSQL, $cms) or die(mysql_error()); $deleteGoTo = "AddPages.php"; if (isset($_SERVER['QUERY_STRING'])) { $deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?"; $deleteGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $deleteGoTo)); } $connection = mysqli_connect("localhost", "cms", "123456", "cms"); mysqli_select_db($connection, 'cms'); $query_Pages = "SELECT * FROM pages"; $Pages = mysqli_query($query_Pages, $cms) or die(mysql_error());#aqui está a linha setenta e um $row_Pages = mysql_fetch_assoc($Pages); $totalRows_Pages = mysql_num_rows($Pages); ?> me ajudem por favor eu ficarei muito agradecido ;) Compartilhar este post Link para o post Compartilhar em outros sites
Beraldo 864 Denunciar post Postado Maio 7, 2015 É o mesmo problema do seu outro tópico: http://forum.imasters.com.br/topic/536151-erro-php-warning-mysqli-select-db-expects-parameter-1-to-be-mysqli/ A solução é a mesma: passar o link da conexão no primeiro parâmetro Compartilhar este post Link para o post Compartilhar em outros sites
Denian00 0 Denunciar post Postado Maio 7, 2015 como assim? me mande um exemplo pfv ;) Compartilhar este post Link para o post Compartilhar em outros sites
Beraldo 864 Denunciar post Postado Maio 7, 2015 Veja a documentação da função. Tem exemplos lá http://php.net/manual/pt_BR/mysqli.query.php $link = mysqli_connect("localhost", "my_user", "my_password", "world"); mysqli_query($link, "SELECT..."); Compartilhar este post Link para o post Compartilhar em outros sites
jokita18 0 Denunciar post Postado Maio 7, 2015 a variavel $cms não parece ter sido declarada. Compartilhar este post Link para o post Compartilhar em outros sites