php的sql语句为$sql=“select count(courseid)from stucourse where courseid=1”,怎么讲sql的结果用echo或者是什么方式显示出来呢?



$sql = "select count(*) as VAR rom table";
$query = mysql_query($sql);
$row = mysql_fetch_array($query);
echo $row['VAR'];

控制下一行如何返回给调用者。此值必须是 PDO::FETCH_* 系列常量中的一个,缺省为 PDO::ATTR_DEFAULT_FETCH_MODE 的值 (默认为 PDO::FETCH_BOTH )。
PDO::FETCH_BOUND:返回 TRUE ,并分配结果集中的列值给PDOStatement::bindColumn() 方法绑定的 PHP 变量。
PDO::FETCH_CLASS:返回一个请求类的新实例,映射结果集中的列名到类中对应的属性名。如果 fetch_style 包含 PDO::FETCH_CLASSTYPE(例如:PDO::FETCH_CLASS | PDO::FETCH_CLASSTYPE),则类名由第一列的值决定

Csdn user default icon

RT. 讨论一下思路 <br />String getTableNames(String sqlStmt){ <br />&nbsp;&nbsp;&nbsp;&nbsp; .... //该如和设计解析逻辑 <br />} <br /> <br />例如: <br />sqlStmt = " <br />INSERT INTO A <br />SELECT B.B1, B.B2, C.C1, C.C2 <br />FROM B INNER JOIN C ON B.B0 = C.C0 <br />WHERE B.B0 IN (SELECT D0 FROM D,E WHERE D.D1 = E.E1) <br />"; <br /> <br />要求getTableNames(sqlStmt)的输出为 "A,B,C,D,E" <br /> <br />需要考虑到所有DML语句包括JOIN结构以及子查询的情况 <br />


<div class="post-text" itemprop="text"> <p>I'm creating a system that allows you to add a message with multiple images uploaded. The uploading of all the images goes well, however, when I try to insert all the image locations into a table that has a foreign key from the table 'messages' (so that every image knows to which message it belongs), I get the following error:</p> <pre><code>Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`scrapll`.`scrapimage`, CONSTRAINT `scrapimage_ibfk_1` FOREIGN KEY (`scrap_id`) REFERENCES `scraps` (`scrap_id`))' in C:\xampp\htdocs\scrapll_m_nonstatic\process ew\scrap_process.php:132 Stack trace: #0 C:\xampp\htdocs\scrapll_m_nonstatic\process ew\scrap_process.php(132): PDOStatement-&gt;execute(Array) #1 {main} thrown in C:\xampp\htdocs\scrapll_m_nonstatic\process ew\scrap_process.php on line 132 </code></pre> <p>This only happens when I try to upload multiple images. When I only upload one image, no issues at all. </p> <p>Here's the code:</p> <pre><code>foreach($_FILES['scrapPhotos']['tmp_name'] as $key =&gt; $tmp_name ){ $fileName = $_FILES['scrapPhotos']['name'][$key]; $fileSize = $_FILES['scrapPhotos']['size'][$key]; $fileTmp = $_FILES['scrapPhotos']['tmp_name'][$key]; $fileType= $_FILES['scrapPhotos']['type'][$key]; if($_FILES['scrapPhotos']['name'][$key]){ // Get file extension of uploaded file $imgFileExtension = strrchr($fileName, "."); // Check if file extension of uploaded file is valid if(!in_array($imgFileExtension, $validFileExtensions)) { echo $scrapErrors[0]; } // Check if file size is valid (!&gt; 10000000) elseif($fileSize &gt; MAXFILESIZE) { echo $scrapErrors[1]; } else { // The path to Scrap image $imgLoc = "../../../scrapll_m/static/img/user/scrap/orig/"; // Move files to appropiate location $imgFile = sha1(uniqid($_FILES['scrapPhotos']['name'][$key])); $imgFilePath = $imgLoc . $imgFile . $imgFileExtension; // Store image(s) on the server move_uploaded_file($_FILES['scrapPhotos']['tmp_name'][$key], $imgFilePath); $insertImgQuery = 'INSERT INTO scrapimage (scrap_id, image_original_size, image_scrap_size) VALUES (LAST_INSERT_ID(), ?, ?)'; $prepInsertImg = $conn-&gt;prepare($insertImgQuery); $prepInsertImg-&gt;execute(array($imgFilePath, $imgFilePath)); } } } </code></pre> <p>So, why can't I make the SQL query at the bottom of my code to be executed multiple times and add one row with the next image locations to the database? I've put it in a foreach to do that, but it doesn't seem to work.</p> </div>

php编程SQL语句union all的使用编程

![图片说明]( id分别是ishijian1,ishijian2,语句是<?php echo '<input style=" margin-left:80;font-family:Arial, Helvetica, sans-serif; font-size:12px; margin-top:8;" name="chadingdan" id="chadingdan" type="button" value="报表查询" onclick="cchadingdan()"/>&nbsp;'; ?> </td></tr> <tr> <td valign="top" style="width:903; " > <form id="post1" name="post1" method="post" action="c_huizong.php" > <table border="0" cellspacing="1"cellpadding="1" align="center" style="width:900; font-family:Arial, Helvetica, sans-serif; font-size:12px"> <tr > <td title="格式:8位数字 示例:20131231&#xd;默认搜索当前三个月内的订单&#xd;要搜索之前的订单请修改或清空本项"><div align="center">起始时间</div></td> <td title="格式:8位数字 示例:20131231&#xd;默认搜索当前三个月内的订单&#xd;要搜索之前的订单请修改或清空本项" width="165"><input type="text" name="1shijian1" id="1shijian1" TABINDEX="1" maxlength="8" onkeyup="value=value.replace(/[^\d]/g,'') " onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d.]/g,''))" style="font-family:Arial, Helvetica, sans-serif; font-size:12px;width:160"/></td> </tr> <tr> <td title="格式:8位数字 示例:20140115"><div align="center">截止时间<br> </div></td> <td title="格式:8位数字 示例:20140115"><input type="text" name="1shijian2" id="1shijian2" TABINDEX="2" maxlength="8" onkeyup="value=value.replace(/[^\d]/g,'') " onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d.]/g,''))" style="font-family:Arial, Helvetica, sans-serif; font-size:12px;width:160"/></td> <td><div align="center"> <input style="font-family:Arial, Helvetica, sans-serif; font-size:12px" type="submit" name="post1" value="查询" tabindex="3" /> &nbsp; <input style="font-family:Arial, Helvetica, sans-serif; font-size:12px" type="reset" name="qingkong1" value="重置" tabindex="4"/> </div></td> </tr> </table> </form> </td> </tr> </table><p></p> c_huizong.php <?php //订单查询 if ($_POST['1shijian1']) { echo "<script type='text/javascript'> document.getElementById('1shijian1').value='".$_POST['1shijian1']. "';document.getElementById('1shijian2').value='".$_POST['1shijian2']. "';cg1name();</script>"; if ($_POST['1shijian1']<>NULL) $shijian1=" and COPTC.TC003>=".$_POST['1shijian1']; else $shijian1=""; if ($_POST['1shijian2']<>NULL) $shijian2=" and COPTC.TC003<=".$_POST['1shijian2']; else $shijian2=""; require_once('i_code/connect.php'); $query="select leixing,xifen,sewen,ddgm,bztdb,daba,SUM(TD008) AS TD008,SUM(TA015)TA015,SUM(RKZS)RKZS,SUM(D310)D310,SUM(D305)D305,SUM(D304)D304,SUM(D3023)D3023,SUM(TH008)TH008,SUM(TJ007)TJ007 FROM chaxun LEFT JOIN DDTJMX ON MA003=leixing and xifen=XIFEN AND sewen=DDTJMX.UDF10 AND ddgm=DDGM and daba=XINGHAO left join COPTC on TC001=DDTJMX.TD001 AND TC002=DDTJMX.TD002 where xifen<>'' and xifen<>'5050' and TC003>='20150110' AND TC003<='20150120' GROUP BY leixing,xifen,sewen,ddgm,bztdb,daba union all select leixing,xifen,null as sewen,null as ddgm,bztdb,null as daba,SUM(TD008) AS TD008,SUM(TA015)TA015,SUM(RKZS)RKZS,SUM(D310)D310,SUM(D305)D305,SUM(D304)D304,SUM(D3023)D3023,SUM(TH008)TH008,SUM(TJ007)TJ007 FROM chaxun LEFT JOIN DDTJMX ON MA003=leixing and xifen=XIFEN left join COPTC on TC001=DDTJMX.TD001 AND TC002=DDTJMX.TD002 where xifen='5050' and TC003>='20150110' AND TC003<='20150120' GROUP BY leixing,xifen,bztdb union all select leixing,null as xifen,null as sewen,null as ddgm,bztdb, null as daba,SUM(TD008) AS TD008,SUM(TA015)TA015,SUM(RKZS)RKZS,SUM(D310)D310,SUM(D305)D305,SUM(D304)D304,SUM(D3023)D3023,SUM(TH008)TH008,SUM(TJ007)TJ007 FROM chaxun LEFT JOIN DDTJMX ON MA003=leixing left join COPTC on TC001=DDTJMX.TD001 AND TC002=DDTJMX.TD002 where xifen='' and TC003>='20150110' AND TC003<='20150120' GROUP BY leixing,bztdb".$shijian1.$shijian2; $result=mssql_query($query); $row_num=mssql_num_rows($result); if ($row_num<=10000 && $row_num>0) { echo "<p></p><table class='tablehkled' id='tablecolor' align='center' cellspacing='0'cellpadding='0' style='width:95%'> <tr align='center'>"; echo "<th style='width:80px'>类别</th>; <th style='width:80px'>细分</th>; <th style='width:150px'>色温</th>; <th style='width:100px'>订单规模</th>; <th style='width:100px'>标准投单比</th>; <th style='width:100px'>打靶</th>; <th style='width:100px'>订单量</th>; <th style='width:100px'>预计产量</th>; <th style='width:100px'>总入库数</th>; <th style='width:80px'>标准入库</th>; <th style='width:80px'>销货数量</th>; <th style='width:80px'>销退数量</th>; <th style='width:80px'>跟踪信息</th>; </tr></tr>"; while($row=mssql_fetch_assoc($result)) { echo"<tr align='center'>"; echo"<td>".$row['leixing']."</td>"; echo"<td>".$row['xifen']."</td>"; echo"<td>".$row['sewen']."</td>"; echo"<td>".$row['ddgm']."</td>"; echo"<td>".$row['bztdb']."</td>"; echo"<td>".$row['daba']."</td>"; echo"<td>".number_format($row['TD008'],0)."</td>"; echo"<td>".number_format($row['TA015'],0)."</td>"; echo"<td>".number_format($row['RKZS'],0)."</td>"; echo"<td>".number_format($row['D310'],0)."</td>"; echo"<td>".number_format($row['TH008'],0)."</td>"; echo"<td>".number_format($row['TJ007'],0)."</td>"; echo"<td onclick='\"3_all.php?n1=".trim(strval($row['leixing']))."\")'>跟踪信息</td>"; //跟踪信息 echo"</tr> \n"; } echo"</table><p>&nbsp;</p>"; echo'<SCRIPT type="text/javascript" src="i_code/color.js"></SCRIPT>'; } mssql_close($conn); } ?> 现在一运行语句是错的,是后面的语句里面的查询语句有错,求指正。


代码如下: ``` $project_list = array(1,2,3,4,5); foreach($project_list as $key => $val){ $project_uid = $project_list[$key]['uid']; $condition['uid'] = array('EQ',$project_uid); $weekscene_sum_visit = $weekscene->where($condition)->sum('visit'); echo $weekscene_sum_visit; } ``` 上面代码是对数据库中某字段的求和,条件是某个时间段的,循环执行多次SQL是因为uid的值不同,也就是分不同项目,即某时间段不同项目对某字段的求和。 在thinkphp控制器中上面的代码要怎样改,和模板中的代码要怎么写才能循环输出?


[code="java"]<?php $con = mysql_connect("localhost","root","5555555551"); //mysql_query("SET NAMES 'UTF-8'"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("zuobiao",$con); //选择数据库 for ($i=1;$i<=5;$i++){ $x= mysql_query("select x,y from t1 order by DrugSId asc limit 1,$i"); $rs = mysql_fetch_array($x); $cc=$rs['y'].",".$rs['x']; //echo $cc."<br>"; $url="$cc&&radius=500&sensor=false&key=AIzaSyCxLAQfEbXSARI3UD7_Nkj0WbVvQqnQuX0"; $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $body=curl_exec($curl); curl_close($curl); $place=json_decode($body,true); foreach ($place as $b){ foreach((array)$b as $c){ if(!is_array($c)) continue; $d=$c['name'].","; //echo $d; $sql=mysql_query("insert into t1(keywords) values ('$d')"); // echo $sql // or die ('SLQ Syntax error '.mysql_error()); if ($d == null){ continue;} } } } ?> [/code] 数据库结构如下 [img][/img] --------------------------------------- 如果直接输出$d,是正常的,可以获得一串地名,但是如果插入数据库就只能获得一串地名中的一项.请问哪个地方写错了,如何修改? 为方便各位高手调试,给出1-5之内的数据 [img][/img]


<div class="post-text" itemprop="text"> <p>I've wrote an function (In Go, of course) that inserting <code>map[string]interface{}</code> to mysql via <a href="" rel="nofollow">this</a> library.</p> <h2>Explanation of the code below:</h2> <ol> <li>The functions receives <code>string</code> called <em>table</em> and <code>map[string]interface{}</code> called <em>data</em>.</li> <li>I separate the <code>data</code> to keys (variable called <em>columns</em>) and values (variable called <em>values</em>).</li> <li>I generate from the <em>columns</em> variable called <em>column_text</em> that will look like this: <code>first_name, last_name, birth_day, date_added</code></li> <li>I generate from the <em>values</em> variable called <em>variable_text</em> that will look like this: <code>?, ?, ?, ?</code></li> <li>I open mysql connection: <code>db, err := sql.Open("mysql", "user:pass@/database")</code></li> <li>I create prepared statement: <code>stmt, err := db.Prepare("INSERT INTO " + table + " ( " + columns_text + " ) VALUES ( " + values_text + " )")</code></li> <li>I execute the prepare statement. but I have a problem. the number of the columns and values changes all the time, and the <code>stmt.Exec()</code> command can't receive an slice (Array) like this: <code>stmt.Exec(values)</code>, only the values alone like this: <code>stmt.Exec(values[0], values[1], values[2]...)</code></li> </ol> <h2>The question:</h2> <p>I'm coming from PHP, where PDO::Statement could receive an array when executing. How can I execute the statement with the slice (Array)? (If I can do it with different library, please write the name of the library and how to use it, thank you!)</p> <h2>The code:</h2> <pre><code>func insertToDB(table string, data map[string]interface{}) { columns := make([]interface{}, 0, len(data)) values := make([]interface{}, 0, len(data)) for key, _ := range data { columns = append(columns, key) values = append(values, data[key]) } columns_text := "" i := 0 of := len(data) for i &lt; of { column := columns[i].(string) if i == 0 { columns_text = column } else { columns_text = columns_text + ", " + column } i++ } fmt.Println(columns_text + " = " + table) values_text := "" i = 0 for i &lt; of { if i == 0 { values_text = "?" } else { values_text = values_text + ", ?" } i++ } fmt.Println(values_text) fmt.Println(values) fmt.Println(data) db, err := sql.Open("mysql", "root:root@/bacafe") if err != nil { return -1, err } defer db.Close() stmtIns, err := db.Prepare("INSERT INTO " + table + " ( " + columns_text + " ) VALUES ( " + values_text + " )") if err != nil { return -1, err } defer stmtIns.Close() // Close the statement when we leave main() / the program terminates result, err := stmtIns.Exec(values...) if err != nil { return -1, err } else { insertedID, err := result.LastInsertId() if err != nil { return -1, err } else { return int(insertedID), nil } } } </code></pre> <p><strong>EDIT: I've edited the function above and it works perfectly now.</strong></p> <p>Thank you!</p> </div>

在php中运行SQL查询然后打印出结果时,调用成员函数prepare()on null error

<div class="post-text" itemprop="text"> <p>i am trying to run the following piece of SQL code in a php file</p> <pre><code>Select show_id, show_name From (tv_shows JOIN distributes on D_SHOW_ID=SHOW_ID) Where show_name= ‘Show Name’ </code></pre> <p>(where 'Show Name' is a variable the the user passes in.) The SQL functions perfectly in mySQL but i just can't seem to print the results without errors occurring.</p> <p>i tried</p> <pre><code>$mysqli = include ('./DBconnect.php'); $sql = 'SELECT show_id, show_name FROM (tv_shows JOIN distributes ON D_SHOW_ID=SHOW_ID) WHERE show_name= ? '; $stmt = $mysqli-&gt; prepare($sql); // getting the variable from the user input $showName = $_GET["name"]; //testing if the variable is passed through echo $showName."is printed"; $stmt-&gt;bind_param('s',$showName); $stmt-&gt; execute(); $stmt -&gt; bind_result($show_id,$show_name); if ($stmt-&gt;fetch()) { echo '&lt;p&gt; Show ID: '.$show_id.' Show Name'. $show_name.'&lt;/p&gt;&lt;br&gt;'; } </code></pre> <p>and it is giving me a "Call to a member function prepare() on null " error</p> <p>i have a second php file that is called DBconnect.php which also seem to function correctly.</p> <pre><code>function get_mysqli_conn(){ $dbhost = "xxxxx"; $dbuser = "xxxxx"; $dbpassword = "xxxxx"; $dbname = "xxxxxx"; $conn = new mysqli($dbhost, $dbuser,$dbpassword,$dbname); if (!$conn){ die ('Failed to connec to MySQL : (' . $conn-&gt;connect_errno.')' . $conn -&gt;connect_error); }else{ echo 'connected'; } } </code></pre> </div>

PHP MYSQL 一模一样的句子,在SQL中能查到东西,PHP中查不出来

一模一样的句子,为啥在MYSQL中能查询出东西,放到PHP中就查不出来了 MYSQL查询用 ``` select *from chillerdate where 型号 = 'CSRAN-1502' ``` 查询结果没问题 然后我放到PHP中 ``` ini_set('display_errors','On'); $con = mysqli_connect('******); $result = $con->query("select * from chillerdate where 型号 = 'CSRAN-1502'"); if (!$result) { echo '没有查询结果'; } print_r(mysqli_fetch_array($result)); ``` 查询结果就是 没有查询结果 Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in /data/home/qxu2062240190/htdocs/getchillerdate.php on line 12


<div class="post-text" itemprop="text"> <p>Given the following code:</p> <pre class="lang-php prettyprint-override"><code>DB::table('users')-&gt;get(); </code></pre> <p>I want to get the raw SQL query string that the database query builder above will generate. In this example, it would be <code>SELECT * FROM users</code>.</p> <p>How do I do this?</p> </div>

用PHP导入excel数据到sql Server数据库,写一个循环的插入语句应该怎么写呢???

环境php7.0+IIS+SQL Server2014 请问我将excel表格中的数据放在一个数组,然后想要将这个数组的数导入到sql server数据库应该怎么写呢? 代码如下: ``` <?php $serverName = "localhost"; //serverName\instanceName $uid = "sa"; $pwd = "987654"; $connectionInfo = array( "UID"=>$uid,"PWD"=>$pwd,"Database"=>"Analysis"); $conn = sqlsrv_connect($serverName, $connectionInfo); if($conn==false) { echo "Error!"; die(print_r(sqlsrv_errors(),true)); } else{ echo "Sucess!"; echo "<br />"; } error_reporting(E_ALL); date_default_timezone_set('Asia/ShangHai'); require_once 'phpexcel-1.8/Classes/PHPExcel.php'; require_once 'PHPExcel-1.8/Classes/PHPExcel/IOFactory.php'; require_once 'phpexcel-1.8/Classes/PHPExcel/Reader/Excel5.php'; if(!file_exists("data/大分结构.xls")) { exit("not found 31excel5.xls."); } $reader = PHPExcel_IOFactory::createReader('Excel5'); //设置以Excel5格式(Excel97-2003工作簿) $PHPExcel = $reader->load("data/大分结构.xls"); // 载入excel文件 //$reader->setOutputEncoding('utf-8'); $sheet = $PHPExcel->getSheet(0); // 读取第一個工作表 $highestRow = $sheet->getHighestRow(); // 取得总行数 $highestColumm = $sheet->getHighestColumn(); // 取得总列数 /*循环读取每个单元格的数据 */ for ($row = 2; $row <= $highestRow; $row++){//行数是以第1行开始 for ($column = 'A'; $column <= $highestColumm; $column++) { $dataset[]= $sheet->getCell($column.$row)->getValue(); //$sql = "insert into BInfo (BQId,CID,TId,BType,BScore)values('一','00903','00903A','操作题','36')";(只插入一条语句是可以成功的,但是用循环语句就不行了) //$sql="insert into BInfo (BQId,CID,TId,BType,BScore) values ('{$dataset[0]}','{$dataset[1]}','{$dataset[2]}','{$dataset[3]}','{$dataset[4]}')";//这个语句应该怎么写呢?求帮忙! $query = sqlsrv_query($conn,$sql); echo $column.$row.":".$sheet->getCell($column.$row)->getValue(); } echo "<br />"; } ?> ```

如何按限制降序排序? PHP / SQL

<div class="post-text" itemprop="text"> <p>Im sure this is a simple solution for you guys, but im trying to just simply select a table, and order by values called "points". I am only trying to produce the first 5 rows. Here is what I have so far, and its not producing any results. </p> <pre><code>$invcheckquery = "SELECT name , points FROM guild ORDER BY points DESC LIMIT 5"; $invcheck = mysqli_query($con, $invcheckquery) or die("error code : invite already sent!"); echo "0"; while ($row = mysqli_fetch_array($invcheck)) { echo ("\t"); echo ($row ['name']); // The number echo ("\t"); // The number echo ($row ['points']); } </code></pre> </div>


<div class="post-text" itemprop="text"> <p>I have a "set password" site where you can set your password only if you do not currently possess one. I therefore have a SQL query that selects the username and password we will work with only if the email matches the one in the database AND the password is NULL. If this one returns false, the PHP-script should not do anything other than echo "Password or username is not valid". It also does other things, like check the length of the password and if it was confirmed, but this is the one which is messing up. Any thoughts?</p> <p>This is my PHP-code so far:</p> <pre><code>&lt;?php session_start(); require ''; include 'core.php'; ob_start(); ?&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt; &lt;?php echo " &lt;form action='update.php' method='post'&gt; Ange din E-post.&lt;br&gt; E-post: &lt;input type='text' name='mail' /&gt;&lt;br&gt; Ange ditt lösenord, minst sex tecken.&lt;br&gt; Lösenord: &lt;input type='password' name='pass1' /&gt;&lt;br&gt; Bekräfta: &lt;input type='password' name='pass2' /&gt;&lt;br&gt; &lt;input type='submit' value='Godkänn'/&gt;&lt;br&gt;"; if(isset($_POST['pass1'])&amp;&amp;isset($_POST['pass2'])) { $email = $_POST['mail']; $query = "SELECT login_id, pass FROM users WHERE (email = '$email') AND (pass IS NULL)"; $query_run = sqlsrv_query( $link, $query); if(($_POST['pass1'] == $_POST['pass2']) &amp;&amp; !empty($_POST['pass2']) &amp;&amp; $query_run &amp;&amp; (strlen($_POST['pass2'])&gt;5)) { $row = sqlsrv_fetch_array($query_run, SQLSRV_FETCH_ASSOC); $id = $row['login_id']; $_SESSION['id'] = $id; $pass = $_POST['pass1']; $query2 = "UPDATE users SET pass = '$pass' WHERE login_id = '$id'"; sqlsrv_query( $link, $query2); $next = "https://localhost/title_choice.php"; header('Location: '.$next); }else { echo "Lösenorden matchar ej, eller E-post ogiltig! Var god ange dem igen!"; } } ob_end_flush(); ?&gt; </code></pre> </div>


<div class="post-text" itemprop="text"> <p>This is my sql statement</p> <pre><code>SELECT TOWN_ID FROM TOWN WHERE CITY_ID = 1 </code></pre> <p>output are : 4,5,6,7,67,887</p> <p>In php my code is like this :</p> <pre><code>$temp = 1; $sql = "SELECT TOWN_ID FROM TOWN WHERE CITY_ID = 1 = $temp"; $compiled = oci_parse($conn, $sql); oci_execute($compiled); $row = oci_fetch_array($compiled, OCI_ASSOC+OCI_RETURN_LOBS); foreach ($row as $element ) { echo " ".$element." "; } </code></pre> <p>My output is just 4 , how to get other outputs?</p> </div>


假如我的页面是这样,很简单 <body> <?php require_once '../config.php'; require_once '../class/DB.class.php'; $db = new DB(HOST, UNAME, UPWD, DBNAME, "utf-8"); /*********************取出数据库的前40条记录 **************************/ $sql = "select * from sendmes order by _second desc limit 0,40"; $result = $db->fetchAll($sql); foreach ($result as $val){ echo $val["_name"].$val["_mood"]."对".$val["_target"]."说道: <font color=".$val["_color"].">".$val["_content"]."</font>"."<br/>"; } ?> </body> 目前我是这样来刷新的: <meta http-equiv="refresh" content="3"; url="mesContent.php"> 怎么用ajax实现页面不刷新页面,显示最近记录

mysql 中sql 可以查到数据 php返回结果集为空

我的在PHP 写的sql 返回的数组没有数据 但是打印出的 sql 在mysql中可以查到数据


//require_once( "./alipay/config.php" );前面引用过了,所以这里不引用了 $sql = "INSERT INTO `ku_civilvn`( `geturl`, `title`, `IsVip`, `coin`, `money`) VALUES ('$url','$pagetitle',$isvip,$pageprice,$pagewebprice)"; echo( $sql ); //输出显示$sql是INSERT INTO `ku_civilvn`( `geturl`, `title`, `IsVip`, `coin`, `money`) VALUES ('','结构',1,10,5) 该语句直接在phpmyadmin和phpfront里执行都木有问题,都可以增加一条记录。但是php就是不行。但是我用php直接给 $sql赋值为INSERT INTO `ku_civilvn`( `geturl`, `title`, `IsVip`, `coin`, `money`) VALUES ('','结构',1,10,5) 执行却能成功,请大神告知为什么​ //$res = mysql_query( $sql, $linksql ); $res = mysqli_query($linksql,$sql); echo( mysqli_errno($linksql) );//输出显示是0,所以是没错的 mysqli_free_result( $res );


<div class="post-text" itemprop="text"> <p>In my code, I have to select the start date and end date for the SQL query to run. I have to obtain the start and end date from a date picker for the value to be display. Below is my code: Any ideas.?</p> <pre><code>include 'DBController.php'; $db_handle = new DBController(); $start_date = $_GET['start_date']; $end_date = $_GET['end_date']; $productResult = $db_handle-&gt;runQuery("SELECT outlets.outletname,outlets.barcode,invoiceissued.invoiceno,invoiceissued.total_amount,invoiceissued.VATAmount,invoiceissued.date_created,outlets.businessregistrationno,outlets.vat FROM `invoiceissued` , outlets WHERE invoiceissued.outletid = outlets.outletsid and `date_created` BETWEEN ('".$start_date."') AND ('".$end_date."')"); &lt;body&gt; Start date : &lt;input type="date" id="start_date" name="start_date"/&gt; End date : &lt;input type="date" id="end_date" name="end_date" /&gt; &lt;/body&gt; </code></pre> </div>


用ajax发送post数据给php页面处理,php页面上用pdo对数据库更新。 php页面中使用如下语句判断exec是否执行成功。 if($pdo->exec($sql))return 1; else return 0; 很奇怪,只要提交的数据没有变化(即相同SQL代码),就会返回0,随便修改数据再提交就可以返回1。 我把sql代码拿出来在phpMyAdmin里多次直接执行,每次都会成功并提示“影响1行”,这说明mysql里没变总是会执行吧。 上网查资料后知道exec返回的是影响的行数,我不知道是不是因为这个。 请问:PDO下相同代码执行第二遍,exec是否就会返回0?如何判断exec返回0是因为数据库不需要更新,而不是出错呢?


<div class="post-text" itemprop="text"> <p>I have a little problem in my code, please review it and help me. I want to assign value of the span tag(fetched by id in html) to a php variable and then run a sql query to fetch record of the related value in the table. Here is my code.</p> <p>I tried it in different ways but it not works. I print the sql query and its absolutely right but does not show the correct result. I copied that printed sql query and paste it into phpmyadmin query section and run it there. Then it works fine and show related records. Please help</p> <pre><code>$regg = '&lt;span id="modal-myvalue"&gt;&lt;/span&gt;'; $fee_detail = "SELECT * FROM `fee_enroll` WHERE registeration = '$regg' AND mode = 'ENABLE'"; //here i print the query and its output is correct but doesn't show the correct record here. echo $fee_detail; $result_fee = mysqli_query($con, $fee_detail); while($row_fee = mysqli_fetch_assoc($result_fee)) { echo $row_fee['registeration']; } </code></pre> <p>The data which i want to fetch in span tag(in id) is sent from a button through this script:</p> <pre><code>&lt;script type="text/javascript"&gt; var ATTRIBUTES = ['myvalue']; $('[data-toggle="modal"]').on('click', function(e) { var $target = $(; var modalSelector = $'target'); ATTRIBUTES.forEach(function(attributeName) { var $modalAttribute = $(modalSelector + ' #modal-' + attributeName); var dataValue = $; $modalAttribute.text(dataValue || ''); }); }); &lt;/script&gt; </code></pre> <p>and the button code is</p> <pre><code>&lt;a class="btn" type=submit data-toggle="modal" data-target="#model-view" data-myvalue="&lt;?php echo $row['registeration']; ?&gt;"&gt;VIEW Detail&lt;/a&gt; </code></pre> <p>When i print the query it shows:</p> <pre><code>(SELECT * FROM `fee_enroll` WHERE registeration = 'FA12-BSE-094' AND mode = 'ENABLE') </code></pre> <p>which works correctly in phpmyadmin query section. but not works here when i want to execute.</p> </div>


今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...


跳槽几乎是每个人职业生涯的一部分,很多HR说“三年两跳”已经是一个跳槽频繁与否的阈值了,可为什么市面上有很多程序员不到一年就跳槽呢?他们不担心影响履历吗? PayScale之前发布的**《员工最短任期公司排行榜》中,两家码农大厂Amazon和Google**,以1年和1.1年的员工任期中位数分列第二、第四名。 PayScale:员工最短任期公司排行榜 意外的是,任期中位数极小的这两家公司,薪资...




一、前言 照着大学的SQL server来学

技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...


华为面试整体流程大致分为笔试,性格测试,面试,综合面试,回学校等结果。笔试来说,华为的难度较中等,选择题难度和网易腾讯差不多。最后的代码题,相比下来就简单很多,一共3道题目,前2题很容易就AC,题目已经记不太清楚,不过难度确实不大。最后一题最后提交的代码过了75%的样例,一直没有发现剩下的25%可能存在什么坑。 笔试部分太久远,我就不怎么回忆了。直接将面试。 面试 如果说腾讯的面试是挥金如土...

和黑客斗争的 6 天!

互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找 Sql 注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都...


loonggg读完需要3分钟速读仅需 1 分钟大家好,我是你们的校长。我之前讲过,这年头,只要肯动脑,肯行动,程序员凭借自己的技术,赚钱的方式还是有很多种的。仅仅靠在公司出卖自己的劳动时...



总结了 150 余个神奇网站,你不来瞅瞅吗?



提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...






私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...



离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...




虽然大公司并不是人人都能进,但我仍建议还未毕业的同学,尽力地通过校招向大公司挤,但凡挤进去,你这一生会容易很多。 大公司哪里好?没能进大公司怎么办?答案都在这里了,记得帮我点赞哦。 目录: 技术氛围 内部晋升与跳槽 啥也没学会,公司倒闭了? 不同的人脉圈,注定会有不同的结果 没能去大厂怎么办? 一、技术氛围 纵观整个程序员技术领域,哪个在行业有所名气的大牛,不是在大厂? 而且众所...


本文作者用对比非常鲜明的两个开发团队的故事,讲解了敏捷开发之道 —— 如果你的团队缺乏统一标准的环境,那么即使勤劳努力,不仅会极其耗时而且成果甚微,使用...




当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...






编程语言层出不穷,从最初的机器语言到如今2500种以上的高级语言,程序员们大呼“学到头秃”。程序员一边面临编程语言不断推陈出新,一边面临由于许多代码已存在,程序员编写新应用程序时存在重复“搬砖”的现象。 无代码/低代码编程应运而生。无代码/低代码是一种创建应用的方法,它可以让开发者使用最少的编码知识来快速开发应用程序。开发者通过图形界面中,可视化建模来组装和配置应用程序。这样一来,开发者直...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?





已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...


每一个C程序都必须有一main()函数, 可以根据自己的爱好把它放在程序的某个地方。有些程序员把它放在最前面, 而另一些程序员把它放在最后面, 无论放在哪个地方, 以下几点说明都是适合的。


前几天我们公司做了一件蠢事,非常非常愚蠢的事情。我原以为从学校出来之后,除了找工作有测试外,不会有任何与考试有关的事儿。 但是,天有不测风云,公司技术总监、人事总监两位大佬突然降临到我们事业线,叫上我老大,给我们组织了一场别开生面的“考试”。 那是一个风和日丽的下午,我翘着二郎腿,左手端着一杯卡布奇诺,右手抓着我的罗技鼠标,滚动着轮轴,穿梭在头条热点之间。 “淡黄的长裙~蓬松的头发...


导读 前天面试了一个985高校的实习生,问了他平时用什么开发工具,他想也没想的说IDEA,于是我抛砖引玉的问了一下IDEA的调试用过吧,你说说怎么设置断点...