mysqli

CSV file from MySQL using PHP with a OOP aproach (mysqli->connect, etc.)

落爺英雄遲暮 提交于 2019-12-25 04:29:32
问题 I'm trying to create a csv file direct from a mysql table using php with an OOP approach. Here is my code: $mysqli = new mysqli($host, $user, $pass, $database); // Checking connection. if ($mysqli->connect_errno) { printf("Connect failed: %s\n", $mysqli->connect_error); exit(); } $query = 'SELECT * FROM table'; $result = $mysqli->query($query); while ($row = $result->fetch_array()) { $rows[] = $row; } $array = ""; foreach($rows as $row) { $array .= "\"".$row["genus"].",".$row["species"]."\","

page redirection in jquery

妖精的绣舞 提交于 2019-12-25 04:22:07
问题 I want to redirect the page after login succesfully completed. but the problem in this code is, if i give wrong input, it also go to home page. so i removed this statement 'window.location = home.php'. what could i do now? does anyone help me guys? <script> $(document).ready(function(){ $('#reg_form').parsley(); $('#reg_form').on('submit',function(event){ event.preventDefault(); if($('#reg_form').parsley().isValid()) { $.ajax({ url:"db.php", method:"POST", data:$(this).serialize(), beforeSend

page redirection in jquery

余生长醉 提交于 2019-12-25 04:22:07
问题 I want to redirect the page after login succesfully completed. but the problem in this code is, if i give wrong input, it also go to home page. so i removed this statement 'window.location = home.php'. what could i do now? does anyone help me guys? <script> $(document).ready(function(){ $('#reg_form').parsley(); $('#reg_form').on('submit',function(event){ event.preventDefault(); if($('#reg_form').parsley().isValid()) { $.ajax({ url:"db.php", method:"POST", data:$(this).serialize(), beforeSend

Can I mix MySQL APIs in PHP?

 ̄綄美尐妖づ 提交于 2019-12-25 04:21:55
问题 I have searched the net and so far what I have seen is that you can use mysql_ and mysqli_ together meaning: <?php $con=mysqli_connect("localhost", "root" ,"" ,"mysql"); if( mysqli_connect_errno( $con ) ) { echo "failed to connect"; }else{ echo "connected"; } mysql_close($con); echo "Done"; ?> or <?php $con=mysql_connect("localhost", "root" ,"" ,"mysql"); if( mysqli_connect_errno( $con ) ) { echo "failed to connect"; }else{ echo "connected"; } mysqli_close($con); echo "Done"; ?> Are valid but

inner join wont work with mysqli prepared statement in php

五迷三道 提交于 2019-12-25 04:14:18
问题 I can't seem to get this statement or statements alike to work with prepared queries, the code works just fine below: $DBH = getDBH(); $stmt = $DBH->prepare("SELECT a.id, a.title, a.photo FROM tag t INNER JOIN tag_reference atx ON t.tag_id = atx.tag_id INNER JOIN articles a ON atx.article_id = a.id WHERE t.tag_name = 'example'"); $stmt->execute(); $stmt->bind_result($id,$title,$photo); $stmt->fetch(); but when I change t.tag_name = '?' it gives me an error that the amount of parameters do not

Unable to retrieve image data from table and display image

北城以北 提交于 2019-12-25 02:57:16
问题 I'm trying to upload an image file to my database with PHP and MySQLi, but I'm coming across a very confusing piece of error. The table has two column, 'title' and 'image'. The 'title' is for the file's name and 'image' for the image data. both tables are NOT allowed to accept NULLs. When I upload a file, data is stored into the table columns. 'title' contains the right values, but the 'image' column contains ' <binary data> '. Since the table column does not accept NULL values I assumed that

mysqli_fetch_array(), prepared statement, and LIKE statement

家住魔仙堡 提交于 2019-12-25 02:56:02
问题 I'm trying to use mysqli prepared statements with a LIKE statement query and wildcard operators. After debugging be sprinkling echo statements throughout the code, I can see that my while statement is not executing. Can you see what I'm doing wrong here? This is my first time asking on this forum, so I apologize if this isn't a good question; I've spent 6 hours trying to get the prepared statement section of my code to work and I can't find any threads addressing my question that don't go

Trouble with mysqli

大兔子大兔子 提交于 2019-12-25 02:52:24
问题 I am new to mysqli functions . I have written a code to do the simple select functionality . Here is what I have done <?php #---- ini settings(ini)--- ini_set('display_errors', '1'); #---------(/ini)------------ #-------initialisations(init)--- $dbUser = 'myuser'; $dbPass = 'mypass'; $dbhost = 'localhost'; $dbname = 'mydb'; #------------(/init)------------ #---- database connection (db connect)----- $mysqli = new mysqli($dbhost, $dbUser, $dbPass, $dbname); $is_error = ($mysqli->connect_errno)

How to use AJAX to perform a MYSQLI query (prepared statement)

旧街凉风 提交于 2019-12-25 02:52:11
问题 So I have this (prepared statement) mysqli query in PHP (partial code): #New DB connection @ $mysqli = new mysqli ('localhost', 'user', 'password', 'database'); #Check DB connection, print error upon failure if (mysqli_connect_errno()) { printf("<p>Connect failed.</p> <p>Error: \"%s\"</p>\n", mysqli_connect_error()); exit(); } #if #Check if userName already exists $query = "SELECT * FROM users WHERE userName = ?"; $stmt = $mysqli->prepare($query); $stmt->bind_param("s", $registerUserName);

How do I reference table dot column notation in a MYSQLI query

淺唱寂寞╮ 提交于 2019-12-25 02:46:30
问题 SELECT * from meets LEFT JOIN teams as hteam on meets.meet_hometeam=hteam.team_id LEFT JOIN teams as ateam on meets.meet_awayteam=ateam.team_id LEFT JOIN teams as altloc on (meets.meet_altloc=altloc.team_id and meets.meet_altloc!='') where meet_date between ($now+(4*86400)) and ($now+(5*86400) or meets.meet_id='2') $var = $queryvar->fetch_object(); Thanks what I'm having issues with is when I call $var->ateam.team_town it is just treating the dot as a concatenation and not as an object to the