Skip to main content

Posts

I want to feed my data directly into mysql database without any query. anyone help please?

I want to change this code so that I can directly feed this data into mysql database without going through mysql query (line 14). I just want this code to help me just as a data entry form. <?php session_start(); require_once('dbconnection.php'); //Code for Registration if(isset($_POST['signup'])) { $fname=$_POST['fname']; $lname=$_POST['lname']; $sname=$_POST['sname']; $email=$_POST['email']; $password=$_POST['password']; $contact=$_POST['contact']; $enc_password=$password; $sql=mysqli_query($con,"select id from attendee where email='$email'"); $row=mysqli_num_rows($sql); if{ $msg=mysqli_query($con,"insert into users(fname,lname,sname,email,password,contactno) values('$fname','$lname','$sname','$email','$enc_password','$contact')"); if($msg) { echo "<script>alert('Register successfully'

PHP. Assigning values to an array within a loop

OK, simple question. New to PHP. How do I accomplish something similar to the following in PHP? This is no specific language intentionally. i = 0; j = 0; k = 50; While i <= 5 While j <= 10 myarray(i,j) = k i = i + 1 j = j + 1 k = k + 2 next next I have found much info regarding arrays and loops in PHP and none seem to accomplish this simple task. Please don't be snarky... just give me a hand here. source https://stackoverflow.com/questions/68967203/php-assigning-values-to-an-array-within-a-loop

Deleting data from database using Laravel 8

I'm stuck with an issue relating to deleting data from my database The DELETE method is not supported for this route. Supported methods: GET, HEAD. - My controller for deleting - public function destroy($id) { $project = Projects::findOrFail($id); $project->delete(); return redirect('/')->with('msg', 'Your project is now done'); } My form for deleting the data - form action="/projects/" method="POST"> @csrf @method('DELETE') <button>Finish your project</button> </form> My route - Route::delete('/projects/{id}', [ProjectController::class, 'destroy']); Migration - public function up() { Schema::create('projects', function (Blueprint $table) { $table->id(); $table->timestamps(); $table->string('type'); $table->string('assignment'); $table->string('name

How to split the result of a mysql query into multiple arrays

I need some help with some code. I have a MYSQL database query output that has a field value of: [ { "title":"SOC1 Certificate", "comment":"", "size":"286.845703125", "name":"SOC1%20Cert.pdf", "filename":"fu_iik2rfypa3tzrxh", "ext":"pdf" }, { "title":"SOC 2 cert", "comment":"", "size":"286.845703125", "name":"SOC2%20Cert.pdf", "filename":"fu_97krdbic5nrdziy", "ext":"pdf" } ] What would the PHP code be to read this and split the entry into two array records? Thanks source https://stackoverflow.com/questions/68962061/how-to-split-the-result-of-a-mysql-query-into-multiple-arrays

Symfony 4 HTTP Cache Headers not same in profiler and browser

For a website development, I try to use Symfony 4 HTTP cache described in documentation . I created an CacheKernel called in index.php like this : namespace App; use Symfony\Bundle\FrameworkBundle\HttpCache\HttpCache; class CacheKernel extends HttpCache { } // index.php $kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']); $kernel = new CacheKernel($kernel); $request = Request::createFromGlobals(); In homepage action: $response->setPublic(); $response->setMaxAge(3600); $response->headers->addCacheControlDirective('must-revalidate', true); return $response; In profiler, headers are sets : cache-control "max-age=3600, must-revalidate, public" But in browser, headers are not same, and I think cache is not stored : Cache-Control: max-age=0, must-revalidate, private Have you got some ides to understand why headers are not same and why cache is not working please ? And how can I make be sure cache is working,

Get value from json_decode

I am kinda struggling, not sure what is wrong. I am trying to get values from the response I get from API. $response = json_decode($call); Output object(stdClass)#1 (3) { ["valid"]=> bool(false) ["api"]=> object(stdClass)#3 (3) { ["query_methode"]=> string(14) "set_client" ["query_client"]=> NULL ["query_timer"]=> string(6) "0.000s" } ["reponse"]=> object(stdClass)#4 (1) { ["info"]=> array(1) { [0]=> string(32) "Success." } } } I am trying to get ["valid"] and ["response"] message which is a success in this case. $response = $response->valid; //doesnt work if($response == true) echo "works"; Then I tried, $response = json_decode($call, true); $results = (array) $response; $valid = $results['valid']; // doesn

How to set a session flash message in lumen 8?

I am trying to set a session flash message in blade file in lumen 8. However it's stated a pervious version but not present in latest doc. Here is my code snippet In Controller: public function foo() { .... return redirect('contact')->with('status', 'Message sent successfully !'); } in blade: @if (session('status')) <div class="alert alert-success"> </div> @endif But it's not working & throwing an error Call to undefined function Session() How can I set a flash message in blade after redirect ? source https://stackoverflow.com/questions/68967322/how-to-set-a-session-flash-message-in-lumen-8