I'm having a problem regarding Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING. I tried every solution in available online but still I got the same error over and over again.
So the problem is: Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in C:\wamp\www\RedCross\load.php on line 25
load.php
<?php
include_once('connect.php');
$EventNum = $_POST['ename'];
//die('You sent: ' . $selStudent);
//Run DB query
$query = "SELECT Price FROM events WHERE EventID = '".$EventNum."' ";
$result = mysql_query($query) or die('Fn another_php_file.php ERROR: ' . mysql_error());
$num_rows_returned = mysql_num_rows($result);
//die('Query returned ' . $num_rows_returned . ' rows.');
//Prepare response html markup
$r = "
<div class='control-group'>
<label class='control-label' for='price'>Price </label>
<div class='controls'>
";
//Parse mysql results and create response string. Response can be an html table, a full page, or just a few characters
if ($num_rows_returned > 0) {
while ($row = mysql_fetch_array($result)) {
$r = $r . "<input type='text' name='price' id='price' class='input-xlarge' value = " . $row['Price'] . " readonly>";
}
$r = $r . "<center>
<button type='submit' class='btn btn-large btn- danger' name='submit' id='submit'>Join!</button>
</center>";
//The response echoed below will be inserted into the
echo $r;
} else {
$r = '<p>sorry there is no available staff for this</p>';
// $r = $r . '</select><input type="submit" name ="go" value="press me">';
$r = $r . '</div></div>';
//The response echoed below will be inserted into the
echo $r;
}
//Add this extra button for fun
?>
Line 25 is this code:
Even though I put spaces before it making this line not in line 25 still the error is in line 25.
Please help.
Change the code in line 25 to line below and test:
$r = $r . '<input type="text" name="price" id="price" class="input-xlarge" value = ' . $row["Price"] . ' readonly>';
Related
I'm trying to store some upload pictures to my database using laravel. Everything goes well, everything got stored, but for the file, they keep storing a bin file of 38B, I've tried reading it to .Txt files and it has a path to /Applications/MAMP/tmp/php/phpUzMXbn.
Here is my function code :
Route::post('/FruitCreate',function(Request $request){
$fruit = new fruit;
$fruit->name = $request->name;
$fruit->price = $request->price;
$fruit->picture = $request->image;
$fruit->save();
return redirect('FruitsChangingPricePanel');
My form blade :
<form enctype="multipart/form-data" method="POST" action="{{ url('FruitCreate') }}" >
{{ csrf_field() }}
<input type="text" name='name'>
<input type="text" name='price'>
<input type="hidden" name="MAX_FILE_SIZE" value="30000000" />
<input type="file" name='image'>
<button type='submit'> submit </button>
thank u For Your Help !!
You can do may be something like that:
$file = $request->file('image');
$imageContent = $file->openFile()->fread($file->getSize());
$fruit = new fruit; $fruit>picture = $imageContent; $fruit>save();
Note: Your column type must be Blob
because you are trying to save directly bin.
try this one
$file = Input::file('file');
$destinationPath = public_path(). '/uploads/';
$filename = $file->getClientOriginalName();
$file->move($destinationPath, $filename);
echo $filename;
//echo '<img src="uploads/'. $filename . '"/>';
$user = ImageTest::create([
'filename' => $filename,
]);
Firstly, you should get your image and then store it to public/uploads/fruits folder.And after that, you are saving the path to your picture to DB.
$fruit = new fruit;
$fruit->name = $request->name;
$fruit->price = $request->price;
if ($request->has('image')) {
if (!file_exists(public_path('uploads/fruits/'))) {
mkdir(public_path('uploads/fruits/'));
}
if (!file_exists(public_path('uploads/fruits/' . date('FY') . '/'))) {
mkdir(public_path('uploads/fruits/' . date('FY') . '/'));
}
$image = $request->file('image');
$filename = public_path('uploads').'/fruits/' . date('FY') . '/' . str_random() . '.' . $image->guessExtension();
\Image::make($image->getRealPath())->encode('jpg')->resize(220, 220)->put($filename);
$fruit->picture = $filename;
}
$fruit->save();
Ive been trying all day to create a new entry in my table. Sorry for all the text in spanish. I hope it is not a problem.
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST'){
$nueva_tienda = $_POST['nueva_tienda'];
if(!empty($nueva_tienda)){
echo "not empty";
include('connection.php');
mysqli_query($dbc, "INSERT INTO tiendas (nombre) VALUES ('$nueva_tienda')");
}
else{
echo "Porfavor llena todos los campos";
}
}
else{
echo "No form has been submitted";
}
?>
<h1>Nueva tienda</h1>
<form action="processing2.php" method="post">
<p>Nombre de la nueva tienda: <input type="text" name="nueva_tienda" maxlength="50"/></p>
<p><input type="submit" name="submit" value="Submit"/></p>
</form>
EDIT:
Added connection include file from comments:
<?php $hostname = "localhost";
$username = "root";
$password1 = "";
$dbname = "inventario_collares"; //making the connection to mysql
$dbc = mysqli_connect($hostname, $username, $password1, $dbname) OR die("could not connect to database, ERROR: ".mysqli_connect_error());
//set encoding
mysqli_set_charset($dbc, "utf8");
?>
Create an object of your connection class.
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST'){
$nueva_tienda = $_POST['nueva_tienda'];
if(!empty($nueva_tienda)){
echo "not empty";
include('connection.php');
//create an object for your connection class
$dbc=new connection();
mysqli_query($dbc, "INSERT INTO tiendas (nombre) VALUES ('$nueva_tienda')");
}else{
echo "Porfavor llena todos los campos";
}
}else{
echo "No form has been submitted";
}
?>
<h1>Nueva tienda</h1>
<form action="processing2.php" method="post">
<p>Nombre de la nueva tienda: <input type="text" name="nueva_tienda" maxlength="50"/></p>
<p><input type="submit" name="submit" value="Submit"/></p>
</form>
1) Turn on PHP error outputting at the top of your script:
ini_set('display_errors', 1);
error_reporting(E_ALL);
2) set this line:
mysqli_query($dbc, "INSERT INTO tiendas (nombre)
VALUES ('$nueva_tienda')")
or die("Error MySQL Line ".__LINE__." :".mysqli_Error($dbc));
This will output any problems if the MySQL insert query fails.
If you do both of these things and still get no error, then the problem is elsewhere (such as is your file called processing2.php? etc.).
I hate to submit this question but I have been unable to find a solution for almost a week now.
<div class="scanform">
<form action="scanform.php" method="post" id="scanform">
<p> <label for="Order Number">Order Number:</label>
<input name="OrderNumber" id="OrderNumber" autofocus="" type="text"><span class="error">*<?php echo $ONErr;?>
</span></p>
<input name="submit" value="Submit" type="submit"></form>
</div>
The form works well when I click on the submit button but if I type in the text field and hit enter, the form just reloads.
I cannot figure out what I am doing wrong.
The PHP code:
<?php date_default_timezone_set('America/Toronto');
$ONErr = "";
if (isset($_POST['submit']))
{
$link = mysqli_connect("localhost", "username", "password", "ordertracking");
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
// Escape user inputs for security
if (empty($_POST['OrderNumber'])) {
$ONErr = "OrderNumber is required";
} else {
$OrderNumber = mysqli_real_escape_string($link, $_POST['OrderNumber']);
// Attempt insert query execution
$query = "SELECT * FROM Orders WHERE OrderNumber LIKE '%$OrderNumber' ORDER BY TimeStamp DESC LIMIT 1";
$result = mysqli_query($link, $query) or trigger_error("Query Failed! SQL: $query - Error: ". mysqli_error($mysqli), E_USER_ERROR);
}
// Close connection
mysqli_close($link);
}
?>
I have a website for school where every teacher is going to have a page. Each teacher's page will have a spot for them to upload a PDF. I want this to then show in a viewer on the page so students see the Viewer when they access it.
How would I code into the website allowing the user to upload a PDF and not have it replaced until somebody else uploads a PDF?
so far I have the code to upload a document.
<form method="POST" enctype="multipart/form-data" action="fup.cgi">
File to upload: <input type="file" name="upfile"><br/>
Notes about the file: <input type="text" name="note"><br/>
<br/>
<input type="submit" value="Press"> to upload the file!
</form>
How can I get it to go into a viewer below? and that it saves until replaced.
1 - First thing you are not able to upload file to server but your form action is claiming to use CGI,
2 - Second i cant really get what you want but the following code can upload files to server its in PHP and otherthing are you using SQL or what Database are you using it seems you also need database
<?php
set_time_limit(0);
if(!is_dir("uploads")){
$uploadDir = mkdir("uploads");
}
$allowedExts = array("pdf", "docx", "doc");
$extension = end(explode(".", $_FILES["file"]["name"]));
if ((($_FILES["file"]["type"] == "application/pdf")
|| ($_FILES["file"]["type"] == "application/vnd.openxmlformats-officedocument.wordprocessingml.document")
|| ($_FILES["file"]["type"] == "application/msword"))
&& ($_FILES["file"]["size"] < 200000000000000)
&& in_array($extension, $allowedExts))
{
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "<br />";
echo "Type: " . $_FILES["file"]["type"] . "<br />";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
if (file_exists("/uploads/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"/uploads/" . $_FILES["file"]["name"]);
echo "Stored in: " . "/uploads/" . $_FILES["file"]["name"];
}
}
}
else
{
echo "Invalid file";
}
?>
Do you want to display pdf thumb, icon, or read the pdf
how do I create a dropdown list in joomla 3.1 for a custom component. I try to create custom fields and I would like to use joomlas dropdown with search
my get input method looks
public function getInput() {
$jinput = JFactory::getApplication()->input;
$sub_id = $jinput->get('sub_id');
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('*')
->from('#__unis_faculties')
//->join('#__unis_subjects')
->order('faculty_name');
$db->setQuery($query);
$rows = $db->loadObjectList();
if (isset($sub_id)) {
$actual = $db->getQuery(true)
->select('f.id, f.faculty_name')
->from('#__unis_faculties AS f')
->join('LEFT', '#__unis_subjects AS s ON f.id = s.faculty')
->where('f.id = ' . $sub_id);
$db->setQuery($actual);
$actual_row = $db->loadRow();
}
$html = '';
$html .= '<div class="span12 input-prepend">
<span class="add-on">€ </span>
<input class="span4" name="price" id="price" type="text" />
</div>';
$html .= '<field name="" type="list" default="" label="Select an option" description=""><select>';
foreach ($rows as $row) {
$html .= '<option ' . "selected" ? $row->id = $actual_row->id : '' . 'value="' . $row->id . '" >' . $row->faculty_name . '</option>';
}
$html .= '</select></field>';
return $html;
}
but this does not outputs the desired result, the list won't shows up
the actual code is producing the following dropdown but without to show the elements