
fluidsharp
Members-
Posts
39 -
Joined
-
Last visited
Everything posted by fluidsharp
-
Hi, How to block access to http://domain.com/admin/main/ admin panel via htaccess ? I tried like below, but it is not working. RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule .* index.php?/$0 [PT,L] RewriteCond %{REMOTE_ADDR} ^1\.1\.1\.1$ RewriteRule /admin/main [F,L]
-
Hi, I have issue with deleting data via jquery/ajax. First delete execute and data on page changed. But then when I click on next element for deleting, nothing happens. To avoid complicated code I wrote simple example which demonstrate issue. Controller function test_contr(){ $this->load->model('admin/Product_crud'); $data['query']=$this->Product_crud->test_model_select_data(); $this->load->view('admin/test',$data); } function test_delete($id){ $output = NULL; //var_dump($id); $this->load->model('admin/Product_crud'); $this->Product_crud->test_delete($id); $data['query']=$this->Product_crud->test_model_select_data(); foreach($data['query'] as $row){ $output .= $row->id."<input class='del_picture' type='button' value='".$row->id."' name='id'>"; } echo json_encode($output); } Model not needed as there simple select id from database and delete View <!DOCTYPE html> <html> <head> <META http-equiv="Content-Type" content="text/html; charset=utf-8"> <script src="/script/jquery-1.9.1.min.js"></script> </head> <body> <div class="result_table"> <?php foreach ($query as $row){ echo $row->id."<input class='del_picture' type='button' value='".$row->id."' name='id'>"; } ?> </div> </body> </html> <script> $(".del_picture").on("click", function(){ var id = $(this).attr("value"); var myurl = '<?php echo base_url()."admin/main/test_delete/"?>'; var url = myurl + id; $.ajax({ url: url, type:'GET', dataType: 'json', success: function(update_html){ $(".result_table").html(update_html); } }); }); </script>
-
Structure for outputing "News" from two tables
fluidsharp replied to fluidsharp's topic in MySQL Help
I mean identical by structure(fields) but not by data. Table record will contain an info about recorded interview, short description, etc. And table article of course contains articles and additional info. -
Hi all, I have two tables: article and records (haven't create but will be same as article) article: +-------------+------------- ----+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------+------------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | title | varchar(255) | NO | | NULL | | | description | text | NO | | NULL | | | article | text | NO | | NULL | | | review | int(11) | NO | | NULL | | | author | varchar(255) | YES | | NULL | | | date | date | NO | | NULL | | So I must output data (news) from both tables and result should be ordered by date. First idea putted all in one table but it is so stupid. Second is creating some intermediary table but how I haven't imagined yet. Thank you in advance!
-
true, i missed this originally, in order for the mail function to work, a from header must be specified, either in the header parameter or in the php.ini file. Your first step will be to add that to the function it helped thanks! but why it works on an another server?
-
error.log I didn't find. But example from http://php.net/manual/en/function.mail.php (Example #4 Sending HTML email) works. I think if I change $message = $clientMessage; to $message = "Test"; it will work. I will check. PS $clientMessage gets data from POST <textarea>.
-
Hi all, I cannot send mail from one paid hosting, but from another I can (it is some free hosting) How to debug or find out why it doesn't send mails? <?php error_reporting(E_ALL); if (isset($clientName) && isset($clientEmail) && isset($clientMessage)) { $to = "[email protected]";//. ", "; //$to .= "[email protected]"; $subject = "test mail from site"; $message = $clientMessage; $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; $l = mail($to, $subject, $message, $headers); if ($l){echo "true";}else echo "false"; echo $l."<h3>Mail was sent</H3>"; print_r(error_get_last()); error_log("error ", 1,"[email protected]"); } ?> Thank you in advance!
-
Thanks!
-
I ask support, here is answer: Thank you for contacting us. Unfortunately the PEAR package is not installed and cannot be installed on the shared hosting environment.
-
Hi all! I have installed PEAR, mail and sendmail on localhost and everything works fine and I was so happy. But when I moved code to server I found out that I cannot use PEAR there. Could you give me advice ? What php function I should use to write own script to send mail via SMTP? Thank you in advice.
-
I've read it before posting, but not all was clear for me. I moved code from add_formats.php to adminka_wrapp.php and it works on remote server. Is there others ways to solve this issue? Thanks.
-
Hi all, I have two issue with script. 1. It works in PhpEd and with apache but doesn't work at remote server with apache. Error is well known - "Warning: Cannot modify header information - headers already sent " 2. when I added more than 20 records like $var = $_POST['var']; it stops work local. Error is same. adminka_wrapp.php <?php $addFormatName = $_POST['addFormatName']; $addFormatDes = $_POST['addFormatDes']; $page = $_GET['page']; if (isset($addFormatName) && isset($addFormatDes)) { $page = 'add_formats'; } else if ($page == NULL) { $page = "user_access_log"; } ?> <!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> <link rel="stylesheet" type="text/css" href="../style/adminkaview.css"> </head> <body> <div class="col-wrap1"> <div class="col-wrap2"> <div class="col1"> <div class="content" id="c1"> <p><a href="?page=view_add_format">Format and extensions</a></p> </div> </div> <div class="col2"> <div class="content" id="c2"> <?php require("$page.php");?> </div> </div> <div class="clear"></div> </div> </div> </body> </html> view_add_format.php <?php require_once "../function.php"; $q = connect("SELECT `formats`.* FROM `xxx`.`formats` "); echo "<form method='post' action='adminka_wrapp.php'> <table> <tr> <td>id</td> <td>Formats Name</td> <td>Description</td> </tr>"; while($rowResult = $q->fetch_assoc()) { echo "<tr>"; $id = $rowResult["id"]; $formatName = $rowResult["f_name"]; $description = $rowResult["description"]; echo "<td>".$id."</td>" ."<td>".$formatName."</td>" ."<td>".$description."</td>"; echo "</tr>"; } echo " <tr> <td> <input type='submit' value='AddFormat' name='submitAddFormat'> </td> <td> <input type='text' name='addFormatName' maxlength='20' size='5'> </td> <td> <input type='text' name='addFormatDes' maxlength='20' size='5'> </td> "; echo "</table> </form>"; ?> add_formats.php <?php require "../function.php"; if (isset($addFormatName) && isset($addFormatDes) ) { $q = connect("INSERT INTO `xxx`.`formats` (`id` ,`f_name` ,`description` ) VALUE (NULL ,'$addFormatName' ,'$addFormatDes' ) "); header("Location: adminka_wrapp.php?page=view_add_format"); exit(); } ?> function.php <?php function connect($query) { $db = new mysqli('127.0.0.1', 'xxx', 'xxx', 'xxx'); if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } $result = $db->query($query); $db->close(); return $result; } ?>
-
Hi guys! Could you give me advice about this issue: index.php <?php $page = $_GET['page']; if ($page == NULL) { $page = "main"; } ?> <div>Header</div> <div> <?php require("view/$page.php");?> </div> <div>Footer</div> main.php <?php require "func.php"; ?> <form method="post" action="view/add.php"> <input type="text" name="from" value=""><br /> <input type="submit" value="Add"> </form> add.php <?php require "../func.php"; $from = $_POST['from']; $a = add($from); echo $a; ?> func.php <?php function add($a) { $c = $a+100; return $c; } ?> I need output result (echo $a) in new windows (target= _blank) and output must be same like with main.php. In other words content of add.php output in index.php This code is just simplified of real code. Thank you in advice
-
Hi, Thanks for reply. I wrote simple other code with has the same issue. I cannot interrupt executing code in result_found.php. Cannot run Stap Over (F8). It works only for index.php index.php: <?php some code ?> <form method="post" action="view/result_found.php"> Enter input format: <input type="text" name="from" value="" maxlength="5" size="30"> <input type="submit" value="Find enterd formats"> </form> result_found.php: <?php $a = $_POST['from']; echo $a; ?>
-
Hi everybody! Could you help me with debugging. Exactly from index.php I call result_found.php through <form method="post" action="view/result_found.php"> and cannot debug code in this file. When I've tried set up breakpoint it doesn't help. Just show me result of executing code in result_found.php Thank you in advance!
-
Condition for returned value after "SELECT" query using mysqli.
fluidsharp replied to fluidsharp's topic in PHP Coding Help
Thank you! -
Hello. After "SELECT" my $var is equal object(mysqli_result)#2 (0) { } and I done next: if (empty($var)) { I''ll fetch rows } else echo "Selected 0 rows"; It work but I want to know is this condition correct? Because I don't know exactly what does object(mysqli_result)#2 (0) { } it means. And how to watch what this object contain. Could you help? Thanks
-
I've founded solution. I should use multibyte string functions.
-
and substr(); gives same result
-
Hello guys! I don't understand why when I get Cyrillic character from string - happens smth. wrong. For example : $str = "МУГдй"; if I echo it all is good. But when I do it: $str1 = $str[2]; it will output Roman character or " in phpED and in firefox fffd. Thanks you in advance.
-
Thanks a lot! finally I got it. Huh
-
it is not important because it is just one way for access data in array - $selectResult and it don't influence on output this data: $selectResult contain this : Array ( [id] => 1 [name] => 1 [surname] => 1 [birthday] => 0001-01-01 00:00:00 [status] => married [gender] => male [phones] => 1 ) i'm just confused where are rest rows [id] => 2 ....etc. As you can see table has 5 rows, and I use SELECT * FROM.
-
fetch_assoc() returns an associative array yes it is but it has just only one record from DB(need 5 records) and it is problem. I don't know why
-
I have doing one task and saw that I don't get all selected lines from query. I've tried it simplified and result is same. [code] <?php echo "<pre>"; function connect($query) { $db = new mysqli('localhost', 'root', 'root', 'contact_books'); if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } $result = $db->query($query); $db->close(); return $result; } $q = connect("SELECT * FROM `contact_details`"); $selectResult = $q->fetch_assoc(); print_r($selectResult); ?> [/code] but .. mysql> SELECT * FROM contact_details; +----+-------+---------+---------------------+---------+--------+--------+ | id | name | surname | birthday | status | gender | phones | +----+-------+---------+---------------------+---------+--------+--------+ | 1 | 1 | 1 | 0001-01-01 00:00:00 | married | male | 1 | | 3 | 3 | 3 | 0003-03-03 00:00:00 | single | male | 3 | | 4 | 4 | 4 | 0004-04-04 00:00:00 | married | female | 4 | | 5 | trhtr | htrhtrh | 0005-05-05 00:00:00 | single | male | 55555 | +----+-------+---------+---------------------+---------+--------+--------+ PS. I've just work all night and closer to dinner this error have appeared.
-
Hello dear Please give me advise. I'm learning class and didn't understand how to get access to more then 1 properties of class. I'm using getter and setter method. abstract class father { protected $title; protected $result; } class connectDB extends father { protected $select; protected $i; function setQuery($query) { //something code //$resultFetch - is array, $i - quantity of iteration $this->select = $resultFetch; $this->i = $i; } function getQuery($select,$i) { return $this->select; return $this->i; } } $db = new connectDB(); $sel = "SELECT * FROM......etc"; $db->setQuery($sel); $get = $db->getQuery($selResult, $quantIter); // <- how to get both "$select" and "$i" I get value only from properties - "protected $select" to $get, but ($selResult, $quantIter) are = NULL How to get both values together ???