lots_o_nuts Posted February 24, 2009 Share Posted February 24, 2009 Since mysqli should be safer then mysql i started transforming my code to the new situation, the only problem is that after many hours of frustration it still isn't working... The required information: SQL-server version: mysql-server.i386-5.0.45-4.fc8 PHP-version: php.i386-5.2.4-3 I am using the php/mysql combo in a CMS, and the table i extract the data from has the following form: pageidpagenamehtml 1home<B>some html code</B> Now with mysql i used the following code to return the html-code: <?php $con =mysql_connect("***","***","***"); if ($con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("database",$con); if(empty($_GET['pageid'])) { $pageid = 1; } else { $pageid =_GET['pageid']; } $query = "SELECT html FROM pages WHERE pageid=" . $pageid; $result = mysql_query($query); $html = mysql_fetch_array($result); echo $html['html']; mysql_close($con); ?> Now this gives me, as expected <B>some html code</B> when pageid is 1. But when i try to implement the code according to the article on http://devzone.zend.com/node/view/id/686, and especially the "Using Bound Parameters and Bound Results Together" example, the following code: <?php $pageid = 1; $mysqli = new mysqli('***', '***', '***', 'database'); if (mysqli_connect_errno()) { printf("Can't connect to MySQL Server. Errorcode: %s\n", mysqli_connect_error()); exit; } if ($stmt = $mysqli->prepare('SELECT html FROM pages WHERE pageid = ?')) { $stmt->bind_param("i", $pageid); $stmt->execute(); $stmt->bind_result($row); $stmt->fetch(); var_dump($row); $stmt->close(); } $mysqli->close(); ?> gives me string(0) "" as output. I have no php errors/warnings/notices whatsoever, and mysql also isn't giving my any errors. What am i doing wrong? If more information is needed, please say so. --LoN Link to comment https://forums.phpfreaks.com/topic/146614-solved-mysql-to-mysqli-migrationproblems/ Share on other sites More sharing options...
lots_o_nuts Posted February 24, 2009 Author Share Posted February 24, 2009 Ok... mysqli doesn't like columns named html... When i renamed that column, everything worked like a charm... Link to comment https://forums.phpfreaks.com/topic/146614-solved-mysql-to-mysqli-migrationproblems/#findComment-770002 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.