I have all the login scripts and profiles set up. I have a data table where all the profile information is stored called plus_signup but I can't seem to get this GET[id] thing to work. Am I missing something? Here's what I have.
When I view the page with the code I have now, there are blank areas where PHP is supposed to fill in the variables.
session_start();
include "include/z_db.php";
if ($_GET['id']){
$id = $_GET['id'];
} else if (isset($_SESSION['id'])) {
$id = $_SESSION['id'];
}
else {
print "important data to render this page is missing";
exit();
$sql = mysql_query("SELECT * FROM plus_signup WHERE id='$userid'");
while($row = mysql_fetch_array($sql)){
$userid = $row["userid"];
$name = $row["name"];
$location = $row["location"];
$sex = $row["sex"];
$aboutme = $row["aboutme"];
}
$check_pic = "users/$id/image01.jpg";
$default_pic = "users/0/image01.jpg";
if (file_exists($check_pic)){
$user_pic = "<img src=\"$check_pic\" width=\"175px\"/>";
} else {
$user_pic = "<img src=\"$default_pic\"/>";
}}
I know it's a little late and that you may have already figured out the answer to this question, but I was having the same issue and just figured it out.
Your SQL query is calling on a variable that has not been defined.
session_start();
include "include/z_db.php";
if ($_GET['id']){
$id = $_GET['id'];
} else if (isset($_SESSION['id'])) {
$id = $_SESSION['id'];
}
else {
print "important data to render this page is missing";
exit();
$sql = mysql_query("SELECT * FROM plus_signup WHERE id='$userid'");
while($row = mysql_fetch_array($sql)){
$userid = $row["userid"];
$name = $row["name"];
$location = $row["location"];
$sex = $row["sex"];
$aboutme = $row["aboutme"];
}
$check_pic = "users/$id/image01.jpg";
$default_pic = "users/0/image01.jpg";
if (file_exists($check_pic)){
$user_pic = "<img src=\"$check_pic\" width=\"175px\"/>";
} else {
$user_pic = "<img src=\"$default_pic\"/>";
}}
You are getting the 'id' from the url and storing it as $id. When you call your query, you are having it search for where ID = $userid when you really should be having it search for ID = $id.
Make sure that your variables are the same throughout!
^Hope that helps some people avoid an hour or two of frustration when trying to figure out why their function isn't working!
Related
I'm trying to export Netsuite ItemFulfillment Records into a local database so I can import into UPS Worldship to send them. I'm able to export recently modified records, but can't figure out how to filter on the shipStatus. Can anyone help lead me in the correct direction?
What I have that exports recently modified records, but does not filter correctly on shipStatus:
require_once '/PHPToolkit/NetSuiteService.php';
$start_time = microtime(true);
$service = new NetSuiteService();
$transactionSearchBasic = new TransactionSearchBasic();
// type = itemFulfillment
$searchMultiSelectEnumField = new SearchEnumMultiSelectField();
$searchMultiSelectEnumField->operator = 'anyOf';
$searchMultiSelectEnumField->searchValue[] = '_itemFulfillment';
$transactionSearchBasic->type = $searchMultiSelectEnumField;
// lastmodified > datelastrun
$SearchDateField = new SearchDateField();
$SearchDateField->operator = "after";
$SearchDateField->searchValue = "2019-12-01T00:00:00";
$transactionSearchBasic->lastModifiedDate = $SearchDateField;
// shipStatus = picked
$SearchStringField = new SearchStringField();
$SearchStringField->operator = 'is';
$SearchStringField->searchValue = '_picked';
$transactionSearchBasic->shipStatus = $SearchStringField;
$transactionSearch = new TransactionSearch();
$transactionSearch->basic = $transactionSearchBasic;
$request = new SearchRequest();
$request->searchRecord = $transactionSearch;
$searchResponse = $service->search($request);
if (!$searchResponse->searchResult->status->isSuccess) {
echo "SEARCH ERROR";
} else {
echo "SEARCH SUCCESS, records found: " . $searchResponse->searchResult->totalRecords . PHP_EOL;
}
$end_time = microtime(true);
$execution_time = ($end_time - $start_time);
echo " Execution time of script = ".$execution_time." sec";
Not sure why _picked is not working.
Can you try using internal id of these status values.
Internal Id Text
A Picked
B Packed
C Shipped
Instead of '_picked' try using 'A'.
I have a form in Laravel. I used pagination in this form and search option too. Pagination works fine when I didn't search anything. If I search something which has records more than 10 (my pagination record limit is 10), it shows result perfectly in first page but in second page or third page it shows the records of whole database. It's ignore the search criteria.
Controller Code:
public function index()
{
if (Input::has('invoiceNumber')) {
$invoiceNumber = Input::get('invoiceNumber');
$invoices = Invoice::where('invoiceNumber','like', '%'.$invoiceNumber.'%')->orderBy('date','desc')->paginate(10);
} elseif (Input::has('client')) {
$client = Input::get('client');
$invoices = Invoice::where('client','like', '%'.$client.'%')->orderBy('date', 'desc')->paginate(10);
} elseif (Input::has('startDate') && Input::has('endDate')) {
$startDate = Input::get('startDate');
$endDate = Input::get('endDate');
$invoices = Invoice::whereBetween('date', [$startDate, $endDate])->orderBy('date', 'desc')->paginate(10);
} elseif (Input::has('startDate')) {
$startDate = Input::get('startDate');
$invoices = Invoice::where('date', $startDate)->orderBy('date', 'desc')->paginate(10);
} elseif (Input::has('endDate')) {
$endDate = Input::get('endDate');
$invoices = Invoice::where('date', $endDate)->orderBy('date', 'desc')->paginate(10);
} else {
$invoices = DB::table('invoices')
->join('vehicles', 'invoices.vehicle', '=', 'vehicles.registration')
->select(
'invoices.*',
'vehicles.brand',
'vehicles.model',
'vehicles.seat',
'vehicles.remarks'
)
->orderBy('date', 'desc')
->paginate(10);
}
return view('invoice.index',compact('invoices'));
}
After performing search my URL look like this:
http://my-site.com/invoice?invoiceNumber=&client=&startDate=2016-01-01&endDate=2016-02-08
After this search when I click on page 2, the URL become this:
http://my-site.com/invoice?page=2
Try to use this bellow code (change as per your requirement)
return view('invoice.index')->withInvoices($invoices->appends(Input::except('page'));
Hope it's working for you...
In your view file, the render has to be like given below:
{!! $invoices->appends(Input::except('page'))->render() !!}
Simply use this on the result page.Pagination will be automatically visible at the bottom of the page
{!! $invoices->render() !!}
Working on instgram Real Time subscription. I am trying to save the image link based on Object id return from subscription. The activity log captures "N" only, not the image link. What I am doing wrong.
<?php
if (isset ($_GET['hub_challenge'])){
echo $_GET['hub_challenge'];
}
else{
$myString = file_get_contents('php://input');
$sub_update = json_decode($myString);
$access_token = 'xxxxx';
foreach($sub_update as $k => $v) // can be multiple updates per call
{ $objid = $v->object_id;
$recent_data = file_get_contents('https://api.instagram.com/v1/tags/'.$objid.'/media/recent?access_token='.$access_token);
$results=$results['data'];
$image_link = $results['images']['standard_resolution']['url'];
file_put_contents('activity.log', serialize($image_link), FILE_APPEND | LOCK_EX);
}
}
?>
I am using Elastica and going to use \Elastica\Query\FunctionScore(); function score --> script_score. Here addDecayFunction() woking fine but addScriptScoreFunction() not work and not through any exception.
DecyFunction is commented because it is working
Here is code
$scriptString = "doc['geo_location'].distanceInMiles('42.946697', '-76.113623')";
$script = new \Elastica\Script($scriptString);
$query = new \Elastica\Query\FunctionScore();
$query->addScriptScoreFunction($script);
// $locationOrigin = "32.804654, -117.242594";
// $locationScale = '2mi';
// $query->addDecayFunction(\Elastica\Query\FunctionScore::DECAY_GAUSS, 'geo_location', $locationOrigin, $locationScale);
$resultSet = $type->search($query);
$results = $resultSet->getResults();
$totalResults = $resultSet->getTotalHits();
if ( $totalResults > 0 ) {
echo "<b>Total Results Found are:</b> " . $totalResults . "<br>";
foreach ( $results as $result ) {
echo $result->getScore();
$data = $result->getData();
var_dump($data);
}
}
maybe you forget to enable scripts?
script.disable_dynamic: false
I am looping through the files array as shown in the middle chunk of code, rest of the code is just for better context.
$email = new PHPMailer();
$email->From = 'John#example.com';
$email->FromName = 'John Doe';
$email->Subject = $name_talent;
$body = '<strong>ADDRESS</strong> : ' .$address_talent.'<br><br>';
if ($_FILES) {
foreach ($_FILES as $file => $array) {
$tmp_path = $_FILES[$file]['tmp_name'];
$tmp_name = basename($_FILES[$file]['name']);
$email->AddAttachment($tmp_path, $tmp_name);
}
}
$email->Body = $body;
$email->IsHTML(true);
$email->AddAddress( '######gmail.com' );
$email->Send();
This sends the attachments with values in the $body as well. Now, I would like to unlink the files either after the mail is sent or the attachments are successful. As inspired from this answer, If I do it like this below, no files are attached and any variables set for the $body eg. $address_talent do not appear in the email.
if ($_FILES) {
foreach ($_FILES as $file => $array) {
$tmp_path = $_FILES[$file]['tmp_name'];
$tmp_name = basename($_FILES[$file]['name']);
if($email->AddAttachment($tmp_path, $tmp_name)){
unlink("$tmp_path");
}
}
}