|
i do this code in my application android
if(result.equalsIgnoreCase("true"))
{
Intent intent2 = new Intent(MainActivity.this,Main2Activity.class);
startActivity(intent2);
MainActivity.this.finish();
}else if (result.equalsIgnoreCase("false")){
Toast.makeText(MainActivity.this, "nom utilisateurs ou mot de passe incorrect", Toast.LENGTH_LONG).show();
all the time php return the result false and show me the message "nom utilisateurs ou mot de passe incorrect"
|
|
|
|
|
Check the status of all mysql calls and return an error message if a call failed. Then show that error message within your application.
Only then you will know what is happening.
|
|
|
|
|
Programming buddies,
I'm back online after nearly 2wks of offline. Gonna be harassing you guys again and more this time. Eeek!
Anyway, right now, I'm trying to build a script that adds multi entries into same single cell or mysql row.
The script tries monitoring what you are browsing via the:
<pre><input type="text" name="browse_url" size="120">
and then record your viewed urls into the same row (position: 0), column: browsings like so:
1.com,2.com and so on.
So, at first, the mysql array or cell is blank. When you view a url (eg.) 1.com then the array would show like this:
1.com
And then afterwards, if you view facebook.com then the cell should get updated by first grabbing the previously viewed urls and then adding the latest url onto the same cell/array like so (each url separated by comma):
1.com,facebook.com
Throw your precious eyes on line 79 onwards on both sample scripts. I reckon the 1st script is no good but the 2nd should work. Gave you both scripts to show the variety of ways I attempted.
Sample 1:
[php]
<?php
session_start();
require "conn.php";
require "site_details.php";
if(!isset($_SESSION["user"]))
{
header("location:login.php");
}
else
{
$user = $_SESSION["user"];
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Browse!</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<p>
<p>
<p>
<?php
?>
<iframe src='<?php echo $db_latest_view;?>'></iframe>
<p>
<p>
<p>
<form method="post" action="">
<table border="1" width="50%">
<tr>
<td width="10">Url: </td>
<td><input type="text" name="browse_url" size="120"></td>
</tr>
<tr>
<td width="10">Browse: </td>
<td>
<select name="browsing_type">
<OPTION>Anonymous Browsing</OPTION>
<OPTION>Group Browsing</OPTION>
</SELECT>
</td>
</tr>
<td></td>
<td><input type="submit" name="browse" size="50" value="Browse"><input type="submit" name="search_keywords" size="50" value="Search Keywords"></td>
<tr>
<td width="10">Message: </td><td><textarea name="message" cols="120" rows="10"></textarea></td>
</tr>
<tr>
<td></td>
<td width="50"><input type="submit" name="submit_message" size="50" value="Send Message!"></td>
</tr>
<p>
<p>
</table>
</form>
<?php
if(isset($_REQUEST['browse']))
{
$browse_url = trim(strip_tags(strtolower(mysqli_real_escape_string($conn,$_POST["browse_url"]))));
$browsing_type = trim(strip_tags(strtolower(mysqli_real_escape_string($conn,$_POST["browsing_type"]))));
$sql = "SELECT * FROM users WHERE usernames = '".$user."'";
$result = mysqli_query($conn,$sql);
$numrows = mysqli_num_rows($result);
if($numrows)
{
while($row = mysqli_fetch_assoc($result))
{
$db_user_browsings = $row["browsings"];
}
$sql = "INSERT INTO users(browsings) VALUES('".$browse_url."''".$db_user_browsings."')";
$result = mysqli_query($conn,$sql);
if($sql)
{
echo "true";
}
$sql = "UPDATE users SET browsings_latest = '".$browse_url."' WHERE usernames = '".$user."'";
$result = mysqli_query($conn,$sql);
if($sql)
{
echo "true";
}
}
}
}
?>
[/php]
Sample 2
[php]
<?php
session_start();
require "conn.php";
require "site_details.php";
if(!isset($_SESSION["user"]))
{
header("location:login.php");
}
else
{
$user = $_SESSION["user"];
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Browse!</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<p>
<p>
<p>
<?php
?>
<iframe src='<?php echo $db_latest_view;?>'></iframe>
<p>
<p>
<p>
<form method="post" action="">
<table border="1" width="50%">
<tr>
<td width="10">Url: </td>
<td><input type="text" name="browse_url" size="120"></td>
</tr>
<tr>
<td width="10">Browse: </td>
<td>
<select name="browsing_type">
<OPTION>Anonymous Browsing</OPTION>
<OPTION>Group Browsing</OPTION>
</SELECT>
</td>
</tr>
<td></td>
<td><input type="submit" name="browse" size="50" value="Browse"><input type="submit" name="search_keywords" size="50" value="Search Keywords"></td>
<tr>
<td width="10">Message: </td><td><textarea name="message" cols="120" rows="10"></textarea></td>
</tr>
<tr>
<td></td>
<td width="50"><input type="submit" name="submit_message" size="50" value="Send Message!"></td>
</tr>
<p>
<p>
</table>
</form>
<?php
if(isset($_REQUEST['browse']))
{
$browse_url = trim(strip_tags(strtolower(mysqli_real_escape_string($conn,$_POST["browse_url"]))));
$browsing_type = trim(strip_tags(strtolower(mysqli_real_escape_string($conn,$_POST["browsing_type"]))));
$sql = "SELECT * FROM users WHERE usernames = '".$user."'";
$result = mysqli_query($conn,$sql);
$numrows = mysqli_num_rows($result);
if($numrows)
{
while($row = mysqli_fetch_assoc($result))
{
$db_user_browsings = $row["browsings"];
}
$sql = "UPDATE users SET browsings = '".$browse_url."''".$db_user_browsings."' WHERE usernames = '".$user."'";
$result = mysqli_query($conn,$sql);
if($sql)
{
echo "true";
}
$sql = "UPDATE users SET browsings_latest = '".$browse_url."' WHERE usernames = '".$user."'";
$result = mysqli_query($conn,$sql);
if($sql)
{
echo "true";
}
}
}
}
?>
[/php]
|
|
|
|
|
You appear to be spamming because you are posting "weird" statements without asking questions. Shape up or get shipped out.
There are two kinds of people in the world: those who can extrapolate from incomplete data.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Please allow me to trouble you one more time.
I got my html working great - thanks in large part to Richard Deeming.
I successfully converted it to php.
I created a template in wordpress called Contact and uploaded it to my wordpress theme.
The name of the theme is Responsive.
The issue now is that I cannot upload the php with the libraries in it. These libraries and their accompanying CSS, as I understand, will need to uploaded to separate directories and then invoked somewhere.
I am not getting clear instructions on how to tie these to my template.
These libraries and inline css are:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.0.6/handlebars.min.js"></script>
<style type="text/css">
.bs-example{
margin-left: 250px;
margin-top: 30px;
}
</style>
Can someone please give me directions as to where to put these?
As I understand it, they can either go to header.php or functions.php.
But how do I use these libraries?
Sorry I realized I didn't give all the useful information.
I have three libraries, the AngularJS handlebags, bootstrap and jquery libraries.
I uploaded those to the theme's js directory.
Then on header.php, I added the following just below the header hook
<?php responsive_in_header(); ?>
//get the js and jquery frameworks
<?php if( is_page(Contact) ){ ?>
<script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/js/jquery.min.js.js"></script>
<script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/js/bootstrap.min.js"></script>
<script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/js/handlebars.min.js"></script>
<script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/js/addrows.js"></script>
<?php }?>
When I tested the page, it is not doing what it is doing my local PC.
modified 17-Feb-17 14:37pm.
|
|
|
|
|
I have users and categories tables and pivot table categorie_users in database. In controller I make that every user can create your own categories and I make check if some category exist and if logged user have that category, he can't create new category with same name and that works fine. So next what I want is 'else' - if category exist and logged user don't have that category but he want to create it - in that case I want to connect that category which already exist and that user. Other words - I want to, let's say, category 'Music' to be just one category with that name for all future users. This is so complicated so any suggestions will appreciate. Thanks.
This is my CategoriesController.php
public function store(Request $request)
{
$user = Sentinel::getUser();
$category = Categories::where('name', $request->name)->get();
foreach ($category as $cat){
$user = CategorieUser::where('categorie_id',$cat->id)->where('user_id', $user->id);
}
if($category->count() > 0){
if($user->count() > 0){
return redirect()->route('categories.index');
}
else{
/*THIS IS THAT 'else' FROM ABOVE QUESTION*/
}
}
else{
$categories = new Categories();
$categories->name = $request->name;
$categories->sections_id = $request->sections_id;
$categories->save();
$categories->users()->sync([$user->id]);
}
session()->flash('success', "New category '{$categories->name}' has been created.");
return redirect()->route('categories.index');
}
And this is my model Categories.php
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Categories extends Model
{
protected $table = 'categories';
public function sections()
{
return $this->belongsTo('App\Models\Sections');
}
public function users()
{
return $this->belongsToMany('App\Models\Users', 'categorie_user','categorie_id','user_id');
}
}
This is model Users.php
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Users extends Model
{
protected $table = 'users';
public function categories()
{
return $this->belongsToMany('App\Models\Categories', 'categorie_user','user_id','categorie_id');
}
}
And this is pivot model CategorieUser.php (which I must create that I can go through foreach loop)
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class CategorieUser extends Model
{
protected $table = 'categorie_user';
public function categories(){
return $this->belongsTo('App\Models\Categories', 'categorie_id');
}
}
|
|
|
|
|
Yes, we understand that you need to setup the relationships between the user and categories. But what is the problem? Did you try anything that does this?
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
Hi,
I'm a newbie in OOP. Can you please help me how to fix this code below because it gives me an infinite output. I want to output or echo my fetched data to my main program. Thanks.
===========================================
class DB {
private $_hostdb = 'localhost';
private $_namedb = 'imsdb';
private $_userdb = 'root';
private $_passdb = '';
private $_conn;
private static $_instance;
private $_rowResult;
private function __construct(){
try{
$this->_conn=new PDO("mysql:host=$this->_hostdb;dbname=$this->_namedb",$this->_userdb,$this->_passdb);
$this->_conn->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
if($this->_conn){
echo "Connected Successfully! ";
}
} catch (Exception $ex) {
echo ("Connection Failed!")." ".$ex->getMessage();
}
}
public static function getInstance(){
if(!isset(self::$_instance))
{
return self::$_instance=new DB();
}
}
public function processQuery($sql){
try{
$q=$this->_conn->prepare($sql);
$q->execute();
$q->setFetchMode(PDO::FETCH_ASSOC);
return $this->_rowResult=$q->fetch(); //Is this correct??
} catch (Exception $ex) {
echo ("Failed!")." ".$ex->getMessage();
}
}
}
//MAIN PROGRAM -> OUTPUT gives me an infinite data which is wrong
$dbUser=DB::getInstance()->processQuery("SELECT * FROM users");
while($dbUser){
echo $dbUser['username'];
}
|
|
|
|
|
while($dbUser){
echo $dbUser['username'];
}
The while statement will repeat as long as the value in $dbUser is not null. So in your case it will continue until the end of time.
|
|
|
|
|
Hi sorry I am just a baby in PHP. I want to get the value of $_SESSION['username'] but it gives me this error : Notice: Undefined offset: 0. Please see my code below. Your help will be greatly appreciated. Thanks.
";
echo $_SESSION[0]; //I want an output "andrew" but it fails.
|
|
|
|
|
$_SESSION (see PHP: $_SESSION - Manual[^] ) is an associative array containing key value pairs (see PHP: Arrays - Manual[^]).
These are not accessed by an index but by their keys which might be integers or strings. Because you have not assigned a value with the key '0' you will get the error.
Just use the key instead:
echo $_SESSION['username'];
|
|
|
|
|
|
Hi all,
I got a problem
I used CentOS 7.1,
used command: yum -y install httpd to install apahce
used command: yum -y install php to install php
noting to change the configure file /etc/httpd/conf/httpd.conf
and then I have done this two things in /var/www/html/:
1. ln -s /home/ninja/workspace/storage .
2. create a test file test.php
[root@localhost html]# pwd
/var/www/html
[root@localhost html]# ls
storage test.php
[root@localhost html]# ll
total 4
lrwxrwxrwx 1 root root 29 Dec 28 20:05 storage -> /home/ninja/workspace/storage
-rwxr-xr-x 1 root root 122 Dec 28 20:04 test.php
[root@localhost html]# cat test.php
<?php
echo "====================\n";
$data = file_get_contents("./storage/8010252");
echo "get data";
echo $data;
?>
the file 8010252 does really there, but php can not access.
the apache error log shows:
[Wed Dec 28 20:06:46.858835 2016] [:error] [pid 8605] [client 192.168.3.57:26918] PHP Warning: file_get_contents(./storage/8010252): failed to open stream: No such file or directory in /var/www/html/test.php on line 4
If I don't use Symbolink, it works, it seems like apache can not access the Symbolink folder.
Anyone can help, Thanks a lot.
Solution:
To solve this problem, I just run the command:
chmod -R +x /home/ninja
and then it works!
modified 28-Dec-16 21:15pm.
|
|
|
|
|
I got the following error trying to install a package error while loading shared libraries libio_misc.so
I am not familiar with Linux would anyone know what this means
|
|
|
|
|
The message tells you it had trouble loading a .so file (a shared object file, similar to a .dll in Windows). However with that little detail it is anyone's guess what the actual problem is.
|
|
|
|
|
I was trying to install IBM zpdt package or rather executing a command I am wondering just as in the case of Windows DLL if I google the name can I some how download it ?
|
|
|
|
|
Possibly, but you will need to first find out why it failed before.
|
|
|
|
|
Probably couldn't find the library. First, search your system to see if you have that library (look in /usr/lib, /usr/local/lib, or multiarch lib paths[^] if Suse supports them), if you don't find it do an online search to see what package that library is a part of and install that package.
If you find the library in your system already but you're still getting an error, it's also possible that whatever you're running is looking in the wrong location or under the wrong name. For example, if it's looking for libio_misc.so but your system has libio_misc.1.2.0.so (in which case, you just need a symbolic link). If the shared object file is in a non-standard location and you want to add search paths to the loader, you just have to define or add to the LD_LIBRARY_PATH environment variable.
|
|
|
|
|
Hi, I am basically a software developer looking for a laravel based admin template with all the Advanced functionalities which can save my tons of hours of production so that i can develop my projects at a quicker pace,can anyone please suggest me regarding this?
|
|
|
|
|
|
Hi all,
It's a Nginx and PHP web project, When I run a php script as shell, there shows Access Denide!
X-Powered-By: PHP/7.0.9
Content-type: text/html; charset=UTF-8
Access Denied!
The php file is like this:
#!/usr/bin/php-cgi
<?php
require_once("config.php");
require_once("util.php");
...
..
.
file_put_contents($argv[1], CJSON::encode($obj));
?>
I have try to change all the php file as 777, and try to run like this:
./list.php /home/cache.json
/usr/bin/php list.phph /home/cache.json
Still can not work.
and then I try to make a new php script test.php:
#! /usr/local/php7/bin/php-cgi
<?php
echo "php test";
?>
and then run it:
/usr/local/php7/bin/php-cgi test.php
it works:
[root@localhost ~]# /usr/local/php7/bin/php-cgi test.php
X-Powered-By: PHP/7.0.9
Content-type: text/html; charset=UTF-8
php test
I don't now why, anyone can help? Thanks for advance.
|
|
|
|
|
I think your path to the output file may be wrong. The directory /home is a system directory that contains the user home directories, one for each user. The command ls -l /home will show you what it is and what permissions it has.
Try just:
./list.php cache.json
// or
./list.php ~/cache.json
|
|
|
|
|
hello all,
i am having this issue with trying to connect my php app to sql server and i have edited the php.ini with the required driver needed to the php version 5.5. Below is the error i get anytime i try to connect to the database, i will appreciate if anybody will help with this.
Database connection refused.
Array ( [0] => Array ( [0] => IMSSP [SQLSTATE] => IMSSP [1] => -49 [code] => -49 [2] => This extension requires the ODBC Driver 11 for SQL Server. Access the following URL to download the ODBC Driver 11 for SQL Server for x86: http://go.microsoft.com/fwlink/?LinkId=163712 [message] => This extension requires the ODBC Driver 11 for SQL Server. Access the following URL to download the ODBC Driver 11 for SQL Server for x86: http://go.microsoft.com/fwlink/?LinkId=163712 ) [1] => Array ( [0] => IM002 [SQLSTATE] => IM002 [1] => 0 [code] => 0 [2] => [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified [message] => [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified ) )
"
|
|
|
|
|
What part of those instructions are you having a problem with?
|
|
|
|
|
I did the connection from the php using these lines of code "
$serverName = "(THAIWO)";
$connectionInfo = array("Database"=>"examples");
$conn = sqlsrv_connect($serverName,$connectionInfo);
if ($conn){
echo ("Database connection Successful.<br />") ;
}else
{
echo ("Database connection refused.<br />") ;
die(print_r(sqlsrv_errors(), true));
}
"
i did download for
php_pdo_sqlsrv_55_ts.dll
php_pdo_sqlsrv_55_nts.dll
php_sqlsrv_55_ts.dll ,
php_sqlsrv_55_nts.dll
with all these done and checking for solution in the MSDN libary where i used the PDO syntax for connecting to sql server using the function sqlsrv_connect, am still at lost for where am doing things wrong. I want to know why i am refused and the reason for asking for the ODBC driver when i have downloaded and enabled it.
|
|
|
|