Jump to content

Search the Community

Showing results for tags 'mysqli'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • HTML/XHTML
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • XSLT/XSL-FO
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Languages

  1. Hi all, l'm a Newbie here I would like to create a page, which after user logged in, they was able to update number of chanting daily with number input. User may insert number and click submit button to update its. After updated, below the submit button, to show up the total number of their total chanting number, and total of all users chanting numbers. Lastly is the history of users update in table view which showing username, date of update, number of updates. Can I have the solution or any related article or site which i can referring to... Thanks all.
  2. The following standard code is not allowing access to the MySQL database indicated: // declare database validation variables $servername = "localhost"; $username = "toughnerd"; $password = "frustrated"; $dbname = "workforaliving2"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } echo "Connected successfully"; Here is the error message: The server name, username, password, and database name are correct, defined in phpAdmin as needed. I do understand that "(using password: YES)" just means a password is being used.
  3. BACKGROUND: As always I am concerned about security on the one hand, but do not wish to over-code on the other. In the following outlined procedure the data is fetched from the super secure, vast thicket of layered PHP and sent after translation THE PROCEDURE: Create two MySQL tables linked with a foreign key. Make a method call to the Matomo API and retrieve a four tiered nested array containing two tiers of visitor data. The first tier consists of an indexed array whose 100 elements each corresponds to a single visit to the Grammar Captive website. The second tier consists of an associative array, one for each of the 100 elements of the first tier. The third tier consists of an indexed array of varying length corresponding to one of the elements of each of the second tier arrays. Each element of this third tier array contains an associative array of varying length whose elements correspond to different actions and/or events associated with the respective visit. The fourth tier contains the data for each recorded action or event. Generate two classes: one for the visit data (2nd tier), and one for the action/event data (4th tier). Translate the keys of the key-value pairs of the two aforementioned tiers so that their values can be properly inserted into either of the two data tables. Insert the translated data into the two data tables via two separate objects created from the two classes. With the exception of the creation of the data tables Steps 1-5 are all performed within the context of the same PHP document. QUESTION: Do you see any security risk in the above? Roddy
  4. Hi again, moved the topic to a new one because it no longer uses PCRE. I have the physical problem of having lost my dev pc and 24" screens, now having to make do with android on a 3.5" touchscreen. So the issue i have encountered is again a likeness of this time a bit more physically - "not being able to see the forest for the trees", as my viewing area has been greatly diminished. The code is below, with the php error_log thereafter. <?php $t = intval($_GET["t"]); switch ($t) { case 1: header('Content-Type: Text/XML'); break; case 2: header('Content-Type: Text/JavaScript'); break; case else: header('Content-Type: Text/HTML5'); ?><!DOCTYPE html> <html lang="en-za"> <head> <meta charset="UTF-8"> <title>*** Test Page</title> </head> <body> <p><a href="http://***.com/default.php?t=0&u=Sof00207&f=c&r=45">*** Test Page</a></p><br /> <p> <pre><? /* Initiate Variables for URL: http://***.com/default.php?t=0&u=Sof00207&f=c&r=45 1. Key Field: C 2. Key Row: 45 3. Account Number: Sof00207 4. Month: G 5. Number Of Licenses: 5 6. Active: Y/N: J 7. Licences Used: 3 8. Year: J 9. Module 1: A 10. Module 2: 1 11. Module 3: B 12. Module 4: 0 */ $f = strtoupper($_GET["f"]); $r = intval($_GET["r"]); $f = dirname(__FILE__) . "/RegUploads/" . $_GET["u"] . "#" . $f . $r . ".xml"; print $f . "\r\n\r\n"; if (file_exists($f)) { $ret = file_get_contents($f); print htmlentities($ret); } $servername = "localhost"; $username = "***"; $password = "***"; $dbname = "***"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } // echo "Connected successfully"; $q = intval($_GET["q"]); switch ($q) { case 0: // Return Encryption Key by Field A/B/C/D & Row ID // Define SQL String $sql = "SELECT * FROM `Sleutels` WHERE `ID` = " . $r . ";"; $result = $conn->query($sql); if ($result->num_rows > 0) { print "\"" . $sql . "\"<br />\r\n"; // output data of each row while($row = $result->fetch_assoc()) { print "Key: " . htmlencode($row[$f]). "<br />\r\n"; }; } else { print "\"" . $sql . "\"<br />\r\n"; print "0 results<br />\r\n"; }; break; case 1: echo "q equals 1"; break; case 2: echo "q equals 2"; break; }; ?></pre> </p> </body> </html><? }; $conn->close(); ?> [30-Jan-2019 19:42:33 UTC] PHP Parse error: syntax error, unexpected 'else' (T_ELSE) in /home/dwtnfwfv/public_html/default.php on line 11
  5. Hello, Please help, how to implement the Depth First Search algorithm into PHP MyQsli. I have a table: - problem - because - solution The DFS diagram I attached. thank you
  6. Hi all, I have a couple of questions that popped up while studying php; really not questions, but I want to get some confirmation that my deductions are correct from what I've figured out. I was getting very confused over the differences in the object-oriented mysqli and the procedural mysqli and translating from one to the other. I think I like using OOps better The reference list on w3 only shows the procedural syntax so I wanted to make sure I was coming up with the correct OOps. Things like 'mysqli_query($conn,$sql)' becomes '$conn->query($sql)'. I could see that quite clearly in the tutorial, but some others get a little hazy like 'mysqli_free_result($result)' becomes '$result->free_result'. Do I have this correct? and is there a rule about changing from one to the other - like whatever the object of the function is goes first in the OOps syntax, or something. Now I noticed that when you check for a connection error the OOps syntax says '$conn->connect_err' while the procedural syntax is 'mysqli_connect_error()' with nothing in the parenthesies. Is that because the connection object hasn't actually been established yet? or some other mysterious reason. I also had a quick question about .php files in general. The w3 said that a file with php in it should end with .php, but when I do that the server won't execute it - so I change it to html and its OK. Now if I have a file with exclusively php code and I don't 'echo' any output, but only 'return' a value, do I still need to write the <!DOCTYPE> and other tags like <head>, etc. Or can I start the file with <?php and end it with ?>. Like I said , I think I have these things correctly in my mind, but if I'm not right I want to nip it in the bud and make sure I'm off on a good foundation. I've experimented with different ideas, but if it doesn't work, sometimes you can't figure out what you did wrong. Thank you so much for your input and answers!!
  7. westman

    using OR in MySQLi

    how do I use "OR" in MySQLi? Here is what I have $i = 0; $Db1 = "1"; $Db2 = "2"; $stmt = $conn->prepare("SELECT id, user, title, date, show_post FROM post WHERE show_post = ? ORDER BY id DESC"); $stmt->bind_param("s", $Db1); $stmt->execute(); $stmt->store_result(); //if($stmt->num_rows === 0) exit('No rows'); $stmt->bind_result($idRow, $userRow, $titleRow, $dateRow, $showRow); while ($stmt->fetch()) { $post_id[] = $idRow; $user[] = $userRow; $title[] = $titleRow; $date[] = $dateRow; $post_show[] = $showRow; $i++; // run a while loop } $stmt->close(); $conn->close(); I would like to use OR to look for $Db1 = "1"; $Db2 = "2"; in my DB. How do I use OR?
  8. DILEMMA: My goal is to style the body of a newsletter template. Although I am able to get the formatting into the database and -table, I am unable to retrieve it for insertion in the newsletter's template. Please find below an example of the way in which the value string of only one of the several SQL INSERT statements is created. The string that results is later combined with a name string and other elements of a valid INSERT statement. EXAMPLE OF THE WAY THE INSERTED VALUE IS FORMATTED include_once('../_utilities/php/classes/class.lunarpages.php'); $lunarpages = new Lunarpages(); $mysqli_obj = $lunarpages->get_mysqli_obj(); var_dump($mysqli_obj); $sql_letter_val = "('"; $substr_start = 0; $substr_length = 8; foreach ($newsvar_names as $name => $value) { if (substr($name, $substr_start, $substr_length) == '$letter_') { $sql_letter_val .= $mysqli_obj->real_escape_string($value) . "', '"; } } WHAT APPEARS IN THE DATA TABLE AFTER INSERTION <h1>ようこそ!</h1> <p>「<span style='font-family:Bradley Hand, cursive;font-size:1.8em;'>Seven Gates</span>」と言うのは文法キャプチッブのオンラインニューズレターです。</p> <p>このニューズレターの初版は文法キャプチッブの紹介としてニューズレターの構成及び文法キャプチッブの本質をユーザー達にその母語で説明しています。第二版のニューズレター以降のニューズレターは英語で書いてあるものです。もしニューズレターの初版を英語でも読んだ方が好いとすれば、ウェブ型の変形が<a href='https://www.grammarcaptive.com/?newsletter=1' title='Seven Gates - Edition No. 1' target='_blank'>ここに</a>見付かります。</p> THE RETRIEVAL CODE public function get_letter_data() { $sql = "SELECT letter.*, qa.qa_question, qa.qa_answer FROM sevengates_letter AS letter JOIN sevengates_qa AS qa ON qa.letter_no = letter.letter_no WHERE letter.letter_no =?"; $mysqli_stmt = $this->mysqli_obj->stmt_init(); $mysqli_stmt->prepare($sql); $mysqli_stmt->bind_param('i', $this->letter_no); $mysqli_stmt->execute(); $meta = $mysqli_stmt->result_metadata(); while ($field = $meta->fetch_field()) { $params[] = &$row[$field->name]; } call_user_func_array(array($mysqli_stmt, 'bind_result'), $params); while ($mysqli_stmt->fetch()) { foreach($row as $key => $val) { $c[$key] = $val; } $prelim_result[] = $c; } foreach ($prelim_result as $arr) { foreach ($arr as $name => $value){ $letter_results[$name] = $value; } } return $letter_results; } WHAT IS RETRIEVED and APPEARS IN THE NEWSLETTER ようこそ! DISCUSSION: Everything after the <h1> element has been omitted. QUESTION: What must I do to get everything after ようそう!to appear? Roddy
  9. hello all! i was trying to run another query inside a while loop of a prepared statement. $qs = $_POST['queryString']."%"; $ledq = $mysqli->prepare("SELECT name, fullid aid, ob FROM account WHERE cid='$cid' AND name LIKE ? AND ac_id IN ('$q') ORDER BY name LIMIT 20"); if (!$ledq) { echo "Error: " . $mysqli->error; } else { $ledq->bind_param('s', $qs); $ledq->execute(); $ledq->bind_result($name, $aid, $ob); $ledq->store_result(); while ($ledq->fetch()) { $balq = $mysqli->query("SELECT SUM(debit) debit, SUM(credit) credit FROM .................."); ............... ............... ............... } $ledq->free_result(); $mysqli->close(); } when i use free result outside the while loop it gives out of sync error. if i use free result inside the while loop and before the next query, it returns only one row. i also tried more_result before executing the next query. but it only worked while testing locally. when i upload it to my server and try, it gives nothing. please someone guide me what is the best solution! thank you in advance..
  10. BACKGROUND: It appears that there are few problems in web development that do not have multiple solutions. My problem is to decide which solution best suits my needs. I have a confirmation email that sends a name, hash, and email address via an HTTP REQUEST using the $_GET superglobal to a PHP file that matches the hash with an entry in a newsletter roster table. If the match succeeds the value of the status variable is changed from 0 to 1. Before the hash is sent to the roster table it is sanitized using the MySQLi real_escape_string( ) function. Elsewhere on my website I use the PHP filter_var( ) function with parameter values that vary with the nature of the data being sent. QUESTION ONE: In the above instance which PHP function would be more secure. And, why? QUESTION TWO: In general which function is preferred? And, why? Roddy
  11. hello all! greetings! i'm trying to fetch data from a prepared statement and using some variables to pass the query $wh = "class=? AND section=?"; $param = "'ss', $clas, $sec"; $stmt = $mysqli->prepare("SELECT CONCAT(fname, ' ', lname) AS name, fullid, roll FROM students WHERE $wh AND ay='$ay' AND cid='$cid'"); if (!$stmt->bind_param($param)) { echo "Bind Error: " . $stmt->error; } ?> this is showing error but only "Bind Error:" not the "$stmt->error". i tried to echo $wh and $param value also and they give the same value as i intend. why this is happening? please guide. thanks in advance.
  12. <?php /* * DB Class * This class is used for database related (connect, insert, update, and delete) operations * @author CodexWorld.com * @url http://www.codexworld.com * @license http://www.codexworld.com/license */ class DB{ private $dbHost = "..."; private $dbUsername = "..."; private $dbPassword = "..."; private $dbName = "..."; public function __construct(){ if(!$this->db){ // Connect to the database $conn = new mysqli($this->dbHost, $this->dbUsername, $this->dbPassword, $this->dbName); if($conn->connect_error){ die("Failed to connect with MySQL: " . $conn->connect_error); }else{ $this->db = $conn; } } } /* * Returns rows from the database based on the conditions * @param string name of the table * @param array select, where, order_by, limit and return_type conditions */ public function getRows($table,$conditions = array()){ $sql = 'SELECT '; $sql .= array_key_exists("select",$conditions)?$conditions['select']:'*'; $sql .= ' FROM '.$table; if(array_key_exists("where",$conditions)){ $sql .= ' WHERE '; $i = 0; foreach($conditions['where'] as $key => $value){ $pre = ($i > 0)?' AND ':''; $sql .= $pre.$key." = '".$value."'"; $i++; } } if(array_key_exists("order_by",$conditions)){ $sql .= ' ORDER BY '.$conditions['order_by']; } if(array_key_exists("start",$conditions) && array_key_exists("limit",$conditions)){ $sql .= ' LIMIT '.$conditions['start'].','.$conditions['limit']; }elseif(!array_key_exists("start",$conditions) && array_key_exists("limit",$conditions)){ $sql .= ' LIMIT '.$conditions['limit']; } $result = $this->db->query($sql); if(array_key_exists("return_type",$conditions) && $conditions['return_type'] != 'all'){ switch($conditions['return_type']){ case 'count': $data = $result->num_rows; break; case 'single': $data = $result->fetch_assoc(); break; default: $data = ''; } }else{ if($result->num_rows > 0){ while($row = $result->fetch_assoc()){ $data[] = $row; } } } return !empty($data)?$data:false; } } $test = new DB(); if ($test instanceof DB) { echo 'Instantiated'; } else { echo 'Uninstantiated. Include failed.'; } $conditions = []; $tbl_name = 'rss2_podcast_item'; $test->getRows($tbl_name, $conditions); function getRows($mysqli_obj, $table,$conditions = array()){ $sql = 'SELECT '; $sql .= array_key_exists("select",$conditions)?$conditions['select']:'*'; $sql .= ' FROM '.$table; if(array_key_exists("where",$conditions)){ $sql .= ' WHERE '; $i = 0; foreach($conditions['where'] as $key => $value){ $pre = ($i > 0)?' AND ':''; $sql .= $pre.$key." = '".$value."'"; $i++; } } if(array_key_exists("order_by",$conditions)){ $sql .= ' ORDER BY '.$conditions['order_by']; } if(array_key_exists("start",$conditions) && array_key_exists("limit",$conditions)){ $sql .= ' LIMIT '.$conditions['start'].','.$conditions['limit']; }elseif(!array_key_exists("start",$conditions) && array_key_exists("limit",$conditions)){ $sql .= ' LIMIT '.$conditions['limit']; } $result = $mysqli_obj->query($sql); if(array_key_exists("return_type",$conditions) && $conditions['return_type'] != 'all'){ switch($conditions['return_type']){ case 'count': $data = $result->num_rows; break; case 'single': $data = $result->fetch_assoc(); break; default: $data = ''; } }else{ if($result->num_rows > 0){ while($row = $result->fetch_assoc()){ $data[] = $row; } } } return !empty($data)?$data:false; } ?> <?php $tbl_name = 'rss2_podcast_item'; $conditions = []; print_r(getRows($mysqli_obj,$tbl_name,$conditions)); ?> Please find above two sets of code and a quoted error message from the first set. The first set of code is a portion of a PHP class called DB. The second set of code is extracted from the first and modified in order to test the integrity of the function. At the bottom of each block of code is included the code necessary to call the getRows() method/function. Whereas the method of the class fails, the extracted function does not. In both cases the same database and table are accessed with success. I am suspicious of the way in which the class is constructed. I have tried several modifications, but none of them appear to work. Roddy
  13. darbok

    connecting to msqli

    Looking at how form items are put into a mysql table, the part that seems daunting is if ones form has like 50 items... having to list all those IDs with their variables makes me wonder if there is a better way or if its just " it up buttercup.".
  14. Hello. I'd like to request a little guidance with regards forms and updating a database table please. I've created a form which has a dropdown list. I'd just like to enquire:- 1. How do I pass the selected result from the dropdown list to a variable? (at present I've written:- $user_gender = $_POST["profile_gender"] 2. I'm unable to update the database table. The database opens and there's no errors reported. I'd just like to ask the following looks ok? $sql = "UPDATE registration_table SET Gender='$user_gender' WHERE Member_id='$userID'"; Thank You.
  15. I don't know how to use "mysqli_result()" function, with general arguments. In "mysql_result()" function, it was like this :- "mysql_result($query, 'row', 'feild')". Here First argument is the "query", Second argument is the specific "row" in the database, Third argument is the "field name" of the row. I don't know if the arguments are same for "mysqli_result()" or not, or maybe more arguments are included or excluded!!!! Hey, I noticed the same question has been asked by so many different members!! in the Forum. Focusing to different use. But one more thing I noticed that the actual implementation is not here, Like "mysqli_result('argument1', 'argument2', 'argument3');". Basically the implementation is quite simple, but heres the confusion thing, and thats the correct arguments, as I've show in most upper example!!?
  16. Hi guys! I have a little problem and it's that I get an error in a determined function where I call my connection and I don't know why. The errors are: 1) Notice: Undefined variable: conexionidiomas in C:\wamp64\www\idiomas\preguntas-frecuentes.php on line 10 2) Warning: mysqli_real_escape_string() expects parameter 1 to be mysqli, null given in C:\wamp64\www\idiomas\preguntas-frecuentes.php on line 11 This is what I have from "/Connections/conexionidiomas.php": # FileName="Connection_php_mysql.htm" # Type="MYSQL" # HTTP="true" $hostname_conexionidiomas = "p:localhost:3307"; $database_conexionidiomas = "idiomasbd"; $username_conexionidiomas = "root"; $password_conexionidiomas = "asdasdf"; $conexionidiomas = mysqli_connect($hostname_conexionidiomas, $username_conexionidiomas, $password_conexionidiomas, $database_conexionidiomas); and this in "preguntas-frecuentes.php": <?php require_once('Connections/conexionidiomas.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysqli_real_escape_string") ? mysqli_real_escape_string($conexionidiomas, $theValue) : mysqli_escape_string($conexionidiomas,$theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO tblfrecuentes (strPregunta,fchFecha) VALUES (%s,NOW())",GetSQLValueString($_POST['strPregunta'], "text")); $Result1 = mysqli_query($conexionidiomas,$insertSQL) or die(mysqli_error($conexionidiomas)); } ?> So, if someone could help me I'd appreciate it so much. Regards!
  17. I want to convert an existing site to use prepared statements. This will be much easier if I can get the result of a SELECT query as an array to replace the array returned by mysqli_fetch_array. I am using PHP 5.4 with mysqlnd activated and should be able to use mysqli_stmt_get_result(stmt) to get such an array. But that function does not work and does not seem to be available at all. But all the documentation I'be read says it should be available in PHP 5.4. $query = "SELECT col1 FROM contactinfo WHERE col2 = ? && col3 = ? && (col4 = ? || col5 = ?) "; $stmt = mysqli_prepare($connect, $query); mysqli_stmt_bind_param($stmt, "ssss", $var1, $var2, $var3, $var4); mysqli_stmt_execute($stmt); $row = mysqli_stmt_get_result(stmt); $newvar = $row[0]; The actual query is much longer but this is the form. If I can't use mysqli_stmt_get_result, I'll probably abandon the transition. Can someone offer advice on my next move?
  18. Hi, I'm currently experiencing difficulties updating the database. I'm currently creating a 'Forgotten Password' feature. I've finished most of it, however when I attempt to update the database with a new password, nothing happens and the old password remains in the database. I've followed W3Schools example but I'm stuck. --------- The new password is generated by numbers 4 in total, ie $new_pass = (rand(1000,9999); and from the form I've used $user_email= $_POST["retrieve_email"]; then I use the line sql = "UPDATE registration SET Password=$new_pass WHERE Email=$user_email"; I can't get it to work, and I don't know why. Could anyone please write the code I need to make it work, or let me know how to proceed? Thank You. ps. I thought about deleting the entry and re-inserting it. Would that work (out of interest)?
  19. I made a set up for showing tables with a php script. Its based on a script from w3schools. // make connection with localhost $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } // script calling to connect with dbase function write_content () { // reading the tables from the dbase $sql = "SHOW TABLES"; // show tables $result = $conn->query($sql); while ($row = $result->fetch_assoc()) { echo current($row) . '<br/>'; } $conn->close(); return; } echo "<br><br><br>"; echo "The following tables are found in the database " ; echo write_content (); The problem is that conn is a not defined variable.though it worked in a condition with if. Then a second error message is given sounding: Fatal error: Call to a member function query() on a non-object in ..... these errors concern this line: $result = $conn->query($sql);
  20. Hello, i am having issues adding info to a database i have a html from where a user should fill in charname and select ###### then press submit. if i do this i get the error ERROR:could not able to execute INSERT INTO character(charname, ######, xp, gold, accdate) VALUES(jay, male, 0, 100000, now()).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 'character(charname, ######, xp, gold, accdate) VALUES(jay, male, 0, 100000, now())' at line 1 <?php include_once 'db_connect.php'; include_once 'psl-config.php'; $error_msg = ""; $now = time(); // check connection if($mysqli === false){ die("ERROR: Could not connect. " . mysqli_connect_error()); } // Escape user inputs for security $charname = mysqli_real_escape_string($mysqli, $_POST['charname']); $###### = mysqli_real_escape_string($mysqli, $_POST['######']); //attempt inser quesry execution $sql = "INSERT INTO character (charname, ######, gold, xp, accdate) VALUES ($charname, $######, 100000, 0, now())"; if(mysqli_query($mysqli, $sql)){ echo "Records added successfully."; } else{ echo " ERROR:could not able to execute $sql." .mysqli_error($mysqli); } // close connection mysqli_close($mysqli); ?> Table CREATE TABLE IF NOT EXISTS `character` ( `id` int(11) NOT NULL AUTO_INCREMENT, `charname` varchar(30) NOT NULL, `######` tinyint(4) NOT NULL, `gold` int(11) NOT NULL, `xp` int(11) NOT NULL, `accdate` timestamp NOT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; I was wondering if some one could explain me what i do wrong, and or have some tips how to make this better. the idea is to add a check to see in the "charname" is already used. and some other stuff. but first i like to see the info end up in my DB Thanks
  21. Hope you can help. I'm trying to install vtiger 6.2.0 on windows 8.1 - during the installation wizard there is the part with the required values testing. In this part everything is set to "yes" except mysqli support that appear as "no" under the present value. In the PHP.ini in C:Program Files (x86)vtigerCRM620php under Dynamic Extensions the line extension=php_mysqli.dll is without ; before it. in the PHP.ini in C:Program Files (x86)vtigerCRM620apachehtdocsvtigerCRMpkgphp under Dynamic Extensions there is no extension=php_mysqli.dll so I added it to the end of the column. Still the mysqli support appears as "no" under the present value. By the way - I don't have a section marked [php_MYSQLI] in my PHP.ini files - the only place that have something to do with php_mysqli.dll is in the ;;;;;;;;;;;;;;;;;;;;;; ; Dynamic Extensions ; section. ;;;;;;;;;;;;;;;;;;;;;; what should I do? By the way (2) - the Required Value of PHP Version is 5.5.0 and the Present Value is 5.3.10 (this is the php that comes with the vtiger installation EXE file). I wonder if 5.5.0 is the required value of PHP - why the exe install 5.3.10? Thanks for your help! Ram
  22. Hello all. I have come here to the source of web standards to understand PHP and the API's it uses to access databases. From my reading (why yes, I do know how to use google ) it seems both MySQLi and PDO are acceptable methods. Other than the boatload of "experts" on various forums and blogs shouting that MySQLi is depreciated, is there any real indication that it is? Now I don't want to start a MySQLi Vs PDO thread. I just want to know if MySQLi is still an acceptable API to use
  23. hello everyone..how do i code PDO for this script...please help me <?php if (isset($_POST['Login'])){ $UserName=$_POST['UserName']; $Password=$_POST['Password']; $hostname = 'localhost'; $username = 'root'; $password = ''; $database_name = 'ovs'; $mysqli = new mysqli($hostname, $username,$password, $database_name); $login_query=mysqli_query($mysqli,"select * from voters where Username='$UserName' and Password='$Password' and Status='Unvoted' and Year='1st year'") or die(mysqli_error()); $login_query1=mysqli_query($mysqli,"select * from voters where Username='$UserName' and Password='$Password' and Status='Voted'"); $count=mysqli_num_rows($login_query); $count1=mysqli_num_rows($login_query1); $row=mysqli_fetch_assoc($login_query); $id=$row['VoterID']; ?>index.php
  24. I have many select insert update query , i have written transaction query but want to know if its safe or some need to be corrected. Also if all is ok i should get successful "Transaction completed successfully!" , but if something get wrong then error message showed be seen and ROLLBACK should be done , but its NOT .... not rollback is done Below is what I have tried. Please let me know if something is wrong: function autocommitfalse(){global $db;return mysqli_autocommit($db, FALSE);}function autocommittrue(){global $db;return mysqli_autocommit($db, TRUE);}function commitquery(){global $db;return mysqli_commit($db);}function rollbackedquery(){global $db;return mysqli_rollback($db);} =============================================================================== try {global $db;autocommitfalse();-----------------$SQLSELECT = "SELECT * FROM BC ";$result_as = mysqli_query($db,$SQLSELECT);$rsfetch = mysql_fetch_array($result_as);if(!$result_as ){throw new Exception('Wrong SQL SELECT: ' . $SQLSELECT. ' Error: '.db_error_msg($db) . db_error_no());}-----------------$sqla ="INSERT INTO A (sd) VALUES ('df') where id=".$rsfetch['dh'];$result_a = mysqli_query($db,$sqla);if(!$result_a){throw new Exception('Wrong SQL SELECT: ' . $result_a. ' Error: '.db_error_msg($db) . db_error_no());}-----------------$sqlb ="INSERT INTO B (sdds) VALUES ('trtrt') where id=".$rsfetch['dh'];$result_b =mysqli_query($db,$sqlb);if(!$result_{throw new Exception('Wrong SQL SELECT: ' . $result_a. ' Error: '.db_error_msg($db) . db_error_no());}-----------------$a = mysqli_insert_id($db);-----------------$sqlCb ="UPDATE CB SET A ='NM' where id=".$a ;$result_Cb = mysqli_query($db,$sqlCb);if($result_Cb === false || mysqli_affected_rows($db) == 0 ){throw new Exception('Wrong SQL SELECT: ' . $result_a. ' Error: '.db_error_msg($db) . db_error_no());}-----------------commitquery();echo 'Transaction completed successfully!';} catch (Exception $e) {echo"<br >";echo "<table align=center><tr><td>";echo $e->getMessage();echo "</td></tr></table>";echo"<br >";echo display_error(_("Transaction failed: transaction rolled back"));rollbackedquery();}autocommittrue(); Please let me know its correct or not , if need to correct then what , as still not rollbacked with above code..
  25. etsted

    error

    this script keep returning warning mysqli_num_rows expect paramter 1 to be a result boolean given. Why? <html> <body> <h1>search engine</h1> <form action="search.php" method="get"> <input type="text" name="k" size='50' /> <input type="submit" name="submit" value='Search' /> </form> <hr /> <?php include "connect.php"; $k = $_GET['k']; $terms = explode(".", $k); $query = "SELECT * FROM users WHERE "; foreach($terms as $each) { $i++; if($i == 1) { $query .= "keywords LIKE '%$each%' "; } else { $query .= "OR keywords LIKE '%$each%' "; } } $query = mysqli_query($con, $query); $numrows = mysqli_num_rows($query); if($numrows > 0) { while($row = mysqli_fetch_array($query)) { $id = $row['id']; $title = $row['title']; $description = $row['description']; $keywords = $row['keywords']; $link = $row['link']; if($k == "") { echo ""; } else { echo "<h2><a href='$link'>$title</a></h2> $description"; } } } else { echo "no result on $k"; } ?> </body> </html>
×
×
  • Create New...