dimanche 19 avril 2015

php mysqli prepared statement: can't echo, print or get anything from var_dump AFTER execute command

I am starting to use mysqli and I got it working on my virtual server but can't get it working on my real server. The databases are the same. I have tried both store and get_result. Any idea what am I doing wrong?


Everything I try to echo, print or var_dump does not show up IF Place after execute but the command will be executed. It worked well on UPDATE and INSERT.



<?php

$mysqli = new mysqli("127.0.0.1", "user", "pass", "db", 3306);
if ($mysqli->connect_errno) {
echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}

echo $mysqli->host_info . "\n";

$sam = 1;


$stmt = $mysqli->prepare("SELECT released FROM svers");
$stmt->execute();
echo "#";
var_dump($sam);
$res = $stmt->get_result();

var_dump($res);

$row = $res->fetch_assoc();
var_dump($row);


$mysqli->close();


The host_info is displayed as "127.0.0.1 via TCP/IP" followed By the # I echoed inside the if() but can't get anything from my database. Even the other # between the $row[ ] info are not showing. Here is my code:



<?php

$mysqli = new mysqli("127.0.0.1", "user", "password", "database", 3306);
if ($mysqli->connect_errno) {
echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}

echo $mysqli->host_info . "\n";

$stmt = $mysqli->prepare("SELECT * FROM svers ORDER BY released DESC LIMIT 1");

if ($result = $stmt->execute()){
echo "#";
$result = $stmt->get_result();
$row = $result->fetch_array(MYSQLI_BOTH);
echo $row['version'] . "#" . $row['released'] . "#" . $row['note'];
$stmt->free_result();
}else {
echo "error";
}
$mysqli->close();
?>

Writing php for a database / web access [duplicate]


This question already has an answer here:




I have this code that I am trying to model from a previous class assignment. The very first part declares a short variable but I am not sure why it is not working. Any ideas?



<?php

if(isset($_POST['in_Person_id'])){ $in_Person_id = $_POST['in_Person_id']
?>

<html>
<head>
<title>Person_Select.php</title>
</head>
<body>

<h1>Guest System</h1>

<?php

@ $db = new mysqli('localhost', 'hrbailey' , 'hb1628', 'hrbailey');

if (mysqli_connect_errno())
{
echo 'Error: Could not connect to database. Please try again later.';
exit;
}

$query = "select * from person
where person_id = '$in_Person_id' ";
echo $query;

$result= @mysqli_query ($db, $query);

$num_results = mysqli_num_rows($result);

if ( $num_results == 0)
{
echo '<font color=red>';
echo 'No Person data found. <br />';
echo '</font>';
echo '<p><a href="Person_Menu.html">Return to Menu</a> </p>';
}
else
{
echo ' <br> <br> ';
echo 'Your search found ';
echo $num_results;
echo ' matches';
echo ' <br> <br> <br>';

//Build Table Header
echo'<table align="center" cellspacing="3" cellpadding="3" width="75%">
<tr>
<td align="left"> <b> Person_id </b> </td>
<td align="left"> <b> Last name </b> </td>
<td align="left"> <b> First Name </b> </td>
<td align="left"> <b> Street Address </b> </td>
<td align="left"> <b> City </b> </td>
<td align="left"> <b> State </b> </td>
<td align="left"> <b> Zip </b> </td>
<td align="left"> <b> RSVP </b> </td>
<td align="left"> <b> Hotel </b> </td>
<td align="left"> <b> Household </b> </td>
<td align="left"> <b> Gift </b> </td>
</tr>';

while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC))
{
echo '<tr>
<td align="left">' .$row['person_id']. '</td>
<td align="left">' .$row['Last Name']. '</td>
<td align="left">' .$row['description']. '</td>
<td align="left">' .$row['First Name']. '</td>
<td align="left">' .$row['Street Address']. '</td>
<td align="left">' .$row['City']. '</td>
<td align="left">' .$row['State']. '</td>
<td align="left">' .$row['Zip']. '</td>
<td align="left">' .$row['RSVP']. '</td>
<td align="left">' .$row['Hotel']. '</td>
<td align="left">' .$row['Household']. '</td>
<td align="left">' .$row['Gift']. '</td>

<td align="left"> <a href=Person_RSVP.php?person='
.$row['person_id'].
'&prod=' .$row['person_id']. '>View Guests </a> </td>
</tr>';
}
echo '</table>';

echo '<br />';
echo '<p><a href="Person_Menu.html">Return to Menu</a> </p>';

}
$result->free();
$db->close();

?>
</body>
</html>


Update: I am getting these notices and warnings:



Notice: Undefined index: in_Person_id in C:\student\hrbailey\Person_Select.php on line 3


Guest System


Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:\student\hrbailey\Person_Select.php on line 30


No Person data found. Return to Menu


Fatal error: Call to a member function free() on a non-object in C:\student\hrbailey\Person_Select.php on line 90



How do i call a dom's method from php?


<?php
session_start();

echo "<script language='javascript'>
document.addEventListener('DOMContentLoaded',
function(){
console.log('11');
console.log(document.getElementById('#login_links_login'));
})
</script>";
?>
<!DOCTYPE html>
<html>
<body>
<!-- form goes here -->
</body>
</html>


This is my php code. It is at the top of my page. After this i have html form.


I want to open my html form from php. I know that i can do it from JQuery/Javascript or keep it open. I want it from php for my another purpose.


But console returns



11
null


But i included those two lines inside DomContentLoaded method of javascript. But it doesn't work.


My browsers are mozilla, webkit.


How do i achieve this?


mailchimp http error: you must specify a apikey

I'm the using MailChimp 2.0 api and trying to post a lists/subscribe call using php. The call is returning an error "You must specify a apikey value".


Here's the code that makes the post:



function json_post ($url, $params)
{
print '<p>url = ' . $url . '</p>';
$data = json_encode ($params);
print '<p>data = ' . $data . '</p>';

$handle = curl_init ($url);
curl_setopt ($handle, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt ($handle, CURLOPT_POST_FIELDS, $data);
curl_setopt ($handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt ($handle, CURLOPT_HTTPHEADER, array ('Content-Type: application/json',
'Content-Length: ' . strlen($data_string)));

$result = curl_exec ($handle);
print '<p>curl_error: ' . curl_errno ($handle) . '</p>';
return $result;
}


The print statements show:



url = http://ift.tt/1ytN3Tn

data = {"apikey":"...","id":"...","email":{"email":"test1@abc.com"},"merge_vars":{"groupings":{"name":"test"}}}

curl_error: 0

{"status":"error","code":-100,"name":"ValidationError","error":"You must specify a apikey value"}


I presume there's something wrong with the syntax. The api key is cut & pasted from my mailchimp account page. I've tried it with and without the -us10 suffix. Any ideas?


Custom validation rule in laravel

I'm trying to create a custom validation rule for laravel but I keep getting the following error: Method [validateOriginalAlt] does not exist.


I have 2 classes.


FormValidator.php



abstract class FormValidator extends Validator
{

protected $validator;
protected $validation;
protected $messages = [];
protected $rules = [];

function __construct(Validator $validator)
{
$this->validator = $validator;
}


public function validate(array $formData)
{
$this->validation = $this->validator->make($formData, $this->getValidationRules(), $this->getValidationMessages());

if ($this->validation->fails()) {
throw new FormValidationException('Validation Failed', $this->getValidationErrors());
}

return true;
}

public function setRules($rules)
{
$this->rules = $rules;
return $this;
}

protected function getValidationRules()
{
return $this->rules;
}

protected function getValidationMessages()
{
return $this->messages;
}

protected function getValidationErrors()
{
return $this->validation->errors();
}
}


Show.php



class Show extends FormValidator
{

protected $rules = [
'title' => 'required|unique:shows,title',
'slug' => 'unique:shows,slug',
'flexget' => 'boolean',
'airing' => 'boolean',
'flexget_titles' => 'original_alt',
];


public function validateOriginalAlt($string)
{
dd($string);
}
}


In my controller I call the validation method like so:



try {
$this->showValidator->setRules([
'title' => 'required',
'slug' => 'unique:shows,slug,' . $id,
'flexget_titles' => 'original_alt',
])->validate($data);
} catch (Animekyun\Forms\FormValidationException $e) {
return Redirect::back()->withErrors($e->getErrors())->withInput();
}


Any ideas on what I could be doing wrong?


Laravel call route action from URL

I'm creating a proxy layer in Laravel to decrypt an authentication token based on this article: http://ift.tt/1cKCwd3


I'm trying to figure out a good way to forward the requests though. I can catch a /proxy/some/other/route route and get the request method, params, headers and the /some/other/route string easily. I would like to match the route against all registered routes in Laravel and call the route action if it exists.


I could also simply forward the request by redirecting it, which would be fine, but this means the application would have to be bootstrapped twice per request which isn't as ideal.


Make file extension to be interpreted by PHP

I added this to my .htaccess file:



AddHandler fcgid-script .test


(I'm using FastCGI / VirtualMin / WebMin)


And crated a test.test file with the contents;



<?php echo "test"; ?>


This results in an internal server error and this message in the error log:



[Thu Apr 16 14:12:57.631287 2015] [fcgid:warn] [pid 2646] (104)Connection reset by peer: [client xxxx:53595] mod_fcgid: error reading data from FastCGI server
[Thu Apr 16 14:12:57.631402 2015] [core:error] [pid 2646] [client xxxx:53595] End of script output before headers: test.test


What am I doing wrong? I tried using different handler namees like x-httpd-php or x-httpd-php5 but that doesn't do anything at all.


I also tried:



<FilesMatch "\.test$">
SetHandler fcgid-script
</FilesMatch>


but it has the same internal server error.


how to create an ajax queue for executing multiple php scripts

hi guys im looking for a free or for someone to show me some code on how to build a ajax queue like this one can anyone help


http://ift.tt/1G7fK8L


How to include website code into iframe via javascript?

I do a curl request with php and the response is a complete website including doctype, html section and so on. Now I want insert this code into an iframe. In my opionion this only can be done with javascript. So I echo the javascript code from my php code. Now I have the problem that the html code contains quotes and line breaks. The quotes are masked by addslashes php function. And I replace the linebreaks with preg_replace php function. But I always get an error "unterminated string literal". You can see the error an this page using for e.g. firebug: http://ift.tt/1aHO9ji The iframe should be shown in the lowermost section called "Hotelbewertungen". Thanks for any suggestion.


Laravel error on logout

I have a custom AppUserProvider to fetch my users from a cache setup like so:



class AppUserProvider extends \Illuminate\Auth\EloquentUserProvider {

public function retrieveById($identifier)
{
return \App\Models\User::getById($identifier);
}
}


I then set a custom property on it in the getById method after retrieving the object with Eloquent and return it.



$user->test = 'test';


Everything works fine, but when I hit logout I get an error.



update `users` set `test` = ?, `remember_token` = ?, `updated_at` = ? where `id` = ?')


Not sure why it's trying to update the test parameter.


Jquey Autocompletion with php file [on hold]

I am following this tutorial. It works fine. What I want now is to get the var availableTags through http request to php file at my server containing same words as defined here. Basically what i want is autocompletion for multiple words and the words suggestions should be get from the file present at server not as defined in the array variable in jquery/javascript.


How to avoid nested if-else statements

When developing API methods to return JSON with details I often find myself creating the following code:



$response = array('success' => false);

$user = User::getSessionUser();
if($user->id > 0){
if(ItemSKU::stringIsValid($sku)){

$itemSKU = ItemSKU::getFromString($sku);
if($itemSKU->isAvailable()){
if(Carts::add($user->id, $sku)){
$response['success'] = true;
}
else{
$response['error'] = "Item was already added";
}
}
else{
$response['error'] = "Unavailable Item";
}
}
else{
$response['error'] = "Invalid SKU";
}
}
else{
$response['error'] = "Invalid User";
}

return response()->json($response);


How can I avoid using this nested if-else chain? Thanks!


Read .txt file into a multi dimensional array in php

The example .txt data is:



20|Charlotte Aaaa|XXXX*SALE*O9
60|Peggy Bbbbb|XXXX*SALE*O8
25|Ashley Ccccc|XXXX*SALE*O7
103|Andrew Ddddd|XXXX*SALE*O1
51|Sally EEeee|XXXX*SALE*O6
9|Richard Fffff|XXXX*SALE*O3
23|Charlotte Aaaaaaaa|XXXX*SALE*O10
150|James Ggggggg|XXXX*SALE*O1
101|Connor Hhhhhhh|XXXX*SALE*O2
90|Barbara Iiiiiiii|XXXX*SALE*O2
23|Richard Ffffff|XXXX*DROP*O4
10|Holly Jjjjjjjj|XXXX*SALE*O5
90|Barbara Iiiiiii|XXXX*SALE*10


The code I currently have is:



$handle = fopen("lock.txt", "r");
if ($handle) {
$i=1;
while (($line = fgets($handle)) !== false) {
$data = explode("|", $line);
$locks = array($i, $data);
$i++;
var_dump($locks);

}
fclose($handle);
} else {
// error opening the file.
}


The output is currently:



array(2) { [0]=> int(1) [1]=> array(3) { [0]=> string(2) "20" [1]=> string(14) "Charlotte Aaaa" [2]=> string(14) "XXXX*SALE*O9 " } } array(2) { [0]=> int(2) [1]=> array(3) { [0]=> string(2) "60" [1]=> string(11) "Peggy Bbbbb" [2]=> string(14) "XXXX*SALE*O8 " } } array(2) { [0]=> int(3) [1]=> array(3) { [0]=> string(2) "25" [1]=> string(12) "Ashley Ccccc" [2]=> string(14) "XXXX*SALE*O7 " } } array(2) { [0]=> int(4) [1]=> array(3) { [0]=> string(3) "103" [1]=> string(12) "Andrew Ddddd" [2]=> string(14) "XXXX*SALE*O1 " } } array(2) { [0]=> int(5) [1]=> array(3) { [0]=> string(2) "51" [1]=> string(11) "Sally EEeee" [2]=> string(14) "XXXX*SALE*O6 " } } array(2) { [0]=> int(6) [1]=> array(3) { [0]=> string(1) "9" [1]=> string(13) "Richard Fffff" [2]=> string(14) "XXXX*SALE*O3 " } } array(2) { [0]=> int(7) [1]=> array(3) { [0]=> string(2) "23" [1]=> string(18) "Charlotte Aaaaaaaa" [2]=> string(15) "XXXX*SALE*O10 " } } array(2) { [0]=> int(8) [1]=> array(3) { [0]=> string(3) "150" [1]=> string(13) "James Ggggggg" [2]=> string(14) "XXXX*SALE*O1 " } } array(2) { [0]=> int(9) [1]=> array(3) { [0]=> string(3) "101" [1]=> string(14) "Connor Hhhhhhh" [2]=> string(14) "XXXX*SALE*O2 " } } array(2) { [0]=> int(10) [1]=> array(3) { [0]=> string(2) "90" [1]=> string(16) "Barbara Iiiiiiii" [2]=> string(14) "XXXX*SALE*O2 " } } array(2) { [0]=> int(11) [1]=> array(3) { [0]=> string(2) "23" [1]=> string(14) "Richard Ffffff" [2]=> string(14) "XXXX*DROP*O4 " } } array(2) { [0]=> int(12) [1]=> array(3) { [0]=> string(2) "10" [1]=> string(14) "Holly Jjjjjjjj" [2]=> string(14) "XXXX*SALE*O5 " } } array(2) { [0]=> int(13) [1]=> array(3) { [0]=> string(2) "90" [1]=> string(15) "Barbara Iiiiiii" [2]=> string(12) "XXXX*SALE*10" } }


What I would like to do is as follows, create an array which I can later use for an ajax search for the third part of each row, i.e. the XXXXSALEYY part so I was thinking $locks[0][3] for which I can later change the 0 as a thing which is used for ajax searching later.


I haven't looked at integrating ajax yet as I am failing at this. Any help would be appreciated.


Php background process useing proc_open

I would like to open a process with "Start /b".$cmd and still have the ability to check its status (.i.e running?) Is it possible?


When I try to use proc_open ( "Start /b".$cmd , $descriptorspec , $pipes ) and check the proc_get_status($process)['running'] it returns false although the process is running ...


Thanks


PHP received value from JavaScript

I create Modal but I'd like to show count "dukung" from my database. I have a problem because, when I query like this >> "select * from sekolah_dukung where kode='valuefromjavascript'";


this is my quote script



var mycode = kode;
<?php
$data_count = "select count(kode) as countkode from sekolah_dukung where kode='mycode'";
$count = mysql_fetch_object($data_count);
?>
h +=' <b><?php echo $count->countkode ?></b>


this is my full script



<script>
function profile(kode,logo,alamat,ket,nama_sekolah,status_sekolah,orientasi_logo)
{
var ip = '<?php echo $_SERVER['REMOTE_ADDR']; ?>';
var mycode = kode;
var h ='';
h +='<div id="openModal" class="modalDialog" >';
h +='<div style="border:1px solid #369ace;">';
h +=' <a onclick="remDialog()" title="Close" class="close">X</a><br/>';
h +=' <h2 style="border-radius: 25px; border: 2px ; padding: 10px; background-color:#359ace; width: auto;"><center>'+nama_sekolah+'</center></h2>';
h +=' <div id="container2">';
h +=' <div id="container1">';
h +=' <div id="col1">';
h +=' <center><img style=" padding: 5px 30px;" width="160px" height="160px" src="images/sekolah/logo/'+logo+'">';
h +=' <p>Klik Disini untuk mendukung agar sekolah ini menampilkan <br/> brosur online <br/></p>';
h +=' <a href="#" id="dukung" style="cursor:pointer;"><button>Ayo Kami Dukung</button></a><br/>Jumlah yang mendukung <br/>';
<?php
$data_count = "select count(kode) as countkode from sekolah_dukung where kode='mycode'";
$count = mysql_fetch_object($data_count);
?>
h +=' <b><?php echo $count->countkode ?></b></center>';
h +=' </div>';
h +=' <div id="col2"><br/>';
h +=' <p><i class="fa fa-home fa-2x"></i> <font color="black">'+alamat+'</p><br/>';
h +=' <p><i class="fa fa-phone fa-2x"></i> <font color="black">0324242324</p>';
h +=' <br/><br/><br/><b>Keterangan :</b> <br/>'+ket+'';
h +=' </div>';
h +=' </div>';
h +=' </div>';
h +=' </div>';
h +='</div>';
$('body').append(h);
$('#dukung').click(function() {
kirimdukung(mycode,ip);
});
}

function kirimdukung(mycode,ip)
{
$.ajax({
url: 'dukung.php?kode='+mycode+'&ip='+ip,
type: 'GET',
success:function(result){
if (result=="True")
{
alert('Terima Kasih Atas Dukungan Anda');
}
else if (result=="False") {
alert('Anda, Sudah Mendukung Sekolah Ini');
}
}
});
}

function remDialog()
{
$("#openModal").remove();
}
</script>

Error when i try to install php 5.4

I get this error when I try to install php 5.4 on cents 6.4


php - v



PHP 5.3.3 (cli) (built: Oct 30 2014 20:12:53)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies


[root@centos145 ~]# rpm -Uvh http://ift.tt/1xf1qsz
Retrieving http://ift.tt/1xf1qsz
warning: /var/tmp/rpm-tmp.LytgA6: Header V4 DSA/SHA1 Signature, key ID cf4c4ff9: NOKEY
Preparing... ########################################### [100%]
file /etc/pki/rpm-gpg/RPM-GPG-KEY-webtatic-andy from install of webtatic-release-6-5.noarch conflicts with file from package webtatic5-release-5.1-4.noarch
file /etc/yum.repos.d/webtatic-archive.repo from install of webtatic-release-6-5.noarch conflicts with file from package webtatic5-release-5.1-4.noarch
file /etc/yum.repos.d/webtatic-testing.repo from install of webtatic-release-6-5.noarch conflicts with file from package webtatic5-release-5.1-4.noarch
[root@centos145 ~]# yum install php54w
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.besthosting.ua
* epel: epel.besthosting.ua
* extras: mirror.besthosting.ua
* updates: mirror.besthosting.ua
* webtatic-el5: uk.repo.webtatic.com
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package php54w.x86_64 0:5.4.39-1.w5 will be installed
--> Processing Dependency: php54w-common = 5.4.39-1.w5 for package: php54w-5.4.39-1.w5.x86_64
--> Processing Dependency: php54w-cli = 5.4.39-1.w5 for package: php54w-5.4.39-1.w5.x86_64
--> Processing Dependency: libssl.so.6()(64bit) for package: php54w-5.4.39-1.w5.x86_64
--> Processing Dependency: libcrypto.so.6()(64bit) for package: php54w-5.4.39-1.w5.x86_64
--> Running transaction check
---> Package openssl098e.x86_64 0:0.9.8e-18.el6_5.2 will be installed
---> Package php54w-cli.x86_64 0:5.4.39-1.w5 will be installed
---> Package php54w-common.x86_64 0:5.4.39-1.w5 will be installed
--> Processing Dependency: libcurl.so.3()(64bit) for package: php54w-common-5.4.39-1.w5.x86_64
--> Processing Conflict: php54w-common-5.4.39-1.w5.x86_64 conflicts php-common < 5.4.0
--> Finished Dependency Resolution
Error: php54w-common conflicts with php-common-5.3.3-40.el6_6.x86_64
Error: Package: php54w-common-5.4.39-1.w5.x86_64 (webtatic-el5)
Requires: libcurl.so.3()(64bit)
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
[root@centos145 ~]#


can you help me please


Pspell doesn't work with kazakh dictionary [on hold]

I have kazakh dictionary to aspell.


Via terminal(ubuntu) the kazakh dictionary works, via pspell not works.


But, Pspell works by en, british dictionary. My code: `



<?php
$pspell = pspell_new("kk","","","utf-8");
$wors = "темір";
if(pspell_check($pspell, $wors)){
print_r($pspell);
echo "Correct";
} else {
var_dump($pspell);
echo "Mistake";
}`

PDO connection login [on hold]

Would you please help me sort this problem out. I don't know what I'm doing wrong. My connection to database working correct but I'm unable to login.


login.php



<?php

session_start();

$username= $_POST["username"];
$password= $_POST["password"];

include("/inc/connect.inc.php");

if(!isset($conn)){
$conn = null;
header('Location: index.php');
}

else{
$query = $conn->prepare("SELECT * FROM `users` WHERE `username`='$username' AND `password`='$password'");
$query ->execute(array(':username' =>$username, ':password' =>$password)
);


if ( ($query->rowCount() == 0) && ( ($password == null) or ($username == null) ) ){
echo "<h3>Please enter your username and password</h3>";
$conn = null;
header("Refresh: 3;URL=index.php");
}
else if ($query->rowCount() == 1)
{
$_SESSION['user_logged'] = $_POST['username'];
unset($username);
unset($password);
echo "<h3>Your password is correct</h3>";
$conn = null;
header("Refresh: 3;URL=interface.php");
}

else {
echo "<h3>The username / password combination entered is incorrect!</h3>";
unset($username);
unset($password);
$conn = null;
header("Refresh: 3;URL=index.php");
}
}


?>


Previously I didn't understand stackoverflow rules. I hope this time my question is more accurate. I have done lot of work to get to this point and only have a problem with login to my database now. My $query = $conn->prepare not finding anything. It's jumping to The username / password combination entered is incorrect! at any time. If I leave username or/and password empty or putting correct username and password always the same result.


PHP - Read counter-strike (valve) console

is there anyone who have experience with console of valve games (counter-strike 1.6, source, global offensive or TeamFortress 2).


thanks.


html form not uploading file via post to a php script

So I have the following html form





<form name="input" onsubmit="return validateForm()" action="validate-signup.php" method='post' enctype="multipart/form-data">
name: <input type='text' name='name'/><br/>
password: <input type='text' name='password'/><br/>
email: <input type='text' name='email'/><br/>
phone number: <input type='text' name='phone'/><br/>
profile picture: <input type="file" name="file" size="25"/><br/>
<input name="submit" type="submit" value="Submit"/><br/>
</form>



after which I have the following php code



if (isset($_POST['submit'])) {
if ($_FILES['file']['name'] != "") {
copy($_FILES['file']['name'], getcwd()) or
die("Could not copy file!");
} else {
die("No file specified!");
}
}


the problem is $_FILES is empty. I've looked at past answers for this topic checked my php.ini, checked read write permissions etc but I'm still stumped. I'm running this using wamp, and editing my work in netbeans if this makes a difference.


codeigniter 404 error Occurred in linode server .how fix it bro

codeigniter 404 error Occurred in linode server .how fix it bro


I changed conf.php


$config['index_page'] = '';


and


edit


.htaccess file


RewriteRule ^(.*)$ index.php$1 [L]


adn change apache.conf


AllowOverride None changed to AllowOverride All but not still work


give me help


map a website structure

I'd like to code my own website based on an existing opensource CMS (PrestaShop). There is some nice functionalities but also a bunch of code I won't need for my website (a simple B2B catalog with no fancy stuff). The CMS uses PHP (very different from what I learned 15 years ago) and .tpl files. I'm wondering if there is a way to map a website like an .exe in a decompiler such as IDA in order to see relation between files, calls etc? Cheers


How can I change the way coupons applies in woocommerce

I am using woo-commerce and have 2 restrictions for coupons:

minimum value and maximum value


When the total value of the cart is either lower than the minimum value or higher than the maximum value, the coupon won't be applied.


Regarding this, I would like to alter this functionality, and only apply a coupon when the total value of the cart exceeds the maximum value. I would also like to apply the discount on only the amount of maximum value, not on the whole cart.


Lets look at on an example:



If the maximum value of the coupon is 100$ and has a 10% discount, while the total value of a cart is 200$, then after applying the coupon, the whole cart should cost 190$ and not 180$.



Summarized: where can I change the functionality of coupons to work like this?


error in MySql syntax near = in where clause

i am writing this command



$result = mysql_query("SELECT * FROM register where name= ‘lakhan’ ") or die(mysql_error());


and when running the php file it shows:



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 '‘lakhan’'


I am using MySql Server 5.5 AND INSTEAD OF = sign i have used LIKE also in query then too error is coming.Please help me to resolve it


PHP echo class object property

Is it possible to echo class object so it will show some property of this object?


Let's say we've got such class



class Color {

public $color = "";

function __construct($color) {
$this->color = $color;
}

}


and then we make it's instance and echo it:



$myColor = new Color("red");
echo $myColor; //I want it to echo 'red' ( same as I'd do echo $myColor->color )


What happens here is my object has prop color. And when I have echo $object I want it to really do echo $object->prop


Is it possible to make such 'echoing' handler?


google analytics track php mvc page views

Im trying to figure out how to track google analytics php mvc page views. I have through htaccess told the server to route all requests through an index.php file in the root. My google anayltics tracking is only recording page views for the root folder (/) .... Obviously makes sense because im routing through the index. My question is how to tell google the actual page url for the content im showing in the index.php file. Can anyone help? Do I need to use google Event tracking codes or is there a better solution for this?


Unable to POST to a specific site using cURL

I'm trying to POST some form data to a site using cURL. It's not a secure site, and doesn't require logging in. It's just a form used to get back some information.


When I post the form manually inside the given web site, I can inspect the headers that are sent. I've tried in vain to reproduce them using cURL. This is normally not a problem for me, but I'm reaching out to others who might know how to do this successfully.


The URL is: http://ift.tt/1HtMOKc, and the form action is to the same page (it's in Turkish).


Here are valid form inputs:



Şehir: ADANA
İlçe: SARIÇAM
Okul: Hacı Özcan Sinağ Ortaokulu
Sınav Türü: TEOGS | ADANA İL MİLLİ EĞİTİM OKDS
Sınıf: 8
Öğrenci No: 1941
Öğrenci Ad: BERKANT İPEK


Here is what the form looks like filled out:


Filled-out form page


Here are the form headers taken from Chrome on a successful POST request:



POST /index.php HTTP/1.1
Host: objektifsonuc.com
Connection: keep-alive
Content-Length: 138
Cache-Control: max-age=0
Origin: http://ift.tt/1EfRaFe
User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 Safari/537.36
Content-Type: application/x-www-form-urlencoded
DNT: 1
Referer: http://ift.tt/1HtMOKc
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.8
Cookie: PHPSESSID=veb6h5ht0nqk1pu4d46sbvpch3


And here is the POST body:



il=1&ilce=1%3B18&okul=1%3B18%3B743729%3BTEOGS%2CSBS&sinav=100%3BTEOGS&sinif=8&ogrno=1941&ograd=BERKANT+%DDPEK&ogr=%D6%F0renci+Veli+Giri%FE


This is how I have been trying to send a POST request in PHP:



$headers = array(
"content-length: 138",
"cookie: PHPSESSID=veb6h5ht0nqk1pu4d46sbvpch3;",
"accept-language: en-US,en;q=0.8",
"accept-encoding: gzip, deflate",
"referer: http://ift.tt/1EfRaFe",
"dnt: 1",
"content-type: application/x-www-form-urlencoded",
"user-agent: Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 Safari/537.36",
"origin: http://ift.tt/1EfRaFe",
"accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
"cache-control: max-age=0",
"connection: keep-alive"
"host: objektifsonuc.com"
);

$query="il=1&ilce=1%3B18&okul=1%3B18%3B743729%3BTEOGS%2CSBS&sinav=100%3BTEOGS&sinif=8&ogrno=1941&ograd=BERKANT+%DDPEK&ogr=%D6%F0renci+Veli+Giri%FE";

$url = "http://ift.tt/1HtMOKc";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
echo curl_exec($ch);


Current result: The form page renders


Desired result: A different page containing some tables renders


I'm stumped. What is causing the POST to fail? Can anyone make this POST succeed?


How to create a file from controller

I'm trying to save a file from a controller. It doesn't work using fopen and I'm unable to get the error message. Is there a way to do this or a absolutely need to use the filesystem bundle? And is there a way to understand the error? I used a try/catch blog with no luck. The code I'm using is really simple:



$file = $this->get('request')->server->get('DOCUMENT_ROOT').'/myfile.txt';
$fp = fopen($file, 'w');
fwrite($fp, 'file content');
fclose($fp);

Symfony2 kernel.controller event for single controller or bundle scope

My question about a little, but significant detail that i discover while read this article: http://ift.tt/1no6Qg9


Manual says, that declared TokenListener will be executed on each request. So, if i have a big application with a lot of controllers (or bundles with own controllers), and a lot of any other kind of event listeners, this beaviour add an overhead: each of the event listeners will be executed in each request for each bundle! For example, i have default AppBundle and ApiBundle, and in given example, TokenListener executes in case of request to boths bundles, because defined in app specific config: app/config/services.yml


How to avoid this beaviour? How to define listeners only per bundle, or, better, per controller? Maybe,it can be defined in bundle specific services.yml, but this is also too wide scope for listener, that used in a few controllers.


Refresh SESSION after change it by submit form

I have code that get me country flag for user when select country from drop down menu like this



define('WCDP_PATH_INCLUDES', dirname(__FILE__) . '/inc');

if (!class_exists('GeoIP')) {
include(WCDP_PATH_INCLUDES . "/geoip.inc");
}
$geo_data = geoip_open(WCDP_PATH_INCLUDES . "/GeoIP.dat", GEOIP_STANDARD);

$country_code = geoip_country_code_by_addr($geo_data, $_SERVER['REMOTE_ADDR']);

$countrynameselect = $_SESSION['countryname'];
if ($countrynameselect){
$country_code = $countrynameselect;
} else {
$country_code = geoip_country_code_by_addr($geo_data, $_SERVER['REMOTE_ADDR']);
}
// Build HTML for flag icons.
?>

<img src="<? bloginfo('stylesheet_directory')?>/flags/sm/<?php echo strtolower($country_code).'.png'; ?>" border="0" style="margin-top:10px" id="flagc" />


Now when user select country from drop down menu, i save country post in SESSION, But when user change agin, itsh not update SESSION, and to update it, we must refresh page to shpw new SESSION value.


What can i do ??


PHP Google Places to find the custom location like Zomato

As in Zomato.com,REFER THIS LINK the website get the location of the user and then shows results (list of restaurants) near it using Google Places.


Can we add some custom locations in Google Places. Fetch the User location and show him our 5 locations(that we added) nearby him in PHP?


Zomato location based search


How to I make special preg_replace




<a href="http://ift.tt/1G7dQox" rel="nofollow" data-trackimg="http://ift.tt/1HlYRZx" target="_blank" class="external-link">UNCHCR</a>

<a href="http://ift.tt/1HgT8nS">Twitter provides greater privacy protection to users in Europe, but not the US</a>

<a href="http://ift.tt/k38zi1" rel="nofollow" data-trackimg="http://ift.tt/1G7dQoz" target="_blank" class="external-link">MASHABLE</a>



I wants to only which are class external-link,


example result





<link href="http://ift.tt/1G7dQox" rel="nofollow" data-trackimg="http://ift.tt/1HlYRZx" target="_blank" class="external-link">UNCHCR</link>

<link href="http://ift.tt/1HgT8nS">Twitter provides greater privacy protection to users in Europe, but not the US</link>

<link href="http://ift.tt/k38zi1" rel="nofollow" data-trackimg="http://ift.tt/1G7dQoz" target="_blank" class="external-link">MASHABLE</link>



How to implement pagination on a custom WP_Query Ajax

I want to paginate my WordPress posts in a custom loop with Ajax, so when I click on load more button posts will appear.


My code:



<?php
$postsPerPage = 3;
$args = array(
'post_type' => 'post',
'posts_per_page' => $postsPerPage,
'cat' => 1
);
$loop = new WP_Query($args);

while ($loop->have_posts()) : $loop->the_post();
?>
<h1><?php the_title(); ?></h1>
<p>
<?php the_content(); ?>
</p>
<?php
endwhile;
echo '<a href="#">Load More</a>';
wp_reset_postdata();
?>


This code does not paginate. Is there a better way to do this?


Why it returns null? .. PHP User class

i need your help. Today, i was doing this code for 3 hours and Im really desperate now.


I have got a class for login/register. I make it with a help of Youtube-tutorial. My problem is, my remember function doesnt work. Look at this.



if($hashCheck->count()){
$user = new User($hashCheck->first()->user_id);
$user ->login();

}


In this part i make a new User object, giving a number (ID) like a param.. Next thing i do is...



public function __construct($user = null){
$this->_db = DB::getInstance();
$this->_sessionName = Config::get('session/session_name');
$this->_cookieName = Config::get('remember/cookie_name');

if(!$user){
if(Sessio::exists($this->_sessionName)){
$user = Sessio::get($this->_sessionName);

if($this->find($user)){
$this->_isLoggedIn = true;
}
else{
//logout
}
}
else{
$this->find($user);
}
}
}


now, var_dump($user) returns null so next is if(!$user){}.. it tries to call function find.. This is my function find



public function find($user = null){
var_dump($user);

if($user){
echo'probiha find';
$field = (is_numeric($user)) ? 'id' : 'jmeno';
$data = $this->_db->get('uzivatele', array($field,'=',$user));
if($data->count()){
echo 'data count';
$this->_data = $data->first();
return true;
}
}
return false;
}


But my $user is still null (and shoud be a number - ID)... When it is ID, function find will be work correct.


My question is, why is $user in construct null? :( When i done $user = new User($hashCheck->first()->user_id); it should be a number.. $hashCheck->first()->user_id returns a number (ID of user..) Thanks everybody for every answer :)


Javascript not waiting for ajax with bootstrap-wizard.js

I have a bootstrap-wizard as follows:



<div class="wizard-card" data-cardname="credential">
<h3>Credential</h3>
<div class="wizard-input-section">
<p>Username</p>
<div class="form-group">
<div class="col-sm-6">
<input type="text" class="form-control" id="Busername" name="Busername" placeholder="Username" required data-parsley-type="alphanum" data-validate="checkNameAvailable" data-msg="Alphanumeric allowed only" />
</div>
</div>
<p>Password</p>
<div class="form-group">
<div class="col-sm-6">
<input type="password" class="form-control" id="Bpassword" name="Bpassword" placeholder="Password" />
</div>
</div>
<p>Re-type Password</p>
<div class="form-group">
<div class="col-sm-6">
<input type="password" class="form-control" id="Bpassowrd2" name="Bpassword2" placeholder="Retype Password"/>
</div>
</div>
</div>
</div>


The input <input type="text" class="form-control" id="Busername" name="Busername" placeholder="Username" required data-parsley-type="alphanum" data-validate="checkNameAvailable" data-msg="Alphanumeric allowed only" /> calls the checkNameAvailable function to make validation.


checkNameAvailable function: Which makes an ajax call to check if the name is available or not.



function checkNameAvailable(el){
if($("#"+$(el).attr('id')).parsley().isValid()){
var data = $(el).val();
if($(el).attr('id') == "Busername"){
var type = "B";
}else{
var type = "I";
}
$.ajax({
method: "POST",
url: "isUserAvailableCommon",
async: false,
data: {Busername: data, _token: $("#_token").val(), _type: type },
success: function(msg) {
var retValue = {};
if(msg == "OK"){
retValue.status = true;
console.log(retValue);
return retValue;
}else{
retValue.status = false;
console.log(retValue);
return retValue;
}
}

});
}
}


The problem is that the variable retValue is not returned to the bootstrap-wizard validation.


However if i try like this it works but not when implementing with ajax



function checkNameAvailable(el){
var retValue = {};
retValue.status = false;
return retValue;
}


Any idea how to make it work with ajax? I have tried callbacks and methods described in Javascript function not waiting for AJAX responsebut it is still not working.


Blogger URL PARAMETER javascript

I have a blog in blogger platform.


I need some extra URL parameter to add in my blog and it post. If I like to keep ?id=100 or ?id=parameter after all original link


Like if some of visit my blog.



http://ift.tt/1Ip51Xr
http://ift.tt/1O2Oob4


If someone Open blogger Post



http://ift.tt/1Ip51Xt
http://ift.tt/1O2Oob9


If some of Open pages.



http://ift.tt/1Ip54T2
http://ift.tt/1O2OoYD


Hope you understand, i just like to keep some extra ?id=anything after all original link.


Please tell me the javascript which redirect to ?something=something after original link.


LinkedIn REST API - Internal server error

I'm using the LinkedIn REST API to post updates to a users timeline. Since a few days I get an Internal server error response from LinkedIn but the code worked before.


PHP:



$postTitle = "hello";
$postDesc = "world ";
$submitted-url = "http://example.com";
$submitted-image-url = "http://ift.tt/1DMrQo6";
$comment = "foobar";

$postData = array('visibility' => array('code' => 'connections-only'),
'content' => array('title' => $postTitle,'description' => $postDesc,'submitted-url' => $postURL,'submitted-image-url' => $postImage), 'comment' => $postComment);

$ch = curl_init('http://ift.tt/1c7LsJ4'.$oauthToken.'&format=json'
);

curl_setopt_array($ch, array(
CURLOPT_POST => TRUE,
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_HTTPHEADER => array('x-li-format: json', "Content-Type: application/json"),
CURLOPT_POSTFIELDS => json_encode($postData)
));

$response = curl_exec($ch);


How to fix that error?


Pase Error When Call Header in on my index page

When i calll this header code on my index page it shows


"Parse error: syntax error, unexpected end of file in D:\wamp\www\namalika\application\views\admin\orders.php on line 116"



<?php
//if($this->session->userdata('admin')=='')
// header("Location:".base_url()."index.php/admin/");
?>
<div id="header">
<div id="logo">
<a href="<?php echo base_url();?>"><img src="<?php echo base_url();?>images/logo.png" alt="Naamalika." /></a>
</div>
</div>
<div id="menu">
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Our Products</a></li>
<li><a href="#">My Cart</a></li>
<li><a href="#">Contact Us</a></li>
<?php if($this->session->userdata('admin')!='')
{
?>
<li><a href="<?php echo base_url();?>http://ift.tt/1HlYRJ9">Signout</a></li>
<? } ?>
</ul>
</div>

I need some help to send and open a variable web address to a object tag on a seperate page using php

in my test page I have three links which assign a different web address to a variable called $link





.buttonpush {
height: 25px;
width: 200px;
font-family: Arial, Helvetica, sans-serif;
font-size: 14px;
font-weight: bold;
color: #333;
border: 2px solid #CCC;
}
.butdiv {
position: absolute;
left: 20px;
top: 30px;
}​



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://ift.tt/kkyg93">
<html xmlns="http://ift.tt/lH0Osb">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>index</title>
<link href="css/phptest.css" rel="stylesheet" type="text/css" />
</head>

<body>

<div class="butdiv">
<div class="buttonpush"><a href="show.php
?link=http://ift.tt/mMnC4k">Button one</a></div>
<div class="buttonpush"><a href="show.php
?link=http://ift.tt/1bggdLL">Button two</a></div>
<div class="buttonpush"><a href="show.php
?link=http://ift.tt/1OYcoJn">Button three</a></div>

</div>

</body>
</html>



I need to make the result page display the required web site within the object tag





<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://ift.tt/kkyg93">
<html xmlns="http://ift.tt/lH0Osb">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>show</title>
</head>

<body>

<?php
$link = $_GET['link'];

?>

<object data="echo htmlspecialchars '$link';" width="1000" height="720">
<embed src="echo htmlspecialchars '$link';" width="1000" height="720" /> Error: Embedded data could not be displayed.
</object>


</body>
</html>



although the correct web address is passed to the show.php page..... it doesn't display the webpage being called? I've used a similar code to pass specific variable strings to a form before.... but I failed in my attempt to achieve this result!! Any help / advice would be greatly appreciated from a relative newbie Thank you


How can I use a PHP Session variable in a dynamically loaded navbar?

I have a series of pages that load a navbar from an external HTML file like so:



<head>
<script>
$(function() {
$("#navbar").load("navbar.html");
});
</script>
</head>
<body>
<div id="navbar"></div>
<!--other stuff here-->


This is all in a PHP page. However, there's part of that navbar that I want to set to set to a PHP $_SESSION variable (a username). Is there a way to easily do this?


Is using strpos() before preg_replace() faster?

Lets say we use this code for millions if posts:



public static function makeClickableLinks($s) {
return preg_replace('@(https?://([-\w\.]+[-\w])+(:\d+)?(/([\w/_\.#-]*(\?\S+)?[^\.\s])?)?)@', '<a href="$1" target="_blank">$1</a>', $s);
}


Now assume that only 10% if all posts contain links, would it be faster to check strpos($string, 'http') !== false before calling makeClickableLinks()?


PHP design pattern for classes with static and non-static methods

My objective is to create class that can be used both static and non-static way. Both ways have to use the same methods, but in different way


Non-static way:



$color = new Color("#fff");
$darkenColor = $color->darken(0.1);


Static way:



$darkenColor = Color::darken("#fff", 0.1);


So in this example method darken can be used both on existing object and as static method of Color class. But depending on how it's used, it uses different parameters.


How should such class be designed? What is good pattern for creating such types of classes?


Class will have a lot of different methods so it should avoid massive checking code in beginning of each method.




ps. I wasnt sure what should be title of this quesiton. If you've got better idea so other people with same problem can find it - please edit.


Adding confirm step to button in Wordpress php file

I'm using a Wordpress plugin (Work The Flow) that allows file uploads / downloads / deletion etc.


The plugin allows a user to delete any file of theirs, but doesn't ask you to confirm you really want to delete it: it just immediately deletes the file.


I'd like to add in something to ensure a confirmation popup appears first.


The plugin owner pointed me to this php code in his plugin (and specifically towards btn btn-danger delete:



function getDownloadJSTemplate() {
$script = <<<DOWNLOADJSTEMPLATE
<!-- The template to display files available for download -->
<script id="template-download" type="text/x-tmpl">
{% for (var i=0, file; file=o.files[i]; i++) { %}
<tr class="template-download fade">
<td>
<span class="preview">
{% if (file.thumbnailUrl) { %}
<a href="{%=file.url%}" title="{%=file.name%}" download="{%=file.name%}" data-gallery><img src="{%=file.thumbnailUrl%}"></a>
{% } %}
</span>
</td>
<td>
<p class="name">
{% if (file.url) { %}
<a href="{%=file.url%}" title="{%=file.name%}" download="{%=file.name%}" {%=file.thumbnailUrl?'data-gallery':''%}>{%=file.name%}</a>
{% } else { %}
<span>{%=file.name%}</span>
{% } %}
</p>
{% if (file.error) { %}
<div><span class="label label-danger">Error</span> {%=file.error%}</div>
{% } %}
</td>
<td>
<span class="size">{%=o.formatFileSize(file.size)%}</span>
</td>
<td>
{% if (file.deleteUrl) { %}
<button class="btn btn-danger delete" data-type="{%=file.deleteType%}" data-url="{%=file.deleteUrl%}&action=load_ajax_function"{% if (file.deleteWithCredentials) { %} data-xhr-fields='{"withCredentials":true}'{% } %}>
<i class="glyphicon glyphicon-trash"></i>
<span>Delete</span>
</button>
<input type="checkbox" name="delete" value="1" class="toggle">
{% } else { %}
<button class="btn btn-warning cancel">
<i class="glyphicon glyphicon-ban-circle"></i>
<span>Cancel</span>
</button>
{% } %}
</td>
</tr>
{% } %}
</script>
DOWNLOADJSTEMPLATE;
return $script;
}


Can anyone advise - assuming I can create a child .php file to do this? - how I can add a confirmation stage in? The delete button can appear many times on the page, as it appears alongside each uploaded file.


Warning: Cannot modify header information [duplicate]


This question already has an answer here:




I have read the other posts and tried what they say and im having no luck.


I created the pages on my localhost using IIS and everything works, I have uploaded my pages to a free server and now im getting the error even though what is ment to happen happens (the folders get created, image gets moved and info is stored on mysql) its just not going to the profile page instead its giving me the error message :- Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /srv/disk13/1572246/www/http://ift.tt/1OYcpgk) in /srv/disk13/1572246/www/http://ift.tt/1bgggao on line 22


Warning: Cannot modify header information - headers already sent by (output started at /srv/disk13/1572246/www/http://ift.tt/1OYcpgk) in /srv/disk13/1572246/www/http://ift.tt/1bgggao on line 27


--insert.php --



<?php include("includes/connect.php"); ?>

<?php
include("includes/var.php");

//check if passwords match
if ($password == $cpassword){
//passwords match - check if file is an image
if(substr($imageType,0,5) == "image"){
//check if accounts dir excists
if (is_dir($accounts)){
//check if username account excists
if (is_dir($uploaddir)){
//Yes users directory exists - Move file to $username
if(move_uploaded_file($_FILES['image']['tmp_name'], $uploadfile)) {
//file moves to folder - insert file to MySQL
include("insert_image.php");
}else{
//file does not move
echo "There is a problem with $tmp_name";
}
}else{
mkdir($accounts . $uploaddir , 0777);
mkdir($accounts . $uploaddir . $image_dir, 0777);
mkdir($accounts . $uploaddir . $video_dir, 0777);
include("insert_image.php");
}
}else{
//No account dir exists - create directory
mkdir($accounts , 0777);
mkdir($accounts . $uploaddir , 0777);
mkdir($accounts . $uploaddir . $image_dir, 0777);
mkdir($accounts . $uploaddir . $video_dir, 0777);
include("insert_image.php");
}
}else{
//file is not an image
echo "This is not an image";
}
}else{
//Passwords do not match
echo "Passwords do not match";
}
?>


--insert_image.php--



<?php

move_uploaded_file($_FILES['image']['tmp_name'], $uploadfile);

//add info to the database.
$sql = "INSERT INTO `apply` (`username`,`email`,`password`,`realname`,`location`,`charname`,`class`,`race`,`mainspec`,`rank`,`image_name`,`avatar`)
VALUES ('$username','$email','$password','$realname','$country','$charName','$class','$race','$spec','$rank','$imageName','$imageData')";

if (mysql_query($sql,$con)){
//display the profile
//header ("Location:index.php");
$sql = "SELECT * FROM apply WHERE username='$username'";
$result =mysql_query($sql);
$row = mysql_fetch_assoc($result);
$id = $row['id'];

// Mysql_num_row is counting table row
$count=mysql_num_rows($result);

if ($id){
//if ursername and password is correct get user ID
if($count==1){
session_start();
$_SESSION['loggedin'] = true;
$sql="UPDATE apply SET logged='Yes' WHERE id='$id'" or die ("cant find learner");
$result=mysql_query($sql) or die ("this stuffedup");
//display profile
header ("Location:profile.php?id=$id");
}else{
$_SESSION['loggedin'] = false;
unset($_SESSION['loggedin']);
}
}else{
echo "No ID";
}
}else{
//cant find table
echo 'Cant find table ' . mysql_error();
}
?>

How symfony2 know user was logged in

I have Bundle like. My idea is: all users must be login before access



app_dev.php/app/
app_dev.php/home/


or app_dev.php/home/show



AppBundle
Controller
LoginController.php
indexAction() {
echo "you can access right now";
}
loginAction() {
$session = $this->getRequest()->getSession();
if ($session->has('login')) {
//redirect to home/index
}else {
//render login form
}
}
checkAction(Request $request) {
if($request->getMethod()=='POST') {
// check user input (username && password) in database
if (ok){
$session->set('login', 'true');
//redirect to home/index
}
else {
//redirect to login/index
}
}else {
//redirect to login/index
}
}
logoutAction() {
//remove login session
// redirect to login/index
}
HomeController.php
indexAction() {
echo "page1";
}
showAction() {
echo "page2";
}


My security.yml like



security:
firewalls:
# the login page has to be accessible for everybody
app_login:
pattern: ^/app/login$
anonymous: ~
security: false

secured_area:
pattern: ^/app
form_login:
check_path: /app/check
login_path: /app/login
logout:
path: /app/logout
target: /app


My routing.yml like



app_index:
path: /
defaults: { _controller: ExAppBundle:Login:index }
app_login:
path: /login
defaults: { _controller: ExAppBundle:Login:login }
app_check:
path: /check
defaults: { _controller: ExAppBundle:Login:check }

app_logout:
path: /logout
defaults: { _controller: ExAppBundle:Login:logout }

app_home_show:
path: /home/show
defaults: { _controller: ExAppBundle:Home:show }

app_home_index:
path: /home
defaults: { _controller: ExAppBundle:Home:index }


But that redirect to login form always. How talk to symfony know user has logged in. Thanks!


Flot MySQL graph no data display

I am having problem making my Flot graphic to work. Here is the code for graphic I also included print_r output from PHP. So basically my biggest problem is either with json encode or the graph display itself I just can't find the fault...





<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://ift.tt/kTyqzh">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Graph of Energy Consumption</title>
<link href="layout.css" rel="stylesheet" type="text/css"></link>
<!--[if IE]><script language="javascript" type="text/javascript" src="flot/excanvas.min.js"></script><![endif]-->
<script language="javascript" type="text/javascript" src="flot/jquery.js"></script>
<script language="javascript" type="text/javascript" src="flot/jquery.flot.js"></script>
<script language="javascript" type="text/javascript" src="flot/jquery.flot.selection.js"></script>
</head>
<body>
<h1>Energy</h1>

<p>Zoom to:
<button id="nineties">half hour</button>
<button id="ninetynine">1 hour</button>
<button id="12hour">12 hours</button>
<button id="24hour">24 hours</button>
<button id="48hour">48 hours</button>
<button id="Refresh">Refresh</button></p>
<?php

include 'connect.php';


$link=Connection();
$result=mysql_query("SELECT * FROM `tempLog` ORDER BY `timeStamp` DESC",$link);

$data = array();
$max = 0;
while($row = mysql_fetch_array($result))
{
$data[] = array( $row['timeStamp'], $row['temperature'] );
}
print_r($data);

?>
<div id="placeholder" style="width:800px;height:400px;"></div>

<p></p>
<div id="overview" style="margin-left:20px;margin-top:20px;width:780px;height:100px"></div>

<script id="source" language="javascript" type="text/javascript">

var data = <?php echo json_encode($data); ?>;
$(function () {

var options = {
xaxis: { mode: "time" },
selection: { mode: "xy" },
};

var plot = $.plot($("#placeholder"), [ data ], options);

var overview = $.plot($("#overview"), [ data ], {
series: {
lines: { show: true, lineWidth: 1 },
shadowSize: 0
},
xaxis: { ticks: [], mode: "time" },
yaxis: { ticks: [], min: 0, max: 5000 },
selection: { mode: "xy" }
});

$("#placeholder").bind("plotselected", function (event, ranges) {
// clamp the zooming to prevent eternal zoom
if (ranges.xaxis.to - ranges.xaxis.from < 0.00001)
ranges.xaxis.to = ranges.xaxis.from + 0.00001;
if (ranges.yaxis.to - ranges.yaxis.from < 0.00001)
ranges.yaxis.to = ranges.yaxis.from + 0.00001;

// do the zooming
plot = $.plot($("#placeholder"), [ data ],
$.extend(true, {}, options, {
xaxis: { min: ranges.xaxis.from, max: ranges.xaxis.to },
yaxis: { min: ranges.yaxis.from, max: ranges.yaxis.to }
}));

// don't fire event on the overview to prevent eternal loop
overview.setSelection(ranges, true);
});


$("#overview").bind("plotselected", function (event, ranges) {
plot.setSelection(ranges);
});

$("#nineties").click(function () {
$.plot($("#placeholder"), [data], {
xaxis: {
mode: "time",
min: (new Date()).getTime()-1800000,
max: (new Date()).getTime()
},
selection: { mode: "xy" }
});
});

$("#ninetynine").click(function () {
$.plot($("#placeholder"), [data], {
xaxis: {
mode: "time",
min: (new Date()).getTime()-3600000,
max: (new Date()).getTime()
},
selection: { mode: "xy" }
});
});

$("#12hour").click(function () {
$.plot($("#placeholder"), [data], {
xaxis: {
mode: "time",
min: (new Date()).getTime()-43200000,
max: (new Date()).getTime()
},
selection: { mode: "xy" }
});
});

$("#24hour").click(function () {
$.plot($("#placeholder"), [data], {
xaxis: {
mode: "time",
min: (new Date()).getTime()-86400000,
max: (new Date()).getTime()
},
selection: { mode: "xy" }
});
});

$("#48hour").click(function () {
$.plot($("#placeholder"), [data], {
xaxis: {
mode: "time",
min: (new Date()).getTime()-172800000,
max: (new Date()).getTime()
},
selection: { mode: "xy" }
});
});

$("#Refresh").click(function () {

});




});
</script>

</body>
</html>






Array ( [0] => Array ( [0] => 2015-04-16 22:47:27 [1] => 25 ) [1] => Array ( [0] => 2015-04-16 22:42:21 [1] => 25 ) [2] => Array ( [0] => 2015-04-16 22:37:15 [1] => 25 ) [3] => Array ( [0] => 2015-04-16 22:32:09 [1] => 24 ) [4] => Array ( [0] => 2015-04-16 22:27:03 [1] => 24 ) [5] => Array ( [0] => 2015-04-16 22:21:56 [1] => 23 ) [6] => Array ( [0] => 2015-04-16 22:16:50 [1] => 23 ) [7] => Array ( [0] => 2015-04-16 22:11:44 [1] => 24 ) [8] => Array ( [0] => 2015-04-16 22:06:38 [1] => 24 ) [9] => Array ( [0] => 2015-04-16 22:01:32 [1] => 24 ) [10] => Array ( [0] => 2015-04-16 21:56:25 [1] => 24 ) [11] => Array ( [0] => 2015-04-16 21:51:19 [1] => 24 ) [12] => Array ( [0] => 2015-04-16 21:46:13 [1] => 24 ) [13] => Array ( [0] => 2015-04-16 21:41:07 [1] => 24 ) [14] => Array ( [0] => 2015-04-16 21:36:01 [1] => 25 ) [15] => Array ( [0] => 2015-04-16 21:30:55 [1] => 25 ) [16] => Array ( [0] => 2015-04-16 21:30:07 [1] => 25 ) [17] => Array ( [0] => 2015-04-16 21:27:56 [1] => 25 ) [18] => Array ( [0] => 2015-04-16 21:27:40 [1] => 25 ) [19] => Array ( [0] => 2015-04-16 21:27:24 [1] => 25 ) [20] => Array ( [0] => 2015-04-16 21:27:18 [1] => 25 ) [21] => Array ( [0] => 2015-04-16 21:22:40 [1] => 25 ) [22] => Array ( [0] => 2015-04-16 21:22:04 [1] => 25 ) [23] => Array ( [0] => 2015-04-16 21:21:53 [1] => 25 ) [24] => Array ( [0] => 2015-04-16 21:21:42 [1] => 25 ) [25] => Array ( [0] => 2015-04-16 21:21:26 [1] => 26 ) [26] => Array ( [0] => 2015-04-16 21:21:10 [1] => 26 ) [27] => Array ( [0] => 2015-04-16 21:20:54 [1] => 25 ) [28] => Array ( [0] => 2015-04-16 21:20:38 [1] => 25 ) [29] => Array ( [0] => 2015-04-16 21:20:22 [1] => 25 ) [30] => Array ( [0] => 2015-04-16 21:20:07 [1] => 25 ) [31] => Array ( [0] => 2015-04-16 21:19:51 [1] => 25 ) [32] => Array ( [0] => 2015-04-16 21:19:35 [1] => 25 ) [33] => Array ( [0] => 2015-04-16 21:19:19 [1] => 26 ) [34] => Array ( [0] => 2015-04-16 21:19:03 [1] => 25 ) [35] => Array ( [0] => 2015-04-16 21:18:47 [1] => 25 ) [36] => Array ( [0] => 2015-04-16 21:18:31 [1] => 25 ) [37] => Array ( [0] => 2015-04-16 21:18:15 [1] => 25 ) [38] => Array ( [0] => 2015-04-16 21:17:59 [1] => 25 ) [39] => Array ( [0] => 2015-04-16 21:17:43 [1] => 25 ) [40] => Array ( [0] => 2015-04-16 21:17:27 [1] => 25 ) [41] => Array ( [0] => 2015-04-16 21:17:11 [1] => 25 ) [42] => Array ( [0] => 2015-04-16 21:16:55 [1] => 25 ) [43] => Array ( [0] => 2015-04-16 21:16:40 [1] => 25 ) [44] => Array ( [0] => 2015-04-16 21:16:24 [1] => 25 ) [45] => Array ( [0] => 2015-04-16 21:16:08 [1] => 25 ) [46] => Array ( [0] => 2015-04-16 21:15:52 [1] => 25 ) [47] => Array ( [0] => 2015-04-16 21:15:36 [1] => 25 ) [48] => Array ( [0] => 2015-04-16 21:15:20 [1] => 26 ) [49] => Array ( [0] => 2015-04-16 21:15:04 [1] => 26 ) [50] => Array ( [0] => 2015-04-16 21:14:48 [1] => 26 ) [51] => Array ( [0] => 2015-04-16 21:14:32 [1] => 26 ) [52] => Array ( [0] => 2015-04-16 21:14:16 [1] => 29 ) [53] => Array ( [0] => 2015-04-16 21:14:00 [1] => 29 ) [54] => Array ( [0] => 2015-04-16 21:13:44 [1] => 25 ) [55] => Array ( [0] => 2015-04-16 21:13:35 [1] => 25 ) [56] => Array ( [0] => 2015-04-16 21:13:17 [1] => 25 ) )


Get value of second , and second using Simple HTML DOM

I'm trying get values from a shoutcast songhistory (link).


The markup of page have 2 tables like:



<table>
<tbody>
<tr>
<td>Header Link 1</td>
<td>Header Link 2</td>
</tr>
</tbody>
</table>
<table>
<tbody>
<tr> <td>Lengh of song 1</td> </tr>
<tr> <td>Song Title 1</td> </tr>
<tr> <td>Lengh of song 2</td> </tr>
<tr> <td>Song Title 2</td> </tr>
</tr>
</tbody>
</table>


I only need get the song title and save this on a database.


This is my code:



<?php
include_once('simple_html_dom.php');

ini_set('display_errors', true);
error_reporting(E_ALL);

$host="localhost";
$username="root";
$password="";
$database="titulos";

mysql_connect($host,$username,$password);
mysql_select_db($database) or die( "No se puede conectar a la base de datos");

$html = file_get_html('http://ift.tt/1HGysGc');
$guardardato = "";

// Buscar
foreach($html->find('table', 2)->find('tr', 2) as $datossc) {
foreach($datossc->find('td') as $titulo) {

echo $titulo->plaintext .'<br>';
$guardardato .= $titulo->plaintext;
}
}

$guardardato = mysql_real_escape_string($guardardato);
$query = "INSERT INTO data(name) VALUES('$guardardato')";

mysql_query($query) or die(mysql_error());

$html->clear();
unset($html);
?>


The sql process is ok, but the simple dom does work..


I get that error:



Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\proyectos\radioargenta\oyentes\indexprueba.php on line 19



enter image description here


Can help me?


Thanks!


Make my own FLV converter with PHP

For my new project i want to make my own FLV converter for download YouTubes's and Dailymotion's videos. I don't know if it is hard and how can i make that. Thank you for answer to my question


FIXED htaccess rewriterule gives 404 error

I'm trying to rewrite /test to /test.php. If I go to the link directly it will give me the php page that works but when I go to /test it just gives a 404 not found error. I have enabled mod_rewrite and given the /var/www 755 permissions.


.htaccess



RewriteEngine On
RewriteRule ^test test.php [NC]


test.com.conf



<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName test.com
ServerAlias www.test.com

DocumentRoot /var/www/test.com
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/test.com>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>


FIXED: Changed FollowSymLinks to +FollowSymLinks


Save MYSQL result on webspace as XML [on hold]

I have the following MYSQL query which is creating results from different tables. It is a query which I use to update google-shopping prices.



SELECT C.virtuemart_product_id as 'g:id',
CONCAT(E.product_name ,' ', E.product_s_desc) as title,
CONCAT('http://ift.tt/1H29hyM',I.slug,'/',E.slug,'-detail') as link,
case when G.mf_name = 'empty' then '1' else 'Free shipping' end as description,
case when A.file_url = '' then '' else CONCAT('http://www.website.com/',A.file_url) END as 'g:image_link',
case when D.override = 1 then round (D.product_override_price,2) else round (D.product_price * J.mwst,2) end as 'g:price',
case when G.mf_name = 'empty' then '1' else 'New' end as 'g:condition', CASE WHEN C.published = '1' then 'in stock' END as 'g:availability',
G.mf_name as 'g:brand', C.product_sku as 'g:gtin',CONCAT(C.product_weight,' kg') as 'g:shipping_weight',
J.g_label_1 as 'g:custom_label_0'

from

e6vw2_virtuemart_medias A, e6vw2_virtuemart_product_medias B, e6vw2_virtuemart_products C, e6vw2_virtuemart_product_prices D, e6vw2_virtuemart_products_da_dk E, e6vw2_virtuemart_product_manufacturers F, e6vw2_virtuemart_manufacturers_da_dk G, e6vw2_virtuemart_product_categories H, e6vw2_virtuemart_categories_da_dk I, product_feed_category_g J

where B.virtuemart_product_id >='6'
and C.published = "1"
and C.product_in_stock >= '1'
and B.virtuemart_product_id=C.virtuemart_product_id
and B.virtuemart_product_id=D.virtuemart_product_id
and B.virtuemart_product_id=E.virtuemart_product_id
and B.virtuemart_product_id=F.virtuemart_product_id
and B.virtuemart_product_id=H.virtuemart_product_id
and B.virtuemart_product_id=J.virtuemart_product_id
and A.virtuemart_media_id = B.virtuemart_media_id
and F.virtuemart_manufacturer_id = G.virtuemart_manufacturer_id
and H.virtuemart_category_id=I.virtuemart_category_id
and H.ordering=1
and B.ordering=1


I would like to end up with a xml which will look like this:



<rss version="2.0"
xmlns:g="http://ift.tt/15FVsV8">
<channel>
<title>Google Merchant Datenfeed</title>
<link>website.com</link>
<description>Datafeed for google merchant - </description>

<item><g:id>32</g:id><title>Samsung Galaxy S5 </title><link>http://ift.tt/1H29hyS shipping</description><g:image_link>http://ift.tt/1H29IJv stock</g:availability><g:brand>Samsung</g:brand><g:gtin>7702018851324</g:gtin><g:shipping_weight>0.0000 kg</g:shipping_weight><g:custom_label_0>Smartphone</g:custom_label_0></item>
<item><g:id>33</g:id> ...

</channel>
</rss>


I need to save these results as a XML file on my webspace as soon I run the php file. I found many posts about this issue but none that would manage results from different tables.


I found this guide http://ift.tt/1Jevvv5 however it does not deal with multiple tables and also does not save the results as a file in the end.


samedi 18 avril 2015

Uncaught Error: Syntax error, unrecognized expression: #[object HTMLDivElement]

I'm passing a value to codeigniter function for getting a result. But the ajax value does not pass to the php function.


My script function follows :



<script src="http://ift.tt/1rKdStd"></script>
<Script>
$(document).ready(function() {
$("#up").on('click',function(){
if ($("#incdec").val() < $(this).data("max")) {
$("#incdec").val(parseInt($("#incdec").val())+1);
}
});

$("#down").on('click',function(){
if ($("#incdec").val() > $(this).data("min")) {
$("#incdec").val(parseInt($("#incdec").val())-1);
}
});
});
$(document).ready(function() {
$(".butt").on('click',function(){
var e=$(".aa").val();
alert(e);

$.ajax({
type:"POST",
data:"id="+e,
url:"<?php echo site_url('pages/getit');?>",
success: function(html){
$('#'+dataprocess).html(html);
}
});
});
});

</script>


My HTML code :



<input type="text" name="incdec" id="incdec" value="0" class="aa"/>
<input type="button" class="butt" id="up" value="Up" data-max="5" />
<input type="button" id="down" value="Down" data-min="0" class="butt"/>

<div id="dataprocess"></div>


But I'm getting an error as follows:


Uncaught Error: Syntax error, unrecognized expression: #[object HTMLDivElement]


Please help me find my mistake.


Toggling Bootstrap modal from PHP trigger

Good day! I'm trying to create modal for edit purposes. That means that it must be filled with retrieved data by specific ID. The problem is that it doesn't work.


Link used to call PHP edit function:



<a href="' . ROOT . '/index.php?edit=' . $payment['id'] . '"><span class="glyphicon glyphicon-edit"></span></a>


PHP edit function:



if (isset($_GET['edit'])) {
$edit = httpGet(ROOT . "/API.php?getId=" . $_GET['edit']);
?><script type="text/javascript">
$('#editId').modal('show');</script>
<?php
}


"editId" modal:



<div id="editId" class="modal fade" tabindex="1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h1 class="text-center">Edit Transaction</h1>
</div>
<div class="modal-body">
<form class="form col-md-12 center-block" action="API.php" method="post">
<div class="form-group">
<input type="text" id="id" name="id" class="form-control input-lg" placeholder="ID" value="<?php echo $edit[0]['id']; ?>">
</div>
<div class="form-group"> <select class="form-control" id="type" name="type" placeholder="Transaction type" value="<?php echo $edit[0]['type']; ?>">
<option value="withdaw">Withdraw</option>
<option value="deposit">Deposit</option>
</select></div>
<div class="form-group">
<input type="text" id="sum" name="sum" class="form-control input-lg" placeholder="Sum" value="<?php echo $edit[0]['sum']; ?>">
</div>
<div class="form-group">
<select class="form-control" id="currency" name="currency" placeholder="Currency" value="<?php echo $edit[0]['currency']; ?>">
<option value="ILS">ILS</option>
<option value="USD">USD</option>
</select></div>
<div class="form-group">
<input type="text" id="transaction" name="transaction" class="form-control input-lg" placeholder="Transaction ID" value="<?php echo $edit[0]['transaction']; ?>">
</div>
<div class="form-group">
<input type="text" id="buyer" name="buyer" class="form-control input-lg" placeholder="Buyer" value="<?php echo $edit[0]['buyer']; ?>">
</div>
<div class="form-group">
<input type="text" id="email" name="email" class="form-control input-lg" placeholder="Email" value="<?php echo $edit[0]['email']; ?>">
</div>
<div class="form-group">
<input type="text" id="invoice" name="invoice" class="form-control input-lg" placeholder="Invoice" value="<?php echo $edit[0]['invoice']; ?>">
</div>
<div class="form-group">
<input type="text" id="date" name="date" class="form-control input-lg" placeholder="Date" value="<?php echo $edit[0]['date']; ?>">
</div>
<div class="form-group">
<button class="btn btn-primary btn-lg btn-block" type="submit" value="updateId" name="updateId">Update Payment</button>
</div>
</form>
</div>
<div class="modal-footer">
<div class="col-md-12">
<button type="button" class="btn btn-default btn-lg btn-block" data-dismiss="modal">Cancel</button>
</div>
</div>
</div>
</div>

How to submit form after validation in jquery

I just try to form submit after validation success. But i have run below code, simultaneously both operations perform same time. I also tried to submit handler method, it gets error only. My code looks like this:



$("#request_form").validate({
debug: false,
onfocusout: function(element) {
$(element).valid();
},
errorClass : 'has-error',
rules: {
Subject : "required",
Screen: "required"
},
messages: {
Subject : "Subject cannot be empty",
Screen: "Screen cannot be empty"
},
submitHandler: function(form) {
form.submit();
}
});



$("#request_form").on('submit',(function(e)
{
$("#request_form").validate();
$("#request_form").valid()
{
alert("test");
var action = "Provide_Feedback";
var form = $('form')[0];
var formData = new FormData(form);

formData.append('action','Provide_Feedback');
e.preventDefault();

$.ajax({
url: "support_update.php",
type: "POST",
data: formData,
contentType: false,
cache: false,
processData:false,
success: function(data)
{
if (data == "200") {
alert("Your Request Sent.");
window.location = 'provide_feedback.php';
}
else {
alert("There was an error occurred!");
}

}
});

}
}));

Ajax sequential file upload

Calling post ajax with file uploading, server takes time to save file,


There are minimum 100KB file to file one by one, how to do this?


I need this in jquery


youtube video scrap using php curl

i used the below post to try to get the youtube video but that will play and my question is how to download directly to the pc using php curl pls help me


Using CURL to play Youtube videos


Zend_Rest_Route not working for a sub-directory controller (e.g. admin/questions)

I'm trying to define RESTful routes for sub directory controllers. I want to be able to create routes for the url at admin/questions/*. My controller is Admin_QuestionsController:



- application
- controllers
-Admin
QuestionsController.php (class Admin_QuestionsController)


Below is how I'm declaring my RESTful route for this controller:



$restRoute = new Zend_Rest_Route($front, array(), array(
'admin' => array('questions')
));
$router->addRoute('rest', $restRoute);


..from the documentation I can't see what I'm doing wrong - http://ift.tt/1kzvS6K. However, I get the following error:



Invalid controller specified (admin)


I can get the routes to work when I declare then not as Rest routes:



$router->addRoute('admin_questions',
new Zend_Controller_Router_Route( '/admin/questions', array(
'controller' => 'Admin_Questions',
'action' => 'index')
)
);


..so I don't think I've have the folder structure wrong, or the class name. But, I need RESTful routes which I'm unable to achieve.