PHP - Mysql Internal Pointer Position
Is there a way to get the mysql's internal pointer position? I have searched Google, found this:
Code: [Select] <?php function mysql_pointer_position($result_set) { $num_rows = mysql_num_rows($result_set); $i = 0; while($result = mysql_fetch_array($result_set)) { $i++; } $pointer_position = $num_rows - $i; //Return pointer to original position if($pointer_position <= $num_rows - 1) { mysql_data_seek($result_set, $pointer_position); } return $pointer_position; } ?> But I don't really like it. Is there a better way to find the current position of the internal pointer? Similar TutorialsHello, So I have a weird error where if I fetch more than a certain number of rows from a mysql table, it triggers a 500 Internal Server Error. I am using Apache Web Server (through GoDaddy) and the offending code is below: Code: [Select] set_time_limit(0); $this->Connect(); $Output = array(); $search = "SELECT * FROM <table> WHERE user_id = ?"; if($Statement = $this->MySQLi->prepare($search)){ $Statement->bind_param("i", $UserId); $Statement->execute(); $Statement->bind_result(<result variables>); $count = 0; while($Statement->fetch() && $count++ < 70){ ChromePhp::log(<result variables>); } $Statement->close(); } $this->Disconnect(); ChromePhp::log is a way of dumping things to the Javascript Console in your browser from within a PHP script just as a heads-up. So when I set the stop number as 70, everything is fine. If I try to fetch more than that it triggers a 500 internal server error on Apache Server port 443. I have looked through the error logs and can't figure out the cause but this is almost certainly a server configuration issue? I'd appreciate any feedback, especially anyone familiar with GoDaddy's hosting services Thanks
According to I have a project need to use PHP 5.6.40 connect to mysql version 5.7.34
when I try to connect it by below coding $servername = "localhost"; $username = "user"; $password = "pass"; $db_database = 'db_unelr'; $db_port = '3306'; // Create connection $conn = mysqli_connect($servername, $username, $password,$db_database,$db_port); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } echo "Connected successfully";
it's show 500 internal error.
I have a query at the moment that gives a name, number of rides and number of points
SELECT COUNT( `points` ) AS 'rides', SUM( `points` ) AS 'pts', rider_name FROM tbl_heat WHERE card_id = $card GROUP BY `rider_name` ORDER BY pts DESCwhat I want to do now is add the position in a league table, I have tried amending the query and have the following SELECT @serial := @serial +1 AS pos, rider_name FROM( SELECT COUNT( `points` ) AS 'rides', SUM( `points` ) AS 'pts', rider_name FROM tbl_heat JOIN ( SELECT @serial :=0 ) AS init WHERE card_id = $card GROUP BY `rider_name` ORDER BY pts DESC ) as sortedhowever this query doesn't give what I am after, not sure how far off getting it right, any help would be great So i've been wanting to expand my php horizons if you will and finally break of my fear of OOP. Here's a simple connection script i built, however i'm kind of stuck on a part of it. user passes username/password. i instantiate the mysqlcon class and call the connect function. the connect function attempts a connection to the database. if successful, pass on the username and password to the authenticator class. call the authenticate function. select user based on username/passwrod criteria. if found return "Confirmed" otherwise "Denied" here's my issue, i'm assuming that my Code: [Select] return $this->ok variable is returned back to the mysqlcon class. however how can i return that variable once more back outside of the object class so that i can continue with my script assuming authentication was confirmed. Here's my code... thanks for the help! <?php ## OOP PRACTICE ## class mysqlcon { function connect($user,$pass) { //Note: Connect to the database $db = mysql_connect("localhost", "usr","psw") or die(mysql_error()); if(mysql_select_db("database",$db) or die(mysql_error())) { $auth = new authenticator(); $auth->authenticate($user,$pass); } } } class authenticator { var $ok = "Confirmed"; var $ex = "Denied"; function authenticate($user,$pass) { //Note: User user and pass variables to check for user in table $qry = "SELECT * FROM users WHERE username = '$user' AND password = '$pass'"; $sql = mysql_query($qry) or die(mysql_error()); $cnt = mysql_num_rows($sql); if($cnt > 0) { return $this->ok; } else { return $this->ex; } } } $con = new mysqlcon(); $con->connect($_POST['username'],$_POST['password']); ?> PS: the classes are in class.php and the instantiation are in index.php. I just placed them together for easy of viewing. Hey guys. Me again... Essentially what i am doing is pulling data from a MySQL database about the number of thumbnails on a page. The user can then change this using a <select> dropdown menu. How ever, i want the <select> to default to the amount already specified by the Database. I know i can do this by inserting a Selected attribute to one of the <options> but what is the best way of doing this? Heres my code.. $NumberOfThumbnails = mysql_result($data, 0,"NumberOfThumbnails"); <select name="numberofthumbnails"> <option value="0">None</option> <option value="2">2</option> <option value="4">4</option> <option value="6">6</option> <option value="8">8</option> <option value="10">10</option> <option value="12">12</option> <option value="14">14</option> <option value="16">16</option> <option value="18">18</option> <option value="20">20</option> <option value="22">22</option> <option value="24">24</option> <option value="25">25</option> <option value="26">26</option> <option value="27">27</option> <option value="28">28</option> </select> Thanks - Danny I'm entering my site via a sub folder, e.g. mysite.com/BeginHere (which triggers index.php in the BeginHere folder) and then including my main page which is in the root folder. I change the directory pointer with chdir( '../' ) so now I'm officially back in the root folder. This works fine - but the HTML still points to one directory down. Is there any way I can move this up one level as well? This topic has been moved to CSS Help. http://www.phpfreaks.com/forums/index.php?topic=350544.0 Hey guys quick question. I have one static ip address that if i put in the broswer it will forward to the internal ip of my server and will display my website which is located on my server. In my house i also have a development pc which is accessibal within my local network and i would like to be able to view it from my website in an iframe or something. My goal is to just go to my website have a page which will load the local internal ip of my dev pc and display my wamp folder. so i can show my clients the progress on their site. I know this is now good practice but this is just and simplified example of what i am trying to achieve. I would like to display te internal ipaddress on my webserver so that when im on the road i can simply click a link on my website and display the content of my dev pc wamp server? Is ther a special link that i need to use? Is this possible with or without PHP? Should i use an iframe? Hi guys! I'm having a problem with my search bar on my company website. I don't know what's going on, I think that everething is ok. But I'm not a master with php. If anyone can help me with this, I'll be very apprceitte it. Here is the code.
<!-- SEARCH --> Hey guys and gals!
I am currently working on implementing the following functionality in one of my pages:
Whenever a person with a specific IP address visits the page, an internal countdown timer of 2 hours should be started. Until that timer is active, the only response from the page ANYONE can get would be a predefined echo value. Once the timer has run out, the normal script execution of the rest of the page should be restored.
Any pointers and tips on how to approach that would be greatly appreciated.
hi, sorry if is a very noob question in this site http://thevalley.org.au/index.php I have changed the info in the link contact us, I know is there changed, cause if I hit the open in new tab contact us, or go to http://thevalley.org.au/contact.php it opens the link in the actual content, but, when it opens the contact us in the side menu, I see the old info how to refresh it, as F5 doesnt seem to work?? thank you! Hello, I am using the Pear Mail and Mail_Mime packages to send SMTP authenticated HTML formatted emails. I was successfully sending emails when I started getting the following error: sendmail: 451 Internal Error I check out the sendmail logs at /var/log/mail.log but that only says the same thing. I am running Linux-Ubuntu and sending emails from an address on a remote server (godaddy hosted). The interesting thing is that this exact same code will run to completion and fail. Any thoughts? Anyone with Pear Mail experience, is there any way to end the SMTP session, maybe that is the problem. I also think an issue might be that the server thinks my IP is sending too many emails, any way to provision against that? Thanks for any insight and please let me know if other information might be helpful to debug this. i tried to access website from a shared network but i keep getting this error. Before this I can access the website through my local host. But since we have started using the shared server.. i cant access most of the websites.. i searched on google they mentioned about php.ini settings. No idea why did my superior changed to iis server.. definitely works on apache before. I look at my phpinfo() output, and it has ISO-8859-1 and ISO-8859-15 all over it. UTF is not listed once.
Furthermore, mb_internal_encoding() displays it as ISO-8859-1.
For the most part, I stick to the default settings unless I have a specific reason to change.
Should I be changing php.ini to use UTF-8? If so, any specific advice how to do so? This whole encoding issue has been causing me major grief today
Only thing I really miss from PHP is "internal" access modifier. Before I was making libraries and extensions in C# (like game frameworks, Tiled implementations, GUI loaders). Now, when I am working on my own PHP framework, I really miss internal, I was using it a lot in C#. Is internal planned to be added in PHP 7 or is it already in PHP 5.6 or it will never be added?
Dear all, try{ $excelContent = chr(255).chr(254).@mb_convert_encoding($excelContent, 'UTF-16LE', 'UTF-8'); } catch (Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n"; } Do you have any idea about this code? I try to catch the error but it's not work Edited June 28 by nitiphone2021test.php: <?php class Forall{ public $var_a=100; function process(){ echo 'This is for testing'.'<br>'; echo '$var_a: '.$this->var_a.'<br>'; } } $obj=new Forall(); $obj->process(); <form action='post' method='insvideo.php'> videotitle: <input type='text' name='nm_videotitle'/><br> description: <input type='text' name='nm_description' /><br> createddate: <input type='text' name='nm_createddate' /><br> image: <input type='text' name='nm_image' /><br> <input type='submit' /> </form> ?> error: Quote Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, admin@example.com and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log. How can i know the line number for error? So I have some php code within an html page (using Apache v2.2, PHP v5.2) that uses MySQLI to connect to a database and fetch some rows from a database. Everything works fine so long as I limit the number of rows fetched, if I try to fetch all the rows, I get a 500 Internal Server Error in my browser. I am using GoDaddy Hosting -- has anyone encountered this problem/know what the hell is going on? The following links propose two different versions https://docs.phpdoc.org/3.0/guide/references/phpdoc/tags/internal.html https://manual.phpdoc.org/HTMLSmartyConverter/HandS/phpDocumentor/tutorial_tags.inlineinternal.pkg.html Respectively
{@internal} The second link, in particular, mentions CitazioneUnlike other inline tags, {@internal}} may contain other inline tags due to its purpose. To terminate an {@internal}} inline tag, you must use two ending brackets "}}" Which is the correct one? Hi. I had this form all working, but then I commented out some echo's and changed the name of my custom error variables now all of a sudden when I hit submit without all fields I get an INTERNAL SERVER ERROR PAGE. Code: [Select] Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log. Apache/1.3.33 Server at www.fusionfashionhair.com Port 80 I don't know what else would have causes this as I had it working yesterday? My code: <?php session_start(); ?> <?php $submit = $_POST['submit']; // Form Data $email = $_POST['email']; $password_old = $_POST['password_old']; $password_new = $_POST['password_new']; $password_new_con = $_POST['password_new_con']; $errorcount = 0; // Edit anything inbetween the " " for the display error message $errormsg['sErrEmail'] = "Email Entered is not in our database"; $errormsg['sErrOldPass'] = "Old Password Entered is Incorrect. Please check your Email"; $errormsg['sErrNewPass'] = "New Password must be between 6 and 32 characters"; $errormsg['sErrNewPassCon'] = "New Passwords do not match."; $errormsg['sErrSecCode'] = "Security Code is Invalid"; $errormsg['sErrdbPass'] = "Invalide Email or activation code. Please Contact <a href='mailto:webmaster@fusionfashionhair.com?subject=Fusion Fashion Hair - Member Activation Error%20Request'>Admin</a>"; $errormsg['NoErr'] = "No Errors, Continue"; $errormsg['PlaceHold'] = ""; $errortrack[] = $errormsg['PlaceHold']; if ($_POST[submit]){ if ($errorstop = "go") { $errorstop="go"; while ($errorstop<>"stop") { //Check for security code if ($_SESSION[key]==$_POST[user_code]){ // echo "True - Continue 0"; // echo "<p>----------</p>"; $_SESSION[key]=''; } else { // echo "False - Stop 0"; $errortrack[] = $errormsg['sErrSecCode']; $errorcount++; $errorstop="stop"; } // check email verification if (!checkEmail($email)) { // echo "False - Stop 1"; $errortrack[] = $errormsg['sErrEmail']; $errorcount++; $errorstop="stop"; } else { // echo "True - Continue 1"; // echo "<p>----------</p>"; } // check for existance if (strlen($password_old)>5) { // echo "True - Continue 2"; // echo "<p>----------</p>"; } else { // echo "False - Stop 2"; $errortrack[] = $errormsg['sErrOldPass']; $errorcount++; $errorstop="stop"; } // check for existance if (strlen($password_new)>32||strlen($password_new)<6) { // echo "False - Stop 3"; $errortrack[] = $errormsg['sErrNewPass']; $errorcount++; $errorstop="stop"; } else { // echo "True - Continue 3"; // echo "<p>----------</p>"; } // check for existance if ($password_new_con==$password_new) { // echo "True - Continue 4"; // echo "<p>----------</p>"; $errorstop="stop";//Get Out of loop } else { // echo "False - Stop 4"; $errortrack[] = $errormsg['sErrNewPassCon']; $errorcount++; $errorstop="stop"; } }//End While Loop // Check database require('dbConfig.php'); // Encrypts old password to check with Database Encryped Password $password_old = md5($password_old); $check = mysql_query("SELECT * FROM {$usertable} WHERE email='$email' AND password='$password_old'"); $checknum = mysql_num_rows($check); if ($checknum==1) { // echo "True - Continue 5 Set password"; // echo "<p>----------</p>"; // Encrypts new password $password = md5($password_new); //run a query to update the account $acti = mysql_query("UPDATE {$usertable} SET password='$password' WHERE email='$email'"); } else { // echo "False - Stop 5"; $errortrack[] = $errormsg['sErrdbPass']; $errorcount++; $errorstop="stop"; }//End if checknum // echo "True - Continue 6 GO TO HEADER PAGE"; // Thank you Page $insertGoTo = "changepass.php"; header(sprintf("Location: %s", $insertGoTo)); //send confirmation email $to = $email; $subject = "Password Changed for Fusion Fashion Hair"; $headers = "From: webmaster@fusionfashionhair.com"; $server = "mail.fusionfashionhair.com"; //change php.ini and set SMTP to $server ini_set("SMTP",$server); $body = " Password Successfuly changed for $email, \n\n Please click on the link provided below to activate the account with Fusion Fashion Hair http://www.fusionfashionhair.com/activate.php?id=$lastid&code=$random \n\n Thank you, Customer Service Contact webmaster for any concerns regarding this email. <a href='mailto:webmaster@fusionfashionhair.com?subject=Fusion Fashion Hair - Password Change Error%20Request'>Admin</a>. "; //function to send email mail($to, $subject, $body, $headers); } else { while($errorcount>=0) { // Test display all error messages // echo "<p>----------</p>"; // echo "<p>Error Count = '$errorcount'</p>"; } $errormsg['MissAll'] = "Please Enter in ALL Fields!"; die ("PLEASE FILL IN ALL FIELDS"); }// End If Error Go }// End if Submit ?> <?php // LINUX PLATFORM OPTION 3 // checkEmail function checks standard email format same as preg_match() // checkEmail function checks DSN records using checkdnsrr Use list() to seperate name and domain using split function // checkdnsrr ONLY WORKS on LINUX PLATFORM // Check to see if domain and username is active // uses fsockopen() to check if its in use using port 25 function checkEmail($email) { // checks proper syntax if(preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/" , $email)) { // gets domain name list($username,$domain)=split('@',$email); // checks for if MX records in the DNS if(!checkdnsrr($domain, 'MX')) { return false; } return true; } return false; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Fusion Fashion Hair, Loop Hair Extensions Winnipeg, MB </title> <link href="css/thrColLiqHdr.css" rel="stylesheet" type="text/css" /> <link rel="stylesheet" type="text/css" href="css/p7exp.css"/> <link rel="stylesheet" type="text/css" href="css/loginforms.css"/> <!--[if lte IE 7]> <style> .content { margin-right: -1px; } /* this 1px negative margin can be placed on any of the columns in this layout with the same corrective effect. */ ul.nav a { zoom: 1; } /* the zoom property gives IE the hasLayout trigger it needs to correct extra whiltespace between the links */ </style> <![endif]--> </head> <body onLoad="document.getElementById('user_code').focus();"> <body> <div class="container"> <div class="header"><img src="mainlogo3.gif" width="824" height="353" alt="Fusion Fashion Hair" /> </div> <!-- end .header --> <div id="menuwrapper"> <ul id="p7menubar"> <li><a href="#">Home</a></li> <li><a href="#">Products</a></li> <li><a href="#">Shipping</a></li> <li><a href="#">Instructions</a></li> <li id="LastItem"><a href="#">Contact Us</a></li> </ul> </div> <!-- end menuwrapper --> <div class="sidebar1_login"> <h1 class="left">Welcome to Fusion Fashion Hair</h1> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <!-- end .sidebar1 --></div> <div class="content_login"> <p> </p> <div class="divider"><!--Page From Divider Line--> <p> </p> </div> <!--End of Divider--> <p> </p> <form action='newpassform.php' method='post' id="regform"> <fieldset> <legend>Change Password</legend> <p><?php foreach ( $errortrack as $value) { //( $errortrack as $key => $value) echo "<span class='errorcode'>$value</span>";}?> </p> <p> <label for='email'>Email:</label> <input name='email' type='text' maxlength="25" value='<?php echo $email; ?>'/> </p> <p> <label for='password_old'>Old Password:</label> <input name='password_old' type='password' maxlength="32" /> </p> <p> <label for='password_new'>New Password:</label> <input name='password_new' type='password' maxlength="32"/> </p> <p> <label for='password_new_con'>Confirm Password:</label> <input name='password_new_con' type='password' maxlength="32"/> </p> <p><span class="required">*</span> Note, username and password are case sensitive</p> <p>Forgot your password? <a href="forgot_password.php">Click Here</a></p> <p>Login <a href="login.php">Here</a></p> <h2>Security Check</h2> <p>Enter letters below exactly how they are displayed. Letter are case sensitive. </p> <br /> <img src="captcha.class.php?usefile=1" /> <!--OR--> <!--<img src="image.php" />--> <input id='user_code' name='user_code' type='text' size='10' > <p> </p> <input class="reset" type='reset' value='Cancel' name='reset'> <input class="submit" type='submit' value='Continue' name='submit'> </fieldset> </form> <!--End of Form--> <!-- end .content --> </div> <div class="sidebar2_login"> <p> </p> <p> </p> <p> </p> <p> </p> <!-- end .sidebar2 --></div> <div class="footer"> <!-- end .footer --></div> <!-- end .container --></div> </body> </html> |