Jump to content

Search the Community

Showing results for tags 'database 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

Found 3 results

  1. I've been trying to write some code that takes user supplied information, sends it to a database (phpmyadmin) and also displays it elsewhere in the app. I'm to the point I'm trying to get it to the database right now. The issue is that it's not making it to the DB and is being lost somewhere. There's no warnings, no errors, nothing being returned anywhere to help resolve the problem, except in the browsers dev tools and that is different whether it's chrome or FF. It's also something that I have trouble seeing being responsible for the loss of data. In Chrome it comes back as -> Page layout may be unexpected due to Quirks Mode In FF as -> Layout was forced before the page was fully loaded. If stylesheets are not yet loaded this may cause a flash of unstyled content. But, like I said, I can't see how this is to blame for the data not making it to the DB and I see no difference in the layout or style anyways. At the top of add_post.php is the following: <?php require("assets/initializations.php"); if(isset($_POST['add_post']) && !empty($_FILES['post_image'])) { $filename = $_FILES['post_image']['name']; $file_tmp_name = $_FILES['post_image']['tmp_name']; $filesize = $_FILES['post_image']['size']; $file_ext = explode('.', $filename); $file_act_ext = strtolower(end($file_ext)); $allowed = array('jpeg', 'jpg', 'png', 'gif'); if(!in_array($file_act_ext, $allowed)) { echo "<script>alert('File Type Not Allowed');</script>"; //not sure how well this size check is working, have to experiment more //also need to research how to do an initial image check } elseif($filesize > 10000000) { echo "<script>alert('Image Is Too Large');</script>"; } else { $file_new_name = uniqid('', true) . "." . $file_act_ext; $dir = "/opt/lampp/htdocs/qcic/usernet/img/"; $target_file = $dir . basename($file_new_name); move_uploaded_file($file_tmp_name, $target_file); $post_obj->addNews( $_POST['title'], $_POST['content'], $_POST['category'], $_POST['status'], $_POST['post_type'], $_POST['tags'], $target_file ); echo "<script>alert('Your Post Has Been Added');</script>"; mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT); } } ?> <?php require('includes/header.php'); ?> Most of it is handling the image. The Post and User objects are instantiated in initializations.php at the top. The image uploads fine, everything works except the post object. The class for that is -> <?php class Post { private $conn; private $user_obj; public function __construct($conn, $user) { $this->conn = $conn; $this->user_obj = new User($conn, $user); } public function addNews($title, $content, $category, $status, $type, $tags, $image) { if(!empty($title) && !empty($content)) { $title = strtoupper($title); $title = mysqli_real_escape_string($this->conn, $title); $content = nl2br($content); $content = mysqli_real_escape_string($this->conn, $content); $added_by = $this->user_obj->getUsername(); $query = mysqli_query($this->conn, "SELECT top_cat_id FROM top_categories WHERE top_cat_title='$category'"); $row = mysqli_fetch_array($query); $cat_id = $row['top_cat_id']; $statement = $this->conn->prepare("INSERT INTO news VALUES ('', '$title', '$content', '$added_by', '$category', '$cat_id', '$image', '$tags', '$status', '$type', '?', '?', '?', '?');"); if($statement) { $statement->execute(); } else { echo "You messed up somewhere"; } } } } ?> I'm not the best or most experienced coder, for sure, but in the few months I've been learning PHP I've written a few DB queries now and this looks right to me. The first attempt didn't have prepared statements but that wasn't getting the data to the DB either. I've checked that the number of fields being sent match the number of fields in the DB, been tinkering with a few small things since yesterday on it, nothing works and as I said, no error or warning is coming back to work from, no message at all to work from. The only thing it triggers is those 2 console messages I mentioned above and the image does get to its new location. It's to the point now I'm just blank-mindedly staring at code. I'm not even getting back the else echo "You messed up somewhere" error from the final if statement, just the javascript alert that it was sent correctly, which it wasn't. I can really use some guidance on this one, thank you
  2. What is the best table structure when constructing what will be a potentially large multi-user platform? Example- Each user inputs their own individualized information into a table, for recall only to that specific user and to certain other users defined as administrators or half-administrators super users. Would it be better to store this all in a single table, or to give each user their own individual table on formation of the account?
  3. Hi all am trying to update the database table by submitting a form and used isset (0 function but is shows nothing what can I do? here's my code!!! <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title></title> <link rel="stylesheet" href="main.css" type="text/css"> </head> <body background="media/dark_blue_background-wallpaper-1920x1200.jpg"> <center> <?php session_start(); if ($_SESSION['uname']) { ?> <div id="bus"> <p><img src="media/rk_logo2.png" height="100" width="220"></p> <ul> <li style="float: right; padding-right: 10px; font-family: sans-serif; font-weight: bold;">You are Logged in as, <?php echo "" . $_SESSION['uname'] . "!"; ?></li> </ul><br><hr> <?php } $host = "localhost"; $uname = "root"; $pass = "pranit"; $db_name = "rk_bookings"; $tbl_name = "bus_details";[/size][/color][/font] [font="Verdana, Geneva, sans-serif"][color="#333333"][size=3] mysql_connect("$host", "$uname", "$pass") or die("cannot connect"); mysql_select_db("$db_name") or die("cannot select DB");[/size][/color][/font] [font="Verdana, Geneva, sans-serif"][color="#333333"][size=3] $coname = $_POST['coname']; $dest = $_POST['destination']; $sql = "SELECT * FROM $tbl_name WHERE company='$coname' and destination='$dest'"; $result = mysql_query($sql) or die(mysql_error()); $rows = mysql_fetch_array($result, MYSQLI_ASSOC); ?> <div id="disp"> <form action="update.php"> <table> <tr> <th>Company Name</th> <th>Bus Facilities</th> <th>Depart Time</th> <th>Arrival Time</th> </tr> <tr> <td><input type="text" name="coname" value="<?php echo $rows['company']; ?>"></td> <td><input type="text" name="aminities" value="<?php echo $rows['aminities']; ?>"></td> <td><input type="text" name="depart" value="<?php echo $rows['depart']; ?>"></td> <td><input type="text" name="arrive" value="<?php echo $rows['arrive']; ?>"></td> </tr> <tr> <th>Duration</th> <th>Rate</th> <th>From</th> <th>To</th> </tr> <tr> <td><input type="text" name="duration" value="<?php echo $rows['duration']; ?>"></td> <td><input type="text" name="rate" value="<?php echo $rows['price']; ?>"></td> <td><input type="text" name="start" value="<?php echo $rows['start']; ?>"></td> <td><input type="text" name="destination" value="<?php echo $rows['destination']; ?>"></td> </tr> <tr> <th style="border: none; background: none;"></th> <td></td> <th style="border: none; background: none; float: right;"></th> </tr> </table> <button type="submit" name="submit">Update!</button><br><br><br> </form> <strong><a href="home.php">Click Here to Go Back!</a></strong> <br><br><br> </div> </body> </html>[/size][/color][/font] [font="Verdana, Geneva, sans-serif"][color="#333333"][size=3]
×
×
  • 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.