PHP - My Code Works Fine. Once I Add A Where Sql Function, It Doesn't
Code: [Select]
<?php $objConnect = mysql_connect("localhost","","cgdfgdfg") or die(mysql_error()); $objDB = mysql_select_db("ffdfvbbd"); $pic2 = "SELECT * FROM images"; if (!isset($_GET['Page'])) $_GET['Page']='0'; $pic1 = mysql_query($pic2); $Num_Rows = mysql_num_rows($pic1); $Per_Page = 16; // Per Page $Page = $_GET["Page"]; if(!$_GET["Page"]) {$Page=1;} $Prev_Page = $Page-1; $Next_Page = $Page+1; $Page_Start = (($Per_Page*$Page)-$Per_Page); if($Num_Rows<=$Per_Page) {$Num_Pages =1;} else if(($Num_Rows % $Per_Page)==0) {$Num_Pages =($Num_Rows/$Per_Page) ;} else {$Num_Pages =($Num_Rows/$Per_Page)+1; $Num_Pages = (int)$Num_Pages;} $pic2 .="ORDER by thumbnailID DESC LIMIT $Page_Start , $Per_Page" ; $pic1 = mysql_query($pic2); $cell = 0; $link1 = "SELECT * FROM images"; echo ' <div id="tablediv"> <table border="0" cellpadding="17" cellspacing="0" class="table"> <tr>'; while($pic = mysql_fetch_array($pic1)) { if($cell % 4 == 0) { echo '</tr><tr>'; } if($cell == 2) { echo ' <td> filler </td>'; } elseif ($cell == 3) { echo ' <td> filler </td>'; } else { echo ' <td> <a href="/' . $pic["link"] . '.php"> <div class="image"> <img src="https://s3.amazonaws.com/images/' . $pic["pic"] . '.png" alt="' . $pic["alt"] . '" height="200" width="200" /> </div> </a> </td>'; } $cell++; } echo '</tr></table></div>'; ?>The code above works just fine. However, once I add a WHERE function,as shown below, I get a "Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource" error. Code: [Select] <?php $objConnect = mysql_connect("localhost","","cgdfgdfg") or die(mysql_error()); $objDB = mysql_select_db("ffdfvbbd"); $pic2 = "SELECT * FROM images WHERE folder = 'blog' "; //WHERE FUNCTION IS HERE if (!isset($_GET['Page'])) $_GET['Page']='0'; $pic1 = mysql_query($pic2); $Num_Rows = mysql_num_rows($pic1); $Per_Page = 16; // Per Page $Page = $_GET["Page"]; if(!$_GET["Page"]) {$Page=1;} $Prev_Page = $Page-1; $Next_Page = $Page+1; $Page_Start = (($Per_Page*$Page)-$Per_Page); if($Num_Rows<=$Per_Page) {$Num_Pages =1;} else if(($Num_Rows % $Per_Page)==0) {$Num_Pages =($Num_Rows/$Per_Page) ;} else {$Num_Pages =($Num_Rows/$Per_Page)+1; $Num_Pages = (int)$Num_Pages;} $pic2 .="ORDER by thumbnailID DESC LIMIT $Page_Start , $Per_Page" ; $pic1 = mysql_query($pic2); My mysql table includes column thumbnailID folder link pic alt time The folder column is there so I can specify what I want in the page. Anyhow, why won't it work? Similar TutorialsHello everyone, I'm having this problem which is really annoying, tried to solve it but couldn't, I write that code in PHPMyAdmin and it works great, but it doesn't work in the website it self ok long story short, there are three tables, hotels, cities, countries hotels include in addition to hotel info, 2 columns (city_id) and (country_id) Cities include id and name and also countries include id and name what I was trying to do, that when a person inputs a city or country name in the search form, it should get the hotels that exists in this city or country, but unfortunately it shows all the hotels in all cities and countries, although the pagination code for number of pages works just fine, it count the number of hotels in that city or country and show the number of pages correctly so here is the code for both for hotel search Code: [Select] class hotelManager { public function getHotel($where) { $where = isset($_POST['where']) ? $_POST['where'] : ""; $dbObj = new DB(); $sql = "select * from hotels where city_id = (select id from cities where name = '$where' ) or country_id = (select id from countries where name = '$where' )"; $result = MYSQL_QUERY($sql); $arr = array(); echo "<table>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td valign=\"top\" width=\"120px\">"; $rowid = $row['id']; $imageqry=mysql_query("SELECT * FROM `hotelphotos` where hotel_id='$rowid' LIMIT 1"); $image=mysql_fetch_array($imageqry); $imagename=$image['attachmentName']; echo "<img src=\"foxmaincms/webroot/files/small/$imagename\"/>"; echo "</td>"; echo "<td valign=\"top\">"; echo "<table> <tr> <td valign=\"top\"> <a href=\"hotels.php?id=".$row['id']."\" class=\"titleslink\">".$row['name']."</a> </td> </tr> <tr> <td class=\"text\" valign=\"top\"> ".$row['location']." </td> </tr> </table>"; echo "</td>"; echo "</tr>"; } echo "</table>"; for hotel pagination Code: [Select] <?php include("includes/hotelsManager.php"); $hotelObj = new hotelManager(); $where = isset($_POST['where']) ? $_POST['where'] : ""; if(isset($_POST['where'])) { $hotelObj -> getHotel($where); $per_page = 9; //Calculating no of pages $sql = "select * from hotels where city_id = (select id from cities where name = '$where' ) or country_id = (select id from countries where name = '$where' )"; $result = MYSQL_QUERY($sql) or die("<br />No Hotels found in this city, please check the city name and try again"); $count = mysql_num_rows($result); $pages = ceil($count/$per_page) ?> <div id="loading" ></div> <div id="maincontent" ></div> <ul id="pagination"> thank you in advance Hi, I have some code which works but when I created a function and call this same code it doesn't. The error I get is as follows: Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/fhlinux010/l/languageschoolsuk.com/user/htdocs/admin/email.php on line 42 Error retrieving schools The code function CreateSchoolCheckboxes() { echo '<div style="height:400px;width:400px;font:16px/26px Georgia, Garamond, Serif;overflow:scroll;">'; $querySchools = "SELECT * FROM school"; $result = mysql_query($querySchools, $conn) or die ("Error retrieving schools ".mysql_error()); while($row = mysql_fetch_array($result)) { $schoolname = $row['name']; echo '<input type="checkbox" name="school" value="'.$schoolname.'">'; echo $schoolname . '<br>'; } echo '</div>'; } Im sure that this is probably something simple but any suggestions would be much appreciated. Thanks, Joe I have created a script (single file) that works fine when testing it alone, but when included it doesn't and rest of page is blank. What could cause this? Is this because of some "mismatch" between the queries, variables used on the included file and the existing file? I am having a very difficult time working out what to look at next. I have a page and it will not fopen a new file or an existing one to write. Even though I have a couple of other pages that copy into the same location without trouble. My PHP is 5.2.13 on W2k3 IIS. Here is the code that works; copy($myDir.$file, "\\\\Eeyore\\TempEDI\\".$file); Here is the code that fails; $fileN = "\\\\Eeyore\\TempEDI\\alley.txt"; $fh1 = fopen($fileN, 'wb'); I have tried with and without the new file already existing. I have checked NTFS permissions and the Share permissions. The webserver in use is remote to the files. I have turned on File level object access auditing on the Eeyore server (also win2k3) and the fopen call does not even hit the Eeyore server, I can see all other access to the file and folder but nothing from the page in question. Safe_mode and Opendirbase are both unset in php.ini. All I want to do is make a text file and add some lines of text, this problem is absolutely infuriating. FOR the CMS go to http://sandeepthapa.com.np/project/admin and login in username: user pasword: 123456 with both Chrome and IE. pleease and site is http://sandeepthapa.com.np/project/ it works fine with Chrome, but not with IE. please help me this is my first CMS . i am learning.. it i use joommla templetefor design. oz i am not a designer //..here is the code for process_login.php page <?php require_once("includes/session.php"); ?><?php require_once("includes/connection.php"); ?><?php require_once("includes/functions.php"); ?><?php if (logged_in()) { redirect_to("content.php"); } if (isset($_POST['submit'])) { if(!$_POST['username']) { echo ' Make sure u type in username'; } if( !$_POST['password']) { echo 'make sure you type password'; } $username = trim(mysql_prep($_POST['username'])); $password = trim(mysql_prep($_POST['password'])); $hashed_password = sha1($password); // Check database to see if username and the hashed password exist there. $query = "SELECT id, username "; $query .= "FROM users "; $query .= "WHERE username = '{$username}' "; //$query .= "AND hashed_password = '{$hashed_password}' "; $query .= "AND hashed_password = '{$hashed_password}' "; $query .= "LIMIT 1"; $result_set = mysql_query($query) or die(mysql_error()); if(!$result_set) {die("Database connection failed: " . mysql_error());} confirm_query($result_set); if (mysql_num_rows($result_set) == 1) { // username/password authenticated // and only 1 match $found_user = mysql_fetch_array($result_set); //echo $found_user['id']; $_SESSION['user_id'] = $found_user['id']; $_SESSION['username'] = $found_user['username']; //echo 'test query'; redirect_to("content.php"); } } else { echo 'error'.mysql_error(); } ?> </body> </html> Good day dear community. I need to build a function which parses the domain from a url. I have used various ways to parse html sources. But this one is is a bit tricky! See the target i want to parse - it has some invaild Markup: http://www.schulministerium.nrw.de/BP/SchuleSuchen?action=644.0013008534253&SchulAdresseMapDO=194190 well what do you think - can i apply this code here <?php require_once('config.php'); // call config.php for db connection $filename = "url.txt"; // Include the txt file which have urls $each_line = file($filename); foreach($each_line as $line_num => $line) { $line = trim($line); $content = file_get_contents($line); //echo ($content)."<br>"; $pattern = '/<td>(.*?)<\/td>/si'; preg_match_all($pattern,$content,$matches); foreach ($matches[1] as $match) { $match = strip_tags($match); $match = trim($match); //var_dump($match); $sql = mysqli_query("insert into tablename(contents) values ('$match')"); //echo $match; } } ?> well i have to rework the parser-part of this script. I need to parse somway different - since i have other site here. Can anybody help me here to get a better regex - or a better way to parse this site ... Any and all help will be greatly apprecaited. regards db1 Hi all, I wonder if any of you have this problem before.. I have a login page with "checked box remember me" - It is working fine in my localhost machine I can see the COOKIE in my browser's option setting (Firefox). But now the problem is: When I run the script in my test server; and do exactly the same thing..the COOKIE did not seem know. When I logged in as an admin and checked the box. And closed all the browser. Then, open the browser (Firefox)and go to the index page (landing page) then it redirect me to the login page instead. I looked the at COOKIE setting in my Firefox and I can it is stored there. Any ideas whats wrong? hi i have the script below which copies data from one table to another but will only insert new data update current data or delete old data from tempproducts to products then it will delete the tempproducts from the db however i keep getting this error: Warning: mssql_query() [function.mssql-query]: Query failed in E:\UpdateProducts.php on line 33 updateproducts.php Code: [Select] <?php include('../../otherscripts/functions.php'); $log = new Logging(); // create DB connection $host = "localhost"; $user = "user"; $pass = "pass"; $mydb = "db"; $db = mssql_connect($host,$user,$pass); //Select Database mssql_select_db($mydb); // delete all old data $sql0 = "SELECT * FROM tempproduct"; $sql1 = "INSERT INTO products SELECT * FROM tempproduct WHERE manf_part_no NOT IN (SELECT manf_part_no FROM products) AND supp_id NOT IN (SELECT supp_id FROM products)"; $sql2 = "DELETE FROM products WHERE manf_part_no NOT IN (SELECT manf_part_no FROM tempproduct) AND supp_id NOT IN (SELECT supp_id FROM tempproduct)"; $sql3 = "UPDATE p1 SET p1.avail_qty = t1.avail_qty, p1.cost_price = t1.cost_price, p1.rrp = t1.rrp, p1.date_added = t1.date_added, p1.description = t1.description FROM Products p1 INNER JOIN tempproduct t1 ON (p1.manf_part_no = t1.manf_part_no AND p1.supp_id = t1.supp_id)"; $sql4 = "TRUNCATE TABLE tempproduct"; //If tempproduct is empty done Execute Commands if it is full then execute commands $query = mssql_query($sql0) or die($log->lwrite('Failed to select for count from db')); $rowcount = mssql_num_rows($query); if($rowcount == 0){ $log->lwrite('Teh tempproduct am emptyish'); } else{ mssql_query($sql1) or die($log->lwrite('Failed to insert to db'.$sql1)); mssql_query($sql2) or die($log->lwrite('Failed to Delete from db')); mssql_query($sql3) or die($log->lwrite('Failed to Update db')); mssql_query($sql4) or die ($log->lwrite('Failed to TRUNCATE db')); } ?> if i run $sql1 command in the sql manager it runs fine and no errors occur? I have strange problem with SOAP. My file SchoolAPI look like that: <?php require_once('../require/constants.php'); require_once('../require/connection.inc.php'); class SchoolAPI{ private $dbh; public function __construct() { $this->dbh = new PDO(DRIVER.':host='.HOST.';dbname='.DB, USER, PASSWORD); } //function return all subcjects public function getSubjects(){ $sth = $this->dbh->prepare(' SELECT id, nazwa ROM subjects'); $sth->execute(); return $sth->fetchAll(PDO::FETCH_NUM); //return array(array("1", "subject1"),array("2", "subject2")); } //function return all classes public function getClasses(){ $sth = $this->dbh->prepare(' SELECT id, nazwa FROM classes'); $sth->execute(); return $sth->fetchAll(PDO::FETCH_NUM); //return array(array("1", "class1"),array("2", "class2")); } } ini_set("soap.wsdl_cache_enabled", "0"); $server = new SoapServer("SchoolAPI.wsdl"); $server->setClass("SchoolAPI"); $server->handle(); ?> wsdl file is named SchoolAPI.wsdl and look like that: <wsdl:definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://schema.example.com" targetNamespace="http://schema.example.com" > <wsdl:types> <xsd:schema targetNamespace="http://schema.example.com"> <xsd:complexType name="myarry2"> <xsd:sequence> <xsd:element minOccurs="0" maxOccurs="unbounded" name="row" nillable="true" type="xsd:string" /> </xsd:sequence> </xsd:complexType> </xsd:schema> <xsd:schema targetNamespace="http://schema.example.com"> <xsd:complexType name="myarray"> <xsd:sequence> <xsd:element minOccurs="0" maxOccurs="unbounded" name="table" nillable="true" type="tns:myarry2" /> </xsd:sequence> </xsd:complexType> </xsd:schema> </wsdl:types> <wsdl:message name="getSubjectsRequest"></wsdl:message> <wsdl:message name="getSubjectsResponse"> <part name="getSubjectsReturn" type="tns:myarray"/> </wsdl:message> <wsdl:message name="getClassesRequest"></wsdl:message> <wsdl:message name="getClassesResponse"> <part name="getClassesReturn" type="tns:myarray"/> </wsdl:message> <wsdl:portType name="SchoolAPIPortType"> <wsdl:operation name="getSubjects"> <wsdl:input message="tns:getSubjectsRequest"/> <wsdl:output message="tns:getSubjectsResponse"/> </wsdl:operation> <wsdl:operation name="getClasses"> <wsdl:input message="tns:getClassesRequest"/> <wsdl:output message="tns:getClassesResponse"/> </wsdl:operation> </wsdl:portType> <wsdl:binding name="SchoolAPIBinding" type="tns:SchoolAPIPortType"> <soap:binding transport="http://schemas.xmlsoap.org/soap/http"/> <wsdl:operation name="getSubjects"> <soap:operation soapAction="urn:SchoolAPI/getSubjects" style="document"/> <wsdl:input> <soap:body use="literal"/></wsdl:input> <wsdl:output><soap:body use="literal"/></wsdl:output> </wsdl:operation> <wsdl:operation name="getClasses"> <soap:operation soapAction="urn:SchoolAPI/getClasses" style="document"/> <wsdl:input> <soap:body use="literal"/></wsdl:input> <wsdl:output><soap:body use="literal"/></wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name="SchoolAPI"> <wsdl:port name="SchoolAPIPort" binding="tns:SchoolAPIBinding"> <soap:address location="http://localhost:82/myschool/webservices/SchoolAPI.php" /> </wsdl:port> </wsdl:service> </wsdl:definitions> The problem is that correct data is returned olny by first function declarated in <wsdl:binding> section. In this example correct data will be return by getSubjects function, and function getClassses return null. However, if we change order and put getClasses operation first in binding section like this: <wsdl:binding name="SchoolAPIBinding" type="tns:SchoolAPIPortType"> <soap:binding transport="http://schemas.xmlsoap.org/soap/http"/> <wsdl:operation name="getClasses"> <soap:operation soapAction="urn:SchoolAPI/getClasses" style="document"/> <wsdl:input> <soap:body use="literal"/></wsdl:input> <wsdl:output><soap:body use="literal"/></wsdl:output> </wsdl:operation> <wsdl:operation name="getSubjects"> <soap:operation soapAction="urn:SchoolAPI/getSubjects" style="document"/> <wsdl:input> <soap:body use="literal"/></wsdl:input> <wsdl:output><soap:body use="literal"/></wsdl:output> </wsdl:operation> </wsdl:binding> then correct data will be return by getClasses function, and getSubjects will return null. Do you know what is going on? I do my best to solve this problem and I have no idea what is wrong... I have two functions that execute an exe program (personal project for a minecraft back end.) Windows only.
First one will execute the sending of commands (THIS ONE WORKS) /* check to see if admin is sending commands to terminal via web */ if(isset($_POST['command'])) { $content = $_POST['command']; writeMCCommandTxt($content); try { exec(SERVER_DIR.'mcCommand.exe',$output); } catch ( Exception $e ) { die ($e->getMessage()); } }// END COMMAND ENTRY This has been a head scratcher for most the week - any help or suggestions would be great!! thanks!!
HTML <div id="commands"> <div id="command_input"> <form method="post" id="commandForm" action="index.php"> <label for="command" >Console Command:</label><br/> <input type="text" name="command" autofocuS/> <input type="submit" name="submit_command" value=" >> " /> <input type="button" value="Refresh page" onclick="location.reload(true);" /> </form> </div> </div>
This is used to start the server // STARTING SERVER if(isset($_POST['startServerBtn'])){ try { exec(SERVER_DIR.'startServer.bat 2>&1' ,$output); } catch( Exception $e ) { die ($e->getMessage()); } } HTML <div id="server_control"> <ul> <li> <form action="index.php" method="post"> <input type="submit" value="START" id="startServerBtn" name="startServerBtn"/> </form> </li> </ul> </div> MCCOMMANDS.EXE will work from both browser(php) and file manager(tested) the STARTSERVER.EXE will NOT work from browser(php), but will work from file manager
The function IS being accessed - debug is showing it going there, and it seems to be running Both exe's are in the same folder Edited May 15, 2020 by Klyx99code tags missing Trying to create a very simple API script sending XML data. When I send the "hard coded" XML, it works perfectly. When I add a form to supply the data for the XML, I get a 500 Internal Server error. Have tried it on two different servers. No error in the logs. Stumped. Examples below are VERY simplified (and obviously won't do anything as-is) to show what I'm dealing with. This one works fine: <?php $xml = "<Order><UserId>foo</UserId><Password>foo</Password><Mode>Test</Mode><Name>Charles R. Hodges</Name>"; $xml .= "</Order>"; $url = 'http://sitename.com'; $ch = curl_init($url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $xml); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch); $xml = simplexml_load_string($response); print_r($xml); ?> And then I use this one and all heck breaks loose with the 500 Internal Error: <?php if (isset($_POST['submit'])) { $xml = "<Order><UserId>foo</UserId><Password>foo</Password><Mode>Test</Mode><Name>{$_POST['name']}</Name>"; $xml .= "</Order>"; $url = 'http://sitename.com'; $ch = curl_init($url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $xml); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch); $xml = simplexml_load_string($response); print_r($xml); exit; } ?> <html>... etc <form method="post" action=""> Name: <input type="text" name="name" /> <p><input type="submit" name="submit" "Add to XML string and send" /> </form> ?>
This may be a bit removed from straight php, but I have a submit button for an e-commerce site as the final step. It runs through all of the php steps and submits the order. The problem is....sometimes the submit button doesn't do anything for some users. They hit it and nothing happens. Is there a way I can verify everything is loaded correctly with php? Its hard to nail it down to a specific problem. Has anyone had this issue in the past? This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=308276.0 Hi there, If anyone has a spare minute, id really appreciate someone casting their eye over this and seeing if there's anything obviously wrong. Writing to the txt file works fine, but the redirect to the thankyou.html page doesn't. Cheers Guys. <?PHP $filename = "output.txt"; #CHMOD to 666 $forward = 1; # redirect? 1 : yes || 0 : no $location = "thankyou.html"; #set page to redirect to, if 1 is above ## set time up ## $date = date ("l, F jS, Y"); $time = date ("h:i A"); ## mail message ## $msg = ""; foreach ($_POST as $key => $value) { $msg .= ucfirst ($key) .", ". $value . ", "; } $msg .= "\n"; $fp = fopen ($filename, "a"); # w = write to the file only, create file if it does not exist, discard existing contents if ($fp) { fwrite ($fp, $msg); fclose ($fp); } else { $forward = 2; } if ($forward == 1) { header ("Location:$location"); } else if ($forward == 0) { echo ("Thank you for submitting our form. We will get back to you as soon as possible."); } else { "Error processing form. Please contact the webmaster"; } ?> Many thanks, Mike Hi, My site was working fine, but I just switched servers/web hosts and now I'm getting the following errors (in blue). The thing is, I don't get the error if I try to run the query loop after just using 'mysql_select_db' once, but if I use it again to select a different database and then run the query loop, I start getting the error. Code: [Select] mysql_select_db ("database1", $mysql_con); $mysql_query = mysql_query ("SELECT ID FROM someTable1", $mysql_con); $someVar1 = 0; while ($mysql_array = mysql_fetch_array ($mysql_query)) { $someVar1 ++; } ////// The above code gives me no error. But If I then try to select a different database and run a loop in the same way (in the same file), I start getting the below error... mysql_select_db ("database2", $mysql_con); $mysql_query = mysql_query ("SELECT ID FROM someTable2", $mysql_con); $someVar2 = 0; while ($mysql_array = mysql_fetch_array ($mysql_query)) { $someVar2 ++; } Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/snubby5/public_html/coozymcmillan.com/view.php on line 86 So I looked it up and somewhere it told me to add some extra code to handle errors better: Code: [Select] if ($mysql_query === FALSE) { die (mysql_error ()); // TODO: better error handling } But when I do that, I get a different error: Table 'database1.someTable2' doesn't exist It doesn't seem to recognize that I switched databases, and it says 'database1.someTable2' doesn't exist (because it doesn't), when really it should be checking for 'database2.someTable2' (which exists). So to reiterate, I can run the query loop fine after selecting database1, but after that if I select database2, it either gives me the first error, or If I add the 'die' code it gives me the second error. Thanks much! PS: I can get it working if I put everything into one database, but I have multiple websites (which sometimes need to call eachothers' databases) and it would be a huge hassle to cram them all into one database unless I have to.
Hi, this query runs fine when I run it from PHPMyAdmin: UPDATE `tran_term_taxonomy` SET `description` = (SELECT keyword from `good_keywords` ORDER BY RAND() LIMIT 1,1) WHERE `tran_term_taxonomy`.`taxonomy` = 'post_tag' AND `tran_term_taxonomy`.`description` = "" LIMIT 1 However, when I run the same query in a PHP file on my server, the page doesn't load at all. The message I get is: www.somesite.com is currently unable to handle this request. HTTP ERROR 500. This is my PHP code: <?php include("/database/connection/path/db_connect.php"); $result4 = mysqli_query($GLOBALS["___mysqli_ston"], "UPDATE `tran_term_taxonomy` SET `description` = (SELECT keyword from `good_keywords` ORDER BY RAND() LIMIT 1,1) WHERE `tran_term_taxonomy`.`taxonomy` = 'post_tag' AND `tran_term_taxonomy`.`description` = "" LIMIT 1"); echo $result4; ?> So how do I make this query work please? Thanks for your guidance. Hello, The following is my situation where I seem to get a 500 error code from the linux server: i have an 'index' file like this: Code: [Select] <?php require("includes/config.php"); $a = $_REQUEST['a']; switch ($a) { case "home": include("frontpage/main.php"); case "user-process": include("user-process.php"); } ?> config.php is something like this: Code: [Select] <?php require(includes/classes/session.class.php); require(includes/classes/user.class.php); require(includes/classes/db.class.php); ... ?> Now if we fall into the case "home" it works fine. Instead, if we fall into user-process it writes to the logs file Fatal Error: Class User does not exist bla bla bla. Why doesn't it exist ? every class is included in the config.php file then index.php includes first config.php ( which has all the classes) and then includes the requested page. I also have a .htaccess file which is as follows: Code: [Select] RewriteEngine On RewriteRule ^([^/\.]+)?/?([^/\.]+)?/?([^/\.]+)?/?([^/\.]+)?/?([^/\.]+)?/?([^/\.]+)?/?([^/\.]+)?$ index.php?a=$1&b=$2&c=$3&d=$4&e=$5&f=$6&g=$7 [NC,L] which is used to access in a SEO friendly way the pages that users request. Hey all. I'm having a little bit of an issue here. I'll start by showing the code: Code: [Select] function dbq($sql) { $q = mysql_query($sql); $row = mysql_fetch_array($q); return $row; } $row = dbq("SELECT * FROM admin"); echo $row['username']; Above code obviously displays a function that can be used for single database outputs.. But, i wanna use it for multiple data outputs, using a while with this function. Something like: Code: [Select] while($row = dbq("SELECT * FROM admin")) { echo $row['username']; echo "<br />"; } But it returns errors like, either does it display the first row a billion times, or does simply timeout.. How can this be done? Thanks in advance! All the tables are correct and it's making the connect to the database fine it's just not working, did I write it wrong? Code: [Select] function newPm($to, $from, $title, $text){ $q = $db->query("SELECT * FROM ibf_message_topics ORDER BY mt_id DESC"); $lastMsg = $db->fetch_assoc($q); $mid = $lastMsg['mt_id'] + 1; $msgId = $lastMsg['mt_msg_id'] + 1; $db->query("INSERT INTO ibf_message_topics SET mt_id=$mid, mt_msg_id=$msgId, mt_date=". time(). ", mt_title='$title', mt_from_id=$from, mt_to_id=". $to. ", mt_vid_folder='in', mt_read=0, mt_owner_id=$to, mt_user_read=0") or die(mysql_error()); $db->query("INSERT INTO ibf_message_text SET msg_id=$msgId, msg_date=". time() .", msg_post='$text', msg_sent_to_count=1, msg_author_id=$from") or die(mysql_error()); $userq = $db->query("SELECT new_msg FROM ibf_members WHERE id = $to"); $userData = $db->fetch_assoc($userq); $msgCount = $userData['new_msg'] + 1; $db->query("UPDATE ibf_members SET new_msg=$msgCount, show_popup=1 WHERE id = $to") or die(mysql_error()); } Here's how that function is being called in the beginning of the page: Code: [Select] if($action =="banUser"){ $expire = time() + (3600000 * 24 * $_GET['duration']); $q = $db->query("SELECT * FROM ibf_message_topics ORDER BY mt_id DESC"); $lastMsg = $db->fetch_assoc($q); $mid = $lastMsg['mt_id'] + 1; $msgId = $lastMsg['mt_msg_id'] + 1; $title = "Notification"; $duration = $_GET['duration'] ." days"; if($_GET['duration'] == "1"){ $duration = "1 day"; } if($_GET['duration'] == "Forever"){ $duration = "forever"; } $temp = 0; if($expire > time()){ $temp = 1; } $body = "This automated message has been sent to notify you that your account has been banned $duration. To appeal this ban, click on Irc from the menu on the homepage and ask to speak to a moderator. If this ban is temporary, your account will be reinstated automatically at the appropriate time"; newPm($id, 3017, $title, $body); $msgCount = $_GET['msg'] + 1; $db->query("UPDATE ibf_members SET ban_level = $level, tempbanned = $temp, banned = 1, ban_expire='$expire', ban_reason='". $_GET['reason']."', ban_by='". $name."' WHERE id=$id") or die(mysql_error()); ?> <center><b>User banned!</b> (<a href="index.php?code=plyrmgmt">Back to Player Management</a>)</center> |