mysql_query()执行select语句,无论能否查询到结果,好像返回值是一样的

mysql_query()执行select语句,无论能否查询到结果,好像返回值是一样的。如果这样的话,我怎样才能知道有没有查询到结果呢?

3个回答

返回值不是一样的。没有结果就是“”,,,,,写方法判断结果集长度等于0返回NULL

应该返回结果不一样的,跟楼上说的一样

如果mysql_query()执行失败会返回false,可以写成 if(my_sql(...)) ... else ...

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
mysql_query查询语句插入不到数据库问题

<?php $conn=@mysql_connect("localhost","root","") or die ("链接错误"); mysql_select_db("newdb",$conn); $sql="INSERT INTO test(`id`,`uid`,`regdate`,`remark`) values(NULL,'php10000',now(),'工人')"; @mysql_query($sql,$conn) or die("链接错误"); ?> 请问,为啥php运行时错误,错在哪?

mysql_query返回错误的结果

<div class="post-text" itemprop="text"> <p>Consider the following code</p> <pre><code>if ( isset( $_SESSION['FBID'] ) ) { $uid = $_SESSION['FBID']; $sql = "SELECT *, count(member_nr) AS notifyMe FROM poolWinners WHERE member_nr = '$uid' AND notification ='1'"; $result = mysql_query($sql); while($row=mysql_fetch_array($result)){ $notification = $row['notifyMe']; }//while if ( $notification &gt; 0 ) { echo '&lt;span class="badge"&gt;' . $notification . '&lt;/span&gt;'; } //if var_dump($notification); } //isset( $_SESSION['FBID'] ) </code></pre> <p>The above script returns how many notifications a member has as you can see in image below <img src="https://i.stack.imgur.com/ZWFu6.png" alt="enter image description here"></p> <p><strong>My Problem</strong></p> <p>The script is returning the wrong result (wrong number of notifications). Have a look at the table below, the member number appears 3 times in the table so: <code>$notification = $row['notifyMe']</code> Should = 3 AND NOT 1</p> <p>What am I missing or doing wrong here? Thanks for reading</p> </div>

php,mysql_query()语句,提示内存溢出

php后台接口,将两个表进行联合查询,使用union语句,在phpmyadmin中执行没有问题, 但是用postman进行测试时,提示内存溢出,有没有不使用ini_set的方法,解决这个问题,我试着unset了 几个变量,还是不行 $recommend = 1; ``` $check_status = 2; $art_act_reslut = mysql_query( "SELECT * FROM ( SELECT publish_time, article_id as id, user_id as user_brand_id, article_text as text, article_thumbs as thumds_person_num, sort_weight, '' as title, article_comment_number as article_comment_number FROM article WHERE recommend = '$recommend' and check_status = '$check_status' and publish_time > '$timestamp' UNION SELECT publish_time, activity_id as id, brand_id as user_beand_id, activity_content as text, join_persons as thumds_person_num, sort_weight, activity_title as title, '' as article_comment_number FROM activity WHERE recommend = '$recommend' and check_status = '$check_status' and publish_time > '$timestamp') stain ORDER BY stain.publish_time DESC, stain.sort_weight DESC"); unset($recommend); unset($check_status); //赋值到cards for($i=0;$i<20;$i++) { $cards_arr = array(); $art_act_reslut_value = mysql_fetch_assoc($art_act_reslut); //给相应的参数赋值 $id = $art_act_reslut_value["id"]; $user_brand_id = $art_act_reslut_value["user_brand_id"]; $text = $art_act_reslut_value["text"]; $thumds_person_num = $art_act_reslut_value["thumds_person_num"]; $article_comment_nummber = $art_act_reslut_value["article_comment_number"]; $publish_time = $art_act_reslut_value["publish_time"]; $title = $art_act_reslut_value["title"]; $sort_weight = $art_act_reslut_value["sort_weight"]; unset($art_act_reslut_value); ``` 这是错误信息 Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20 bytes) in /home/fgang/local/apache/htdocs/bimu/interface/get_home_recommand.php on line 102 ![phpmyadmin运行正常](https://img-ask.csdn.net/upload/201604/17/1460894569_910309.png)

mysqli_query仅在有WHERE语句时返回结果

<div class="post-text" itemprop="text"> <p>MySQL query is only showing information if I have a condition in the SQL statement.</p> <p>I've successfully used the SQL statement in phpmyadmin and it works great. I've changed the table name in the PHP code and it functions properly, the "people" table is the only one that causes a problem. </p> <pre><code>&lt;?php include 'dbconnectLocal.php'; $sql = "SELECT * FROM people WHERE nameFirst = 'Karen'"; $billings = array(); $billingResults = mysqli_query($connL, $sql); while($row = mysqli_fetch_assoc($billingResults)){ $billings[] = $row; } mysqli_close($connL); $jsonOutput = json_encode($billings); print("&lt;pre&gt;".json_encode($billings, JSON_PRETTY_PRINT)."&lt;/pre&gt;"); ?&gt; </code></pre> <p>The above code produces the desired result, it gives me a JSON result of everyone whos name is Karen. But if I were to change it to $sql = "SELECT * FROM people" I get a blank screen.</p> </div>

mysqli_query返回错误

<div class="post-text" itemprop="text"> <p>Hi I'm very new to php and my query to my mysql database is returning an error. My connection is fine, but there's something wrong with my query. I've run it through php validators but they can't find any errors. Any help would be appreciated. Thanks in advance. Here's my code.</p> <pre><code>&lt;?php $dbc=mysqli_connect('url','username','password') or die('error connecting'); $query = "INSERT INTO mailing_list (first_name, last_name, email_address)" . "VALUES ('one','two','three')"; $answer = mysqli_query($dbc,$query) or die('error querying'); mysqli_close($dbc); ?&gt; </code></pre> </div>

linux c语言mysql编程 select 或 insert 到结构体中

linux c语言mysql编程时,mysql_store_result(&gmysql_main)是select结果集存,sqlrow = mysql_fetch_row(res_ptr))就取出了这一行数据,C语言编程时,如何将这一行数据赋值到一个对应表结构的结构体中(这个表结构有int型和char型数据),同理,如何将一个对应表结构的结构体数据insert到数据库中。在下需要示例代码,还请各位大神指教!

从PHP执行时,MySQL SELECT语句不起作用

<div class="post-text" itemprop="text"> <p>I have the following piece of code, executing a pretty simple MySQL query:</p> <pre><code>$netnestquery = 'SELECT (`nested`+1) AS `nest` FROM `ipspace6` WHERE `id`&lt;='.$adaddr.' AND `subnet`&lt;='.$postmask.' AND `type`="net" AND `addr` NOT IN(SELECT `id` FROM `ipspace6` WHERE `addr`&lt;'.$adaddr.' AND `type`="broadcast") ORDER BY `id`,`subnet` DESC LIMIT 1'; $netnestresults = mysql_query($netnestquery); $netnestrow = mysql_fetch_array($netnestresults); $nestlvl = $netnestrow['nest']; echo '&lt;br&gt; NESTQ: '.$netnestquery; </code></pre> <p>Now, when I execute this in PHP, I get no results; an empty query. However, when I copy and paste the query echoed by my code (for debug purposes) into the mysql command line, I get a valid result:</p> <pre><code>mysql&gt; SELECT (`nested` + 1) AS `nest` FROM `ipspace6` WHERE `id`&lt;=50552019054038629283648959286463168512 AND `subnet`&lt;=36 AND `type`='net' AND `addr` NOT IN (SELECT `id` FROM `ipspace6` WHERE `addr`&lt;50552019054038629283648959286463168512 AND `type`='broadcast') ORDER BY `id`,`subnet` DESC LIMIT 1; +------+ | nest | +------+ | 1 | +------+ 1 row in set (0.00 sec) </code></pre> <p>Can anybody tell me what I'm doing wrong? I can't put quotes around my variables, as then MySQL will try to evaluate the variable as a string, when it is, in fact, a very large decimal. I think I might just be making a stupid mistake somewhere, but I can't tell where.</p> </div>

从select count MySQL语句中获取行数

<div class="post-text" itemprop="text"> <pre><code>$How_Many_Manufacturers = "SELECT COUNT(manufacturer), manufacturer FROM products WHERE name LIKE '%$new_title%' GROUP BY manufacturer"; $result2 = mysql_query($How_Many_Manufacturers, $connection) or die(mysql_error()); $num_rows = mysql_num_rows($result2); if ($num_rows == 0) { echo "&lt;div id=\"noMatches\"&gt;No Matches&lt;/div&gt;"; } else { } </code></pre> <p>The if statement will not work. How can I correct this script?</p> </div>

如何在两个select语句中使用mysql_fetch_assoc,这个语句在OR运算符中给出,以选择表格表格

<div class="post-text" itemprop="text"> <p>How to <code>mysql_fetch_assoc</code> array for either of <code>select</code> statement if either one is selected and display them ?</p> <pre><code>$query1= "SELECT name, email_id,mobile_number from tablename where `user_id='$id'"` OR "SELECT guser_name, guser_email from tablename1 where user_id='$id'"; if($q=mysql_query($query1)) { $row = mysql_fetch_assoc($q); $name = $row['guser_name']; $name1 = $row1['name']; $mail1 = $row1['email_id']; $mail= $row['guser_email'] ; $phone = $row1['mobile_number'] </code></pre> </div>

遇到mysqli_query问题,返回NULL但查询在phpmyadmin中有效

<div class="post-text" itemprop="text"> <p>I'm tring to retrive information from a database while a user send Login command from iOS app. To test this function i'm launching my php page manually (ex. <a href="http://www.testdatabase.com/LoginFunctions.php" rel="nofollow noreferrer">http://www.testdatabase.com/LoginFunctions.php</a>) and forcing username programmatically.</p> <p>The problem is that mysqli_query return NULL value. if i use "or die(mysql_error()" nothing happens. Even if i use mysqli_num_rows return 1, but $result is still empty. So when mysql_fetch_assoc is been executed the programm crashes without showing any error. Any idea? Thanks</p> <pre><code>&lt;?php // Create connection $con=mysqli_connect("localhost","super","super","testdb"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $action = "login"; $username = "Peperoncino"; $response = array(); if ($action == "login") { $query = "SELECT psw AS pswrd,id FROM Activities WHERE nome = 'Peperoncino' LIMIT 1"; if ($result = mysqli_query($con, $query)) { $values = mysql_fetch_assoc($result); $password = $values['pswrd']; $response["password"] = $password; $response["message"] = "Get information from db"; } else { echo "err"; } echo json_encode($response); } // Close connections mysqli_close($con); ?&gt; </code></pre> </div>

Mysqli_query返回false而Mysqli_error返回NULL?

<div class="post-text" itemprop="text"> <p>I've been creating a booking system, and creating appointments, but my SQL statement is not working. I've been trying to find a solution but to no avail.</p> <p>Listed below is my php code. My first SQL statement works perfectly and returns the correct ClientID, however, the second SQL statement does not insert it all into the database. I have done var_dumps on result, returning bool(false), as well as mysqli_error on the result, returning null. My error message at the end only displays the echo'd message, and not the mysqli_error or error number also.</p> <p>(Note: some values are changed/removed to protect data)</p> <pre><code>&lt;?php session_start(); if(! $_SESSION['Username']) { header("location:Index.php"); } $servername = "localhost"; $username = "root"; $password = ""; $dbname = ""; $tablename = "appointmentinformation"; $tablenamed = "clientinformation"; $connection = mysqli_connect("$servername", "$username", "$password", "$dbname") or die("Could not connect to the database"); $clientusername = $_SESSION['Username']; $sql = "SELECT ClientID FROM $tablenamed WHERE Username = '$clientusername' LIMIT 1"; $results = mysqli_query($connection, $sql); if (! $results) { echo ("Could not select the data : " . mysql_error()); } else { $datarows = mysqli_fetch_row($results); $clientid = $datarows[0]; } $date = $_POST["Date"]; $month = $_POST["Month"]; $year = $_POST["Year"]; $time = $_POST["Time"]; $length = $_POST["Length"]; $date = stripslashes($date); $month = stripslashes($month); $year = stripslashes($year); $time = stripslashes($time); $length = stripslashes($length); $date = mysqli_real_escape_string($date); $month = mysqli_real_escape_string($month); $year = mysqli_real_escape_string($year); $time = mysqli_real_escape_string($time); $length = mysqli_real_escape_string($length); $query = "INSERT INTO appointmentinformation (ClientID, Length, Date, Month, Year, Time, Price) VALUES ('$clientid', '$length', '$date', '$month', '$year', '$time', '$price')"; $result = mysqli_query($connection, $query); if ($result) { header("Location:UserCP.php"); } else { echo ("Could not insert data : " . mysqli_error($result) . " " . mysqli_errno()); } ?&gt; </code></pre> </div>

PHP中mysql_num_rows问题

![图片说明](https://img-ask.csdn.net/upload/201512/15/1450142500_363690.png) ``` <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>注册</title> </head> <?php if(isset($_POST["Submit"]) && $_POST["Submit"] == "注册") { $user = $_POST["username"]; $psw = $_POST["password"]; $psw_confirm = $_POST["confirm"]; if($user == "" || $psw == "" || $psw_confirm == "") { echo "<script>alert('请确认信息完整性!'); history.go(-1);</script>"; } else { if($psw == $psw_confirm) { mysql_connect("localhost","root",""); //连接数据库 mysql_select_db("用户表"); //选择数据库 mysql_query("set names 'gdk'"); //设定字符集 $sql = "select username from user where username = '$_POST[username]'"; //SQL语句 $result = mysql_query($sql); //执行SQL语句 $num = mysql_num_rows($result); ``` ![图片说明](https://img-ask.csdn.net/upload/201512/15/1450142575_981627.png) ``` <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>登陆</title> </head> <?php if(isset($_POST["submit"]) && $_POST["submit"] == "登陆") { $user = $_POST["username"]; $psw = $_POST["password"]; if($user == "" || $psw == "") { echo "<script>alert('请输入用户名或密码!'); history.go(-1);</script>"; } else { mysql_connect("localhost","root",""); mysql_select_db("用户表"); mysql_query("set names 'gbk'"); $sql = "select username,password from user where username = '$_POST[username]' and password = '$_POST[password]'"; $result = mysql_query($sql); $num = mysql_num_rows($result); ```

使用select语句的MySQL语法错误

<div class="post-text" itemprop="text"> <p>Hi can you please help me in this, I don't know where my error is. here is my code:</p> <pre><code> $capacitance =@mysql_query ("SELECT DISTINCT wwpn, SUBSTR(val, 1, LENGTH(val) / 2) as capacitor, SUBSTR(val, LENGTH(val) / 2+1) as capasitance FROM bom_csv where boardnumber ='$board' and qty&lt;&gt;'' and qty !='qty'"); @mysql_query($capacitance,$connect)or die("Failed to execute query:&lt;br /&gt;" . mysql_error(). "&lt;br /&gt;" . mysql_errno()); while($row = mysql_fetch_array($capacitance)) { $capacitor = $row['capacitor']; $capacitance =$row['capasitance']; $adi_pn = $row['wwpn']; } </code></pre> <p>and the error while I am executing it by php: </p> <pre><code>Failed to execute query: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Resource id #4' at line 1 1064 </code></pre> </div>

sql语句在phpMyAdmin中工作,但在mysql_query中不起作用

<div class="post-text" itemprop="text"> <p>Really stuck on something. I'm trying to update a database and the code looks write - and if I echo it out and paste it directly into phpMyAdmin it works perfectly - but the code itself doesn't work... I have spend a day so far trying to figure out why it's not working and I'm completely out of ideas... </p> <pre><code>function restoreSession() { mysql_connect("theHost", "root", "rootPWD") or die(mysql_error()); mysql_select_db("myDatabase") or die(mysql_error()); $restore_cmd = 'UPDATE wp_dor_cart66_sessions SET user_data = (SELECT user_data FROM wp_dor_cart66_stored_sessions WHERE ip_address = "' . $_SERVER['REMOTE_ADDR'] . '")'; $clean_up = "DELETE FROM `wp_dor_cart66_sessions` WHERE `ip_address` = \"" . $_SERVER['REMOTE_ADDR'] . "\" AND id NOT IN (SELECT id FROM ( SELECT id FROM `wp_dor_cart66_sessions` ORDER BY id DESC LIMIT 1 ) user_data )"; mysql_query($clean_up) or die('Query failed: ' . mysql_error()); $result = mysql_query($restore_cmd) or die('Query failed: ' . mysql_error()); echo "&lt;br/&gt;"; echo $restore_cmd; echo "&lt;br/&gt;"; var_dump($result); echo "&lt;br/&gt;"; print_r($result); } </code></pre> <p>The resulting output looks like:</p> <pre><code>UPDATE wp_dor_cart66_sessions SET user_data = (SELECT user_data FROM wp_dor_cart66_stored_sessions WHERE ip_address = "196.54.110.24"); bool(true) 1 </code></pre> <p>It doesn't appear to have any errors - but I just can't get it to update. If it didn't work in phpMyAdmin - I'd know there was something wrong with the SQL - but it seems right... I'm just really out of ideas - any help would be greatly appreciated!</p> <hr> <p>Here are the statements again with some formatting:</p> <pre><code>$restore_cmd = ' UPDATE wp_dor_cart66_sessions SET user_data = ( SELECT user_data FROM wp_dor_cart66_stored_sessions WHERE ip_address = "' . $_SERVER['REMOTE_ADDR'] . '" ) '; $clean_up = " DELETE FROM `wp_dor_cart66_sessions` WHERE `ip_address` = \"" . $_SERVER['REMOTE_ADDR'] . "\" AND id NOT IN ( SELECT id FROM ( SELECT id FROM `wp_dor_cart66_sessions` ORDER BY id DESC LIMIT 1 ) user_data ) "; </code></pre> </div>

仅来自Zend_DB Select语句(子查询)的COUNT(*)

<div class="post-text" itemprop="text"> <p>I'm trying to wrap a count(*) query around an existing Zend_Db select statement, but all I was able to get is:</p> <pre><code>SELECT `t`.*, COUNT(*) AS `TotalRecords` FROM (SELECT ....) AS `t` </code></pre> <p>However I like to get rid of the t.* as I only need the count(*).</p> <p>This is my code so far:</p> <pre><code>$db = Zend_Registry::get('db'); $select = $dbmodel-&gt;getSomething(); //zend select object $outterSelect = new Zend_Db_Select($db); $outterSelect-&gt;from($select)-&gt;columns(array('TotalRecords' =&gt; new Zend_Db_Expr('COUNT(*)'))); echo $outterSelect-&gt;__toString(); </code></pre> <p>Any help is appreciated!</p> </div>

MySql 查询语句中包含中文时不能查询结果 编码问题!

最近在做mysql查询时,发现一个很郁闷的问题:sql水土不服! 在公司内部做的mysql 查询,包含中文毫无问题。(mysql服务安装在公司,所用数据库编码设置成gbk,mysql安装设置编码为utf-8),项目运行一切OK。 但是 当把项目部署到客户的指定的服务器(可能是虚拟机)上 安装mysql服务 运行环境等,一切搞定后,发现只要有中文的查不出来数据。 没别的,肯定是编码问题,去修改安装配置文件,但是安装的是 mysql-5.1.53-win32, 结果目录下找不到my.ini 文件,找了一些ini 文件每一个包含default-character-set 属性设置这一项。 郁闷中,惆怅中,向各位同仁讨教,感激不尽。

SELECT * FROM给出其他结果然后SELECT 2010,2011 FROM

<div class="post-text" itemprop="text"> <p>when i try to get the values from some columns and use SELECT 2010,2011 FROM blablatable then i get only the table names(checked in a browser). When i use SELECT * FROM blablatable then i get (of course everything) but then the content of the year colums are displayed correct(checked in a browser). Now other columns in the same table are displayed correct, i use this php script to get the data into a datagrid in Livecode. Everything works OK except for the year columns. Then the datagrid is giving an error. I do not understand why it is giving the tables instead of giving the data. I allready use the same adjusted script in Livecode and that works ok. So tested some thing and either it is the php script or it is the database giving the trouble.</p> <p>These are parts of the 2 php testscripts i use: _______First the script that only gives the table names__notgood___</p> <pre><code>$hostname_connLivecode = "localhost"; $database_connLivecode = "blabla"; $username_connLivecode = "blabla"; $password_connLivecode = "blabla"; $connLivecode = mysql_pconnect($hostname_connLivecode, $username_connLivecode, $password_connLivecode) or trigger_error(mysql_error(),E_USER_ERROR); //2. Perform database query mysql_select_db($database_connLivecode, $connLivecode); $query_rsUser = ("SELECT 2010,2011 FROM blabla_table ORDER BY id"); $rsUser = mysql_query($query_rsUser, $connLivecode) or die(mysql_error()); $row_rsUser = mysql_fetch_assoc($rsUser); $totalRows_rsUser = mysql_num_rows($rsUser); if ($totalRows_rsUser == 0) { echo "no data found"; } do { echo $row_rsUser["id"]."\t".$row_rsUser["2010"]."\t".$row_rsUser["2011"]." "; } while ($row_rsUser = mysql_fetch_assoc($rsUser)); ?&gt; </code></pre> <hr> <p>____________Now the script that gives the correct info_____</p> <pre><code>$hostname_connLivecode = "localhost"; $database_connLivecode = "blabla"; $username_connLivecode = "blabla"; $password_connLivecode = "blabla"; $connLivecode = mysql_pconnect($hostname_connLivecode, $username_connLivecode, $password_connLivecode) or trigger_error(mysql_error(),E_USER_ERROR); //2. Perform database query mysql_select_db($database_connLivecode, $connLivecode); $query_rsUser = ("SELECT * FROM blabla_table ORDER BY id"); $rsUser = mysql_query($query_rsUser, $connLivecode) or die(mysql_error()); $row_rsUser = mysql_fetch_assoc($rsUser); $totalRows_rsUser = mysql_num_rows($rsUser); if ($totalRows_rsUser == 0) { echo "no data found"; } do { echo $row_rsUser["id"]."\t".$row_rsUser["2010"]."\t".$row_rsUser["2011"]." "; } while ($row_rsUser = mysql_fetch_assoc($rsUser)); ?&gt; </code></pre> <hr> <p>Does anyone understand why SELECT * works ok? I cannot use this, i have to use the column names.</p> <p>Any help will be appreciated.</p> <p>Thanks.</p> </div>

mysqli_query()参数1错误但查询正确执行

<div class="post-text" itemprop="text"> <p>I am getting the PHP warning:</p> <blockquote> <p>mysqli_query() expects parameter 1 to be mysqli, null given</p> </blockquote> <p>Printed to my <code>error_log</code> file however the query is running fine and the results are executing correctly. I would just really like to understand why I'm getting the warning. code below</p> <pre><code>&lt;? //initialize file sets $link variable with mysqli_connect() and contains the $item variable require "php/initialize.php"; $tradeAmount = mysqli_query($link, "SELECT sum(amt) AS total FROM actfcast WHERE item=$item"); $tradeAmount_array = mysqli_fetch_array($tradeAmount); ?&gt; </code></pre> <p>I then loop through the <code>$tradeAmount_array</code> and echo it. It works fine and everything is printing correctly. Any idea why it would think <code>$link</code> is <code>null</code>.</p> <p>to the comment from Rizier123:</p> <pre><code>object(mysqli)#1 (19) { ["affected_rows"]=&gt; int(1) ["client_info"]=&gt; string(11) "5.5.38-35.2" ["client_version"]=&gt; int(50538) ["connect_errno"]=&gt; int(0) ["connect_error"]=&gt; NULL ["errno"]=&gt; int(0) ["error"]=&gt; string(0) "" ["error_list"]=&gt; array(0) { } ["field_count"]=&gt; int(1) ["host_info"]=&gt; string(25) "Localhost via UNIX socket" ["info"]=&gt; NULL ["insert_id"]=&gt; int(0) ["server_info"]=&gt; string(11) "5.5.40-36.1" ["server_version"]=&gt; int(50540) ["stat"]=&gt; string(152) "Uptime: 962856 Threads: 5 Questions: 252975480 Slow queries: 513 Opens: 319250 Flush tables: 1 Open tables: 20000 Queries per second avg: 262.734" ["sqlstate"]=&gt; string(5) "00000" ["protocol_version"]=&gt; int(10) ["thread_id"]=&gt; int(4660775) ["warning_count"]=&gt; int(0) } </code></pre> <p>From the <code>initialize.php</code> file:</p> <pre><code>$host="localhost"; $current_db="xxxxxx"; $current_dir="exp"; $dbuser="xxxxxxx"; $dbpw="xxxxxxx"; if (!(isset($_SESSION['user']) &amp;&amp; $_SESSION['user'] != '')){ $_SESSION['redirect'] = $_SERVER['REQUEST_URI']; header ("Location: http://www.xxxxx.com/".$current_dir."/signin.php"); } else{ $link = mysqli_connect($host, $dbuser, $dbpw, $current_db); //more stuff } </code></pre> </div>

2 while循环在php - mysql select语句中

<div class="post-text" itemprop="text"> <p>I have 2 tables in DB:</p> <p>clients (Show all clients data)</p> <p>clientsmany (admin could add many phone numbers for each client)</p> <p>I would like to print all the details about the clients in 1 html table and if any client has more than phone number, all the numbers are printed in the same cell of 'td'</p> <pre><code>&lt;?php $result = mysql_query("SELECT * FROM clients"); $result1 = mysql_query("SELECT clientsmany.phone, clients.ID FROM clients INNER JOIN clientsmany ON clients.ID=clientsmany.ClientID"); while($row = mysql_fetch_array($result)){ //Not read! while($row1 = mysql_fetch_array($result1)){ //Working correctly and show the list of 'phone' in $row1 for clientsmany.phone echo "&lt;center&gt;&lt;table border='1'&gt;"; echo "&lt;tr&gt;&lt;td&gt;".$row['ID']."&lt;/td&gt;&lt;td&gt;".$row['phone']."&lt;br&gt;".$row1['phone']."&lt;/td&gt;&lt;/tr&gt;"; echo "&lt;/table&gt;&lt;/center&gt;"; }} ?&gt; </code></pre> <p>Why the 1st while is not working??</p> <p>The 2nd while only works and print a correct data then it exit automatic!</p> </div>

在中国程序员是青春饭吗?

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

Java校招入职华为,半年后我跑路了

何来 我,一个双非本科弟弟,有幸在 19 届的秋招中得到前东家华为(以下简称 hw)的赏识,当时秋招签订就业协议,说是入了某 java bg,之后一系列组织架构调整原因等等让人无法理解的神操作,最终毕业前夕,被通知调往其他 bg 做嵌入式开发(纯 C 语言)。 由于已至于校招末尾,之前拿到的其他 offer 又无法再收回,一时感到无力回天,只得默默接受。 毕业后,直接入职开始了嵌入式苦旅,由于从未...

Java基础知识面试题(2020最新版)

文章目录Java概述何为编程什么是Javajdk1.5之后的三大版本JVM、JRE和JDK的关系什么是跨平台性?原理是什么Java语言有哪些特点什么是字节码?采用字节码的最大好处是什么什么是Java程序的主类?应用程序和小程序的主类有何不同?Java应用程序与小程序之间有那些差别?Java和C++的区别Oracle JDK 和 OpenJDK 的对比基础语法数据类型Java有哪些数据类型switc...

@程序员:GitHub这个项目快薅羊毛

今天下午在朋友圈看到很多人都在发github的羊毛,一时没明白是怎么回事。 后来上百度搜索了一下,原来真有这回事,毕竟资源主义的羊毛不少啊,1000刀刷爆了朋友圈!不知道你们的朋友圈有没有看到类似的消息。 这到底是啥情况? 微软开发者平台GitHub 的一个区块链项目 Handshake ,搞了一个招募新会员的活动,面向GitHub 上前 25万名开发者派送 4,246.99 HNS币,大约价...

再不跳槽,应届毕业生拿的都比我多了!

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

我以为我学懂了数据结构,直到看了这个导图才发现,我错了

数据结构与算法思维导图

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

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

华为初面+综合面试(Java技术面)附上面试题

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

和黑客斗争的 6 天!

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

讲一个程序员如何副业月赚三万的真实故事

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

win10暴力查看wifi密码

刚才邻居打了个电话说:喂小灰,你家wifi的密码是多少,我怎么连不上了。 我。。。 我也忘了哎,就找到了一个好办法,分享给大家: 第一种情况:已经连接上的wifi,怎么知道密码? 打开:控制面板\网络和 Internet\网络连接 然后右击wifi连接的无线网卡,选择状态 然后像下图一样: 第二种情况:前提是我不知道啊,但是我以前知道密码。 此时可以利用dos命令了 1、利用netsh wlan...

上班一个月,后悔当初着急入职的选择了

最近有个老铁,告诉我说,上班一个月,后悔当初着急入职现在公司了。他之前在美图做手机研发,今年美图那边今年也有一波组织优化调整,他是其中一个,在协商离职后,当时捉急找工作上班,因为有房贷供着,不能没有收入来源。所以匆忙选了一家公司,实际上是一个大型外包公司,主要派遣给其他手机厂商做外包项目。**当时承诺待遇还不错,所以就立马入职去上班了。但是后面入职后,发现薪酬待遇这块并不是HR所说那样,那个HR自...

女程序员,为什么比男程序员少???

昨天看到一档综艺节目,讨论了两个话题:(1)中国学生的数学成绩,平均下来看,会比国外好?为什么?(2)男生的数学成绩,平均下来看,会比女生好?为什么?同时,我又联想到了一个技术圈经常讨...

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

原博客再更新,可能就没了,之后将持续更新本篇博客。

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

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

MySQL数据库面试题(2020最新版)

文章目录数据库基础知识为什么要使用数据库什么是SQL?什么是MySQL?数据库三大范式是什么mysql有关权限的表都有哪几个MySQL的binlog有有几种录入格式?分别有什么区别?数据类型mysql有哪些数据类型引擎MySQL存储引擎MyISAM与InnoDB区别MyISAM索引与InnoDB索引的区别?InnoDB引擎的4大特性存储引擎选择索引什么是索引?索引有哪些优缺点?索引使用场景(重点)...

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

我入职阿里后,才知道原来简历这么写

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

程序员写出这样的代码,能不挨骂吗?

当你换槽填坑时,面对一个新的环境。能够快速熟练,上手实现业务需求是关键。但是,哪些因素会影响你快速上手呢?是原有代码写的不够好?还是注释写的不够好?昨夜...

!大部分程序员只会写3年代码

如果世界上都是这种不思进取的软件公司,那别说大部分程序员只会写 3 年代码,恐怕就没有程序员这种职业。

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

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

HTTP与HTTPS的区别

面试官问HTTP与HTTPS的区别,我这样回答让他竖起大拇指!

男生更看重女生的身材脸蛋,还是思想?

往往,我们看不进去大段大段的逻辑。深刻的哲理,往往短而精悍,一阵见血。问:产品经理挺漂亮的,有点心动,但不知道合不合得来。男生更看重女生的身材脸蛋,还是...

程序员为什么千万不要瞎努力?

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

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

当HR压你价,说你只值7K,你该怎么回答?

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

面试:第十六章:Java中级开发(16k)

HashMap底层实现原理,红黑树,B+树,B树的结构原理 Spring的AOP和IOC是什么?它们常见的使用场景有哪些?Spring事务,事务的属性,传播行为,数据库隔离级别 Spring和SpringMVC,MyBatis以及SpringBoot的注解分别有哪些?SpringMVC的工作原理,SpringBoot框架的优点,MyBatis框架的优点 SpringCould组件有哪些,他们...

面试阿里p7,被按在地上摩擦,鬼知道我经历了什么?

面试阿里p7被问到的问题(当时我只知道第一个):@Conditional是做什么的?@Conditional多个条件是什么逻辑关系?条件判断在什么时候执...

终于懂了TCP和UDP协议区别

终于懂了TCP和UDP协议区别

Python爬虫,高清美图我全都要(彼岸桌面壁纸)

爬取彼岸桌面网站较为简单,用到了requests、lxml、Beautiful Soup4

立即提问
相关内容推荐