Jump to content

Search the Community

Showing results for tags 'php'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

  1. Hi, I'm doing web page menu that will be stored in mysql database called 'menitest' it has 2 fields, menu id (INT) and item (VARCHAR). For now I made index.php and style.css, menu is ul list, connection to database works, and I'm managed to get everythig works. menu is populated from database, and that is fine, but what I need is help to make menu items to links to another pages. here is the code for now. index.php <?php include('testconnect.php'); //calling menu from database $query_sql = "SELECT * FROM meni"; $item_query = mysql_query($query_sql) or die(mysql_error()); $rsitem = mysql_fetch_assoc($item_query); ?> <! DOCTYPE html> <html> <head><title></title> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <link rel="stylesheet" href="style2.css" type="text/css" /> </head> <body> <nav> <ul> <?php do { ?> <li><a href="menutest.php?meni_ID=<?php echo $rsitem['meni_ID']; ?>"><?php echo $rsitem['item']; ?></a></li> <?php }while ($rsitem = mysql_fetch_assoc($item_query)); ?> </ul> </nav> </body> </html> menutest.php does not be there, it just page that I use for testig to see if it works...
  2. Hello, I am trying to use array in bind statement to avoid entering bind manually Below, I set up the array, then imploded the array to insert , on it // to return 1,2,5 , but I got error Warning: mysqli_stmt::bind_param(): Number of elements in type definition string doesn't match number of bind variables $arr = [1,2,5]; $arr_as_string = implode( ',',$arr); $type = 'iii'; $params = [$type,$arr_as_string]; $tmp = []; foreach($params as $key => $value) $tmp[$key] = &$params[$key]; call_user_func_array([$query, 'bind_param'], $tmp);
  3. When I try to display PDF , not working when pdf contains path, just working if the file is in the same index This Works <a href="myfile.pdf" target="_blank">View PDF</a> The below not working .. ERROR The requested URL was not found on this server. <a href="admin/assets/cvs/myfile.pdf" target="_blank">View PDF</a> I am sure that the path is right and I tested with .png extensions. Also I tried to use header function to display PDF with PHP but got also error even if the file in the same directory index Failed to load PDF document. $fileName = "myfile.pdf"; header('Content-type: application/pdf'); header('Content-Disposition: inline; filename="' .urlencode($fileName). '"'); header('Content-Transfer-Encoding: binary'); header('Content-Length: ' . filesize($fileName)); header('Accept-Ranges: bytes'); @readfile($fileName);
  4. Can anyone provide their method of getting the results to show as a table as the results it showing now is an unreadable mess, I'd also like the following css styling as follows: Padding: 20px Border: 1px solid grey th to be in light grey Id be greatfull if someone could put the code into a table as its driving me nuts lol Here is the code for showing the results: $sql = "SELECT animal_type, animal_breed, colour, owner_name, address, telephone, mobile, email, offence, offence_date, offence_location, case_status, case_ref, action_required, action_taken, microchipped, microchip_number, aggressive, dangerous, lost, date_lost, location_lost, stolen, date_stolen, location_stolen, found, date_found, location_found, other_information FROM `animals` WHERE 1"; $result = $conn->query($sql); if ($result->num_rows > 0){ while($row = $result->fetch_assoc() ){ echo $row["animal_type"]." ".$row["animal_breed"]." ".$row["colour"]." ".$row["owner_name"]." ".$row["address"]." ".$row["mobile"]." ".$row["email"]." ".$row["offence"]." ".$row["offence_date"]." ".$row["offence_location"]." ".$row["case_status"]." ".$row["case_ref"]." ".$row["action_required"]." ".$row["action_taken"]." ".$row["microchipped"]." ".$row["microchip_number"]." ".$row["aggressive"]." ".$row["dangerous"]." ".$row["lost"]." ".$row["date_lost"]." ".$row["location_lost"]." ".$row["stolen"]." ".$row["date_stolen"]." ".$row["location_stolen"]." ".$row["found"]." ".$row["date_found"]." ".$row["location_found"]." ".$row["other_information"]."<br>"; } } else { echo "0 records"; }
  5. I tried to use FIND_IN_SET() with prepared statement, but did work, do not return any result, or even errors if(escape($_POST['jobCategory']) != "all-categories" && escape($_POST['countryId']) == "all-countries" && escape($_POST['careerLevel']) == "all-career-levels"): $the_array = [77,181]; $job_id_imploded = implode(',',$the_array); $query = mysqli_prepare($dbConnection,"SELECT jobs.id, jobs.job_title, jobs.country_id, employers.employer_name FROM jobs LEFT JOIN employers ON jobs.employer_id = employers.employer_id WHERE job_status = ? AND FIND_IN_SET('id',?)"); mysqli_stmt_bind_param($query,'si',$job_status,$job_id_imploded); endif; mysqli_stmt_execute($query); mysqli_stmt_bind_result($query,$job_id,$job_title,$countryId,$employer_name); while(mysqli_stmt_fetch($query)){ ?> <div class="job-title"> <a href="job_post.php?job_id=<?php echo htmlspecialchars($job_id) ?>" class="job-title-link"><?php echo htmlspecialchars($job_title); ?></a> </div> <?php } // End While ?>
  6. I need to output the exact below array format from the mysqli_fetch_assoc rows The Array "Need to achieve like this" ["172"=>["4","6"],"174"=>["4","6"],"175"=>["4","3","6"],"176"=>["4","3"],"177"=>["4","6"],"181"=>["3","6"],"182"=>["7"],"183"=>["3","4"],"184"=>["4","3","6"],"185"=>["3","6"],"186"=>["8","6"],"188"=>["3","6"],"189"=>["3","6"],"190"=>["6"],"191"=>["3","6","4","7"]]; It's var_dump "Need to achieve like this" array(15) { [172]=> array(2) { [0]=> string(1) "4" [1]=> string(1) "6"} [174]=> array(2) { [0]=> string(1) "4" [1]=> string(1) "6" } [175]=> array(3) { [0]=> string(1) "4" [1]=> string(1) "3" [2]=> string(1) "6" } [176]=> array(2) { [0]=> string(1) "4" [1]=> string(1) "3" } [177]=> array(2) { [0]=> string(1) "4" [1]=> string(1) "6" } [181]=> array(2) { [0]=> string(1) "3" [1]=> string(1) "6" } [182]=> array(1) { [0]=> string(1) "7" } [183]=> array(2) { [0]=> string(1) "3" [1]=> string(1) "4" } [184]=> array(3) { [0]=> string(1) "4" [1]=> string(1) "3" [2]=> string(1) "6" } [185]=> array(2) { [0]=> string(1) "3" [1]=> string(1) "6" } [186]=> array(2) { [0]=> string(1) "8" [1]=> string(1) "6" } [188]=> array(2) { [0]=> string(1) "3" [1]=> string(1) "6" } [189]=> array(2) { [0]=> string(1) "3" [1]=> string(1) "6" } [190]=> array(1) { [0]=> string(1) "6" } [191]=> array(4) { [0]=> string(1) "3" [1]=> string(1) "6" [2]=> string(1) "4" [3]=> string(1) "7" } } My Code $query = mysqli_query($dbConnection,"SELECT id, job_category_id FROM jobs"); while($row = mysqli_fetch_assoc($query)){ $job_id = $row['id']; $job_category_id = htmlspecialchars($row['job_category_id']); $job_category_id = unserialize(base64_decode($job_category_id)); $asscArrays = [$job_id=>$job_category_id]; // Here I am trying to achieve the array template like the I mentioned above } var_dump $asscArrays array(1) { [172]=> array(2) { [0]=> string(1) "4" [1]=> string(1) "6" } } array(1) { [174]=> array(2) { [0]=> string(1) "4" [1]=> string(1) "6" } } array(1) { [175]=> array(3) { [0]=> string(1) "4" [1]=> string(1) "3" [2]=> string(1) "6" } } array(1) { [176]=> array(2) { [0]=> string(1) "4" [1]=> string(1) "3" } } array(1) { [177]=> array(2) { [0]=> string(1) "4" [1]=> string(1) "6" } } array(1) { [181]=> array(2) { [0]=> string(1) "3" [1]=> string(1) "6" } } array(1) { [182]=> array(1) { [0]=> string(1) "7" } }
  7. Hello I need to find a way to close loop outside if condition like below example if(escape($_POST['jobCategory']) != "all-categories" && escape($_POST['countryId']) == "all-countries"): $query = mysqli_query($dbConnection,"SELECT jobs.id, jobs.job_title, jobs.salary, jobs.employer_id, employers.employer_name, employers.employer_logo FROM jobs LEFT JOIN employers ON jobs.employer_id = employers.employer_id WHERE job_status = '".mysqli_real_escape_string($dbConnection,'Active')."' AND id IN (".mysqli_real_escape_string($dbConnection,$job_id_imploded).") "); while($row = mysqli_fetch_assoc($query)){ // Start Loop $job_id = $row['id']; $job_title = $row['job_title']; endif; <div class="job-title"> <a href="job_post.php?job_id=<?php echo htmlspecialchars($job_id) ?>" class="job-title-link"><?php echo htmlspecialchars($job_title); ?></a> </div> } // End Of Loop Gives me error HTTP ERROR 500
  8. I have no experience of doing command-line stuff, so am hoping to find some way of installing Webalizer that uses simple ftp to upload files and some way of calling the program to run. 25 years internet experience and some ability with php/mysql, but I don't understand where the Webalizer files go (in a directory, yes, and with a log file to analyse) but *where* to put them and *how* to call them, I haven't figured out at all (yet). I have heard that the latest stable Webalizer version is 2.23 but (also) don't know where to get this from. Any help appreciated.
  9. Hi all I am trying to create something like 2023-2024 in a loop so that each year it generate the session for me. I don't want to manually add it. What I did did not work (though I know it won't work but just did it anyway) $cur_yr = date('Y'); $nxt_yr = date('Y', strtotime('+1 year,); $cur_session = $cur_yr."-".$nxt_yr; $strt_session = "2020-2021"; for($i = $strt_session; $i<= $cur_session; $i++){ echo $i; } Mine won't work. But how can I get it done. Thanks in anticipation
  10. Hello all. I have worked my head out but i cant seem to figure out why i am getting error/entering empty stings. I have tried different things but none seems to work as expected. i know the problem is from the array field validation but cant seem to figure out how to get it done. If i submit without entering any field, the error works fine. But if i fill only one field, it gives error and saves empty strings. Thanks if(isset($_POST['submit'])) { $test_score = $_POST['test_score'][0]; $exam_score = $_POST['exam_score'][0]; if(empty($test_score)) { $error['test_score'] = "Test Score Field is Required"; }if(empty($exam_score)) { $error['exam_score'] = "Exam Score Field is Required"; } if(empty($error)) { foreach ($_POST['subject'] as $key => $value) { $sql = "INSERT INTO $table_name( subject, test_score, exam_score ) VALUES( :subject, :test_score, :exam_score )"; $stmt = $pdo->prepare($sql); $stmt->execute([ 'subject' => $value, 'test_score' => $_POST['test_score'][$key], 'exam_score' => $_POST['exam_score'][$key] ]); } if($stmt->rowCount()){ echo '<div class="alert alert-success text-center">Data Saved</div>'; }else{ echo '<div class="alert alert-danger text-center">Data Not Saved</div>'; } }else{ echo '<br><div class="alert alert-danger text-center">Fields Empty!</div>'; } } //my form <table class="table table-borderless"> <thead> <tr> <th>SN</th> <th>Subject</th> <th>Continuous Assesment Score</th> <th>Examination Score</th> </tr> </thead> <tbody> <div> <form action="" method="post"> <?php $i = 1; $stmt=$pdo->query(" SELECT subjects FROM tbl_subjects_secondary "); WHILE($row = $stmt->fetch(PDO::FETCH_ASSOC)){ ?> <tr> <th><?php echo $i++ ?></th> <td><input type="text" name="subject[]" class="form-control border-0" readonly value="<?php if(isset($row['subject_name'])) { echo $row['subject_name']; } ?>"></td> <td><input type="number" name="test_score[]" class="form-control"><span style="color: red; font-size: .8em;"><?php if(isset($error['test_score'])){ echo $error['test_score'];} ?></span></td> <td><input type="number" name="exam_score[]" class="form-control"><span style="color: red; font-size: .8em;"><?php if(isset($error['exam_score'])){ echo $error['exam_score'];} ?></span></td> </tr> <?php } ?> <tr> <td></td><td></td> <td colspan="2"><button type="submit" name="save" class="btn btn-primary w-50">Save</button></td> </tr> </form> </div> </tbody> </table>
  11. As long as it's SQL injection proof, would it be alright for me to let non-members add comments to a post and give the Author the ability to delete them?
  12. Hello... I have a form to get some urls from users. Eg: Web Address, Facebook Address, Twitter Address, Google+ address etc... My problem is how I validate these urls when they submit the form. I tried to validate URL in PHP by using the FILTER_VALIDATE_URL or simply, using regular expression. Here, I would like to know what are the best methods to get such a urls from users. Is it always good to let them to enter protocol? sometimes they may not know it is http, https, ftp, ftps.. etc. I think it is something hard to do some users. I tried something like this using FILTER_VALIDATE_URL, But it always use protocol and sometime I am confusing how its work.. // validate url $url = 'http://example.com'; if (filter_var( $url, FILTER_VALIDATE_URL)){ echo "<br>valid"; } else { echo "<br>invalid"; } [b]OUTPUT[/b] : valid // validate url $url = 'http://example.com?id=32&name=kamalani'; if (filter_var( $url, FILTER_VALIDATE_URL)){ echo "<br>valid"; } else { echo "<br>invalid"; } [b]OUTPUT[/b] : valid Can you tell me what are the best ways to get urls from user and how those validate? Any comments are greatly appreciating.. Thank you.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.