doyrte8419 2010-11-24 19:57
浏览 31

WebMatrix PHP mySQL

I am using WebMatrix Beta 3 which has support for php 5.2 and 5.3 I am able to run php pages but when I am trying to connect to mySql DB its not working.

Can anyone please suggest me the right way of doing it.

The connection code is written in a file called dbinfo.php which resides under config folder

<?php
$hostname = '127.0.0.1';
$username = 'root';
$password = 'password';
$database = 'test';

$link = mysql_connect($hostname, $username, $password)
  or die("Could not connect : " . mysql_error());
mysql_select_db($database) or die("Could not select database");

//Below function added to allow customized unescaping.
function mysql_unescape($sRet_VAL=""){
  $sRet_VAL = str_replace('\"','"',$sRet_VAL);
  $sRet_VAL = str_replace("\'","'",$sRet_VAL);
return $sRet_VAL;
}
?>

and I am using this file as follows

<?php
require_once( $_SERVER['DOCUMENT_ROOT'] . '/config/dbinfo.php');
?>
<?php

    $query = "SELECT * from temp";
    $result = mysql_query($query)
        or die("Error: " . mysql_error());
?>
  • 写回答

1条回答 默认 最新

  • douji9184 2010-11-25 09:46
    关注

    it worked seems like webmatrix do not recognize I replaced it wilt <>php echo $varData ?> and it worked.

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作