[Solved] How do i upload an image to my mysql database with php? [duplicate]

[ad_1] You don’t need to store image directly into to database. Just store the image name in the database and fetch it when you want to show. For e.g. $target_dir = “uploads/”; $target_file = $target_dir . basename($_FILES[“fileToUpload”][“name”]); $uploadOk = 1; $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION); // Check if image file is a actual image or fake image … Read more

[Solved] Is this prepared statement?

[ad_1] Yes you are using a prepared statement with a parameter. That’s the right thing to do. Parameters are the best way to write safe SQL statements in the majority of cases. There are just a few edge cases where they don’t help (see my answer to how safe are PDO prepared statements) I can … Read more

[Solved] convert mysql query to laravel query builder

[ad_1] \DB::table(‘cars’) ->join(‘garage’, ‘garage.id’, ‘=’, ‘cars.garage’) ->where(‘garage.name’, ‘main’) The above solves the garage and cars part, but you never specified what is aliased to p. If p is a different table then you need to add another call to join() and making the following \DB::table(‘cars’) ->join(‘garage’, ‘garage.id’, ‘=’, ‘cars.garage’) //<Other table join goes here for … Read more

[Solved] How to use proper variable in php? [closed]

[ad_1] You should better a try var_dump($row) or print_r($row) first to see if the array contains the datas at right keys. $lang[$row[0]] doesnt work because $row[0] is empty. Your are probably not assigning Hello to $row[0]. So try print_r($row); to see whats stored in the whole array. Add : $lang[$row[0]] will give you $lang[hello]. It … Read more

[Solved] how to Multiply 2 columns from different tables but same database mysqli php [closed]

[ad_1] $con = mysqli_connect(“localhost”, “root”, “”, “zoo”); if (mysqli_connect_error()) { echo “Failed to connect” . mysqli_connect_error(); } $sel = “select (quantity* bill) as total from animal inner join price on animal.id=price.animal_id group by price.animal_id”; $result = mysqli_query($con, $sel); while ($row = mysqli_fetch_array($result)) { echo “<tr>”; echo”<td>” . $row[‘total’] . “</td>”; } Before copy and paste … Read more

[Solved] How to loop table in php [duplicate]

[ad_1] There are multiple issues with your current code. You fetch the first row with $row = mysqli_fetch_array($select); (line 3), but you don’t do anything with it. This means that the first result is discarded. Your while loop attempts to loop over an incorrect variable ($query is a string, not the result-object), and you’ve quoted … Read more

[Solved] PHP How to generate School Year?

[ad_1] Change your code following way- <?php $date2=date(‘Y’, strtotime(‘+1 Years’)); for($i=date(‘Y’); $i<$date2+5;$i++){ echo ‘<option>’.$i.’-‘.($i+1).'</option>’; } ?> [ad_2] solved PHP How to generate School Year?

[Solved] I need a sql query to view data

[ad_1] SELECT cities.cityname, states.statename, countryname FROM cities JOIN states ON cities.states_id = states.id JOIN country ON states.country_id = country.id WHERE cities.id=3; Assuming 3 is the id of the city you are searching for… [ad_2] solved I need a sql query to view data