Jump to content

All Activity

This stream auto-updates     

  1. Today
  2. saynotojava

    Ajax call without reloading ?

    Figured out that one as well - i had jquery include in http url, and for some reason firefox is blocking js load in case of protocol mismatch.
  3. maxxd

    HELP ME, NEED PHP ARTICLE SCRIP?

    WORDPRESS!!! Seriously, it's easy to set up, and given your "question" and style of asking should be very doable for you without spending too much money or time. If your site ends up getting a lot of traffic or you want to do something slightly more advanced or intricate you'll want to learn some php and JavaScript, but if you're just starting out it should do you fine.
  4. Yesterday
  5. ginerjm

    HELP ME, NEED PHP ARTICLE SCRIP?

    What is an "article script"? If you don't know how to write PHP code, I suggest you start with something small and something you fully understand and learn how to write PHP code, as well as a website. And how to ask decent questions....
  6. NotionCommotion

    cURL both a file and POST data

    Because it won't work if I don't.
  7. You'll want to review the syntax for heredoc. Hint: it doesn't use greater than. Here's an example from the manual: http://php.net/manual/en/language.types.string.php#example-46
  8. echo >>>HEREDOC <table name='AccountInfo'><form method='post' action='<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>' enctype='multipart/form-data'> <tr><th><span class='fieldname'>Username:</span></th><td><?php echo $user; ?></td></tr> <tr><th><span class='fieldname'>Password:</span></th><td><input type='password' size='16' name='pass' value='<?php echo $pass; ?>'></td></tr> <tr><th><span class='fieldname'>First Name:</span></th><td><input type='name' size='16' maxlength='16' name='fname' value='<?php echo $fname; ?>'></td></tr> <tr><th><span class='fieldname'>Last Name:</span></th><td><input type='name' size='16' maxlength='16' name='lname' value='<?php echo $lname; ?>'></td></tr> <tr><th><span class='fieldname'>Email:</span></th><td><input type='email' maxlength='20' name='email' value='<?php echo $email; ?>'></td></tr> <tr><th><span class='fieldname'>Phone:</span></th><td><input type='tel' maxlength='10' name='phone' value='<?php echo $phone; ?>'></td></tr> <tr><th><span class='fieldname'>Title:</span></th><td><input type='title' maxlength='16' name='title' value='<?php echo $utitle; ?>'></td></tr> <tr><th><span class='fieldname'>Company:</span></th><td><input type='text' maxlength='20' name='company' value='<?php echo $company; ?>'></td></tr> <tr><th><span class='fieldname'>Website:</span></th><td><input type='url' maxlength='20' name='website' value='<?php echo $website; ?>'></td></tr> <tr><th><span class='fieldname'>Mailing Address:</span></th><td><input type='address' maxlength='30' name='snailmail' value='<?php echo $snailmail; ?>'></td></tr></table> <tr><td><input type='submit' value='Save Info'></td></tr></form></div><br> <h3>Upload/Edit Account Photo</h3> <table name='UploadPhoto'><form method='post' action='<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>' enctype='multipart/form-data'> <tr><th>Select a Photo:</th><td><input type='file' name='image'></td><td><input type='submit' value='Save Photo'></td></tr></form></div><br></center> HEREDOC; I keep getting this error: [16-Oct-2018 12:05:16 UTC] PHP Parse error: syntax error, unexpected '>>' (T_SR) in /home/iqy0804tq6fq/public_html/portal/account.php on line 247 There is no whitespace, I can't figure out why '>>' all of a sudden causes an error.
  9. NotionCommotion

    cURL both a file and POST data

    Thanks kicken, Why do you think I will need urldecode()? See below outputs. Also, back to my original line of thought, any reason (other than being non-typical and thus confusing maybe) that the data array couldn't be transferred in the url and arrive as GET parameters, and CURLOPT_POSTFIELDS used solely for files? With uldecode(): Array ( [name] => Kicken [date[month]] => 10 [date[day]] => 15 [date[year]] => 2018 [date[extraSeq][0]] => a 1 [date[extraSeq][1]] => b 1 [date[extraSeq][2]] => c 1 [date[extraAssoc][a 1]] => A 1 [date[extraAssoc][b 1]] => B 1 [date[extraAssoc][c 1]] => C 1 ) Without uldecode(): Array ( [name] => Kicken [date%5Bmonth%5D] => 10 [date%5Bday%5D] => 15 [date%5Byear%5D] => 2018 [date%5BextraSeq%5D%5B0%5D] => a+1 [date%5BextraSeq%5D%5B1%5D] => b+1 [date%5BextraSeq%5D%5B2%5D] => c+1 [date%5BextraAssoc%5D%5Ba+1%5D] => A+1 [date%5BextraAssoc%5D%5Bb+1%5D] => B+1 [date%5BextraAssoc%5D%5Bc+1%5D] => C+1 )
  10. benanamen

    HELP ME, NEED PHP ARTICLE SCRIP?

    Help you with what? Help you code it? Help you hire somebody to code it? Help you to find out where you can buy it? Feel free to ask an actual question.
  11. I WANT TO MAKE NEWS PORTAL SITE, I NEED ARTICLE SCRIPT, PLZ HELP ME!!!
  12. requinix

    cURL both a file and POST data

    Probably.
  13. kicken

    cURL both a file and POST data

    Looking at that comment on PHP.net linked earlier, it seems like you just need to make sure your $data array is a single dimension. You can use http_build_query to do some of the work of converting your potentionaly multi-dimensional array into a single dimension, then add your files to the end. For example: <?php $data = [ 'name' => 'Kicken' , 'date' => [ 'month' => 10 , 'day' => 15 , 'year' => 2018 ] ]; $files = [ 'photo' => [ 'tmp_name' => '/tmp/blah.jpg' , 'type' => 'image/jpeg' , 'name' => 'blah.jpg' ] , 'cv' => [ 'tmp_name' => '/tmp/cv.txt' , 'type' => 'text/plain' , 'name' => 'cv.txt' ] ]; $postData = []; foreach (explode('&', http_build_query($data)) as $pair){ list($name, $value) = explode('=', $pair, 2); $postData[$name] = $value; } foreach ($files as $name=>$file){ $postData[$name] = new \CURLFile($file['tmp_name'],$file['type'],$file['name']); } var_dump($postData); Output: array(6) { 'name' => string(6) "Kicken" 'date%5Bmonth%5D' => string(2) "10" 'date%5Bday%5D' => string(2) "15" 'date%5Byear%5D' => string(4) "2018" 'photo' => class CURLFile#1 (3) { public $name => string(13) "/tmp/blah.jpg" public $mime => string(10) "image/jpeg" public $postname => string(8) "blah.jpg" } 'cv' => class CURLFile#2 (3) { public $name => string(11) "/tmp/cv.txt" public $mime => string(10) "text/plain" public $postname => string(6) "cv.txt" } } You could also make your own version of http_build_query that's aware of CURLFile if that'd make things easier. Then you could just build up your $data array with the file objects where they need to be and then collapse it with your custom function. edit: Might need to urldecode() the name/value pairs after the http_build_query, not sure on that.
  14. benanamen

    Why If Not Statement Fetch Condition Fails ?

    Depending on what forum you are on and how many times he was banned from it or how many duplicate accounts he signed up will determine which of the at least 10 usernames the OP goes by. It would make a heck of a switch statement if you were to program it out.
  15. Me too. "Tables are not for layout" happened a few years back and that's nice, but people are still using tables for layout - just not with a <table>. What happened was people went right off the deep end, fixated on avoiding <table>s even for tabular data because people got it drilled into them that Tables Are Bad (tm). No. Tables are not bad. Tables have a purpose. What's bad is using tables for the wrong purpose, but it's just as bad as not using tables for the wrong reason. Tabular data doesn't have to involve numbers or math. It simply involves rows and columns, and if the stuff being put on the page has a row/column or other 2D nature then the row/column element is a good place to go. And responsive design can happen just as well with tables as it can grids. It's just as easy to force inline-block on a div as on a table cell. If you really have to do that. But damn, don't get me started on responsive design, one rant for today is enough.
  16. I lost track of the number of of times I've forgotten those dumb bootstrap classes on buttons and wondered "WTF isn't this looking like it should?" I always hated this about css grid setups too. Having 'col', 'row', 'col-x', etc scattered everywhere, but I guess that's what happens why you try and use a generic grid framework. Now that I'm using SCSS more often I'll generally use a grid that includes a scss distribution so I can integrate it into my more meaningful rules. I'm still not perfect, but I'm a lot better now than I was 5 years ago at this stuff.
  17. requinix

    cURL both a file and POST data

    PHP parses query strings automatically (for $_GET) by using parse_str(). http_build_query() is the opposite of that. It's great for building query strings that you want to embed in links or forms or wherever that you need to get the query string as a, well, string. But the situation there is that you need it as a string. Like if you wanted to pass $_GET to another script you would <a href="/path/to/script.php?<?=htmlspecialchars(http_build_query($_GET))?>">Link</a> Not only is creating that query string manually yourself difficult with something dynamic like $_GET (you don't know the parameters), you'd also have to deal with URL-encoding stuff. http_build_query does all that. To make this even more complicated, consider <a href="/path/to/script.php?<?=htmlspecialchars(http_build_query(["get" => $_GET]))?>">Link</a> then in the other script parse_str($_GET["get"], $get); Point is, it takes a $_GET-type array and gives you a string, and you use it because you want the string. If you don't want or need a string, like you wouldn't with CURLOPT_POSTFIELDS because cURL will do that for you, then you wouldn't use it. Yes. There are two types of POST bodies, so to speak. The normal one is "application/x-www-form-urlencoded" and sends data that looks and works just like a query string, except it goes in the request body instead of in the URL. The other one, needed by file uploads, is "multipart/form-data" and is much less compact and incidentally much more human readable. If you're using cURL for an upload then you'll have to get that second format. http_build_query won't help you there. The problems are indeed because it's not going in the URL. And yes, $_GET values are in the URL - $_GET is always from the URL, $_POST is always the POSTed data (if it's one of the two body types I mentioned above). The REQUEST_METHOD doesn't switch where data goes but rather instructs PHP that it should look for the presence of POSTed data. Kinda.
  18. Last week
  19. NotionCommotion

    cURL both a file and POST data

    Thanks requinix, Even before seeing your reply, I came to the same conclusion. I thought http_build_query converts an array such that it could be sent in the URL. Which never made sense to me that I would use to pass to POSTFIELDS. I mean, is it in the body or the url? Granted, I need to better understand the http protocol. And if in the url, why am I having these problems? I know that a post request could also have $_GET values which are presumably passed not in the body but the url. Dang, wife is telling me I need to take the dog for a pop. function convert($x) { $rs=[]; if(!is_array($x) && !is_object($x)) { throw new Exception('not an array or object'); } foreach($x as $key=>$value) { if(is_array($value) || is_object($value)) { $rs[$key]=convert($value); } else { $rs[$key]=$value; } } return $rs; } <?php echo('$_POST:<br>'); var_dump($_POST); echo('<br>$_GET:<br>'); var_dump($_GET); echo('<br>'); $a=['x'=>123, 'y'=>[5,7,9,0], 'z'=>['a'=>123,'b'=>321,'c'=>111]]; $http_build_query=http_build_query($a); echo('$http_build_query: '.$http_build_query.'<br>'); $converted=convert($a); echo('$converted '.var_dump($converted).'<br>'); $x=123; ?> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>?a=1&b=2&c=3"> <input type="text" name="name"><br> <input type="submit" name="submit" value="Submit Form"><br> </form>
  20. So we all (most of us) know some CSS. You might not consider yourself a web designer, be fluent with all the popular libraries, but you know your way around how to do it. Like if you want to make something bold you could inline it <span style="font-weight:bold;">An important statement</span> but you're smarter and you know you should .bold { font-weight: bold; } <span class="bold">An important statement</span> A trivial example, of course, but it demonstrates how you should use CSS. Right? No. God damn *#(*^y$&#ing NO. So maybe it's a bad example. People don't actually do that. Okay. Let's look at some official Bootstrap examples instead. <button type="button" class="btn btn-lg btn-default">Default</button> No. <table class="table table-striped"> Stop that. <ul class="list-group"> <li class="list-group-item">Cras justo odio</li> Dude. What's the problem here? You're restating the obvious! I know that button is a button. It's got #*^(ing "button" right in the (*^-@$ markup. Ooh, it's a LARGE button. Wow! And hey, that table has stripes? Amazing! And you mean to tell me that UL is a list and the LI is an item? You're blowing my mind! You're also DOING IT WRONG. The power behind CSS is (a) not having to tell the browser that yes, in fact, that button really is a button, and (b) not having to say the same thing over and over again in different places. And that is where Bootstrap fails miserably. You want to create a button? Go ahead. Create the button. Then throw a few classes at it so it looks the way you want. Want another button? Create another button and throw classes at that one too. Created a button and it doesn't look right? Oh damn, you forgot one of the classes you have to include. Ha ha, oops. "But that's how CSS should be used!" No. You're all missing the (*@#*^ing point and making everything hard on yourself and the people who have to deal with your crap. What if I want to add a dropdown list of items? What should I do? The page already has a couple dropdowns on it so I know the styling is in place. I'll add a simple <select> and... nope, looks like a plain list. No styling applied. What happened? What happened is that I didn't apply the handful of classes necessary to make the list appear like the damn list it should already be. What happened is that I forgot I have to add in the presentation aspects to my HTML. And that's what this whole stupid thing boils down to: people can't shift their mindset away from the presentation, and while they know not to mix presentation with markup they've not noticed that all they did was trade one syntax for another. The problem is still (@^$ there. "Oh, right, yeah, if you're so smart then how would you do it?" Thank you for asking. You want a button. You want a large button. You want a large button that draws peoples' eyes to it because it's the button they probably want to use and so it's the default. That's presentation. Forget about presentation. You want a default button. That's it. That's all you should have to care about. <button type="button" class="default">Default</button> Done. "But no, it doesn't look the way I want!" I don't give a damn how you want it to look. I want to know what the button means. What is the significance behind the button. What does it represent. Because ultimately that's what the HTML markup needs to concern itself with. Write semantic markup and leave out the presentation crap because it has no place in the document. "Oh, so you think we shouldn't have any CSS at all or what?" Take those words out of my mouth before I cram them back down yours. button { /* make it look like a nice button */ } button.default { /* blue or whatever */ } There. Now the presentation is accounted for in the @(!^)$ place where it should be: CSS. And if I want to add another default button somewhere I don't have to look up the Bootstrap reference because I don't remember which 5 classes are relevant. Default button? Default button. The only way this could improve is if HTML added a way to actually identify the default button of a form, in which case that class=default goes right out the damn window and the CSS targets that new attribute or whatever it is instead. "Noo, it's not a large button!" Alright. Fine. Let me take a deep breath before I have to deal with you. So. Why do you want it to be large? Don't give me some stupid reason like "because I want it to be large". What is the reason behind making it large? What decision process did you go through in your head that resulted in the button needing to be larger? Why is the normal size for buttons not appropriate? Maybe the form is a modal and you want larger buttons? Okay. Did you mark the form as modal? Because that's the first thing you have to do. <form class="modal"> form.modal button { /* larger */ } And done. Problem solved. Problem solved in a way that keeps the appearance of the button separate from the markup of the button. Want to add another button to the modal? Go on. Add another stupid button. One that doesn't require any classes just because it's supposed to be larger. What you might be able to realize here is that now I've established a rule saying "buttons in modal forms are larger". And it applies everywhere you have a modal form. If you make another modal form then magically the buttons are larger there too! And without having to find that first place you had that one modal form, what page was that again, oh right, over here, now what classes and CSS files did I have to use for it to make it look that way, oh right, those classes. How about a striped table? Why is it striped? Because it's a table that will grow vertically and has enough data in its columns that people need help scanning through them? So what you're telling me is that the table is, say, "dense"? <table class="dense"> table.dense > tbody > tr:nth-child(odd) { /* striped */ } Somehow I'm able to rub a couple brain cells together and end up with a way of identifying the table for what it is and not what I want it to look like on the page. How about a regular list? Nothing special? <ul> <li>Cras justo odio</li> Nothing (*&^!@ special. Now when I come along, I can write markup into your fancy page you spent a couple days tweaking until it looked oh so pretty, and I don't have to run off to the kitchen where I can cool my heels instead of planning your "accidental" death because I can write simple, logical, and minimal HTML that represents what I'm adding without having to fire up five different browsers to see that I got all the required classes. What's more, if someone decides that modal dialogs on mobile devices need to look a little different, I don't have to spend a day searching the codebase for anything modal because the work has gone from "go fix all the modal dialogs to use this new CSS class someone wrote" to "apply media queries to adjust the existing modal dialog to better suit mobile screens". This isn't damn rocket science. I know you web designers had a hard time in college with your liberal arts degree and that's it's so unfair you have to work with computer graphics instead of living in a loft painting bowls of fruit all day, but surely even you are smart enough to understand these principles. Stop thinking with your eyes and start thinking with your brain. And now I go back to work. Dealing with stupid crap. That I put off by ranting about it here.
  21. requinix

    cURL both a file and POST data

    Building the request body manually is worse. 1. You cannot use CURLFile and http_build_query. You have to choose. 2. You know what http_build_query does, right? You know what passing an array for POSTFIELDS does, right? If you've decided that the hammer for this screw will be http_build_query then you're in for a hard time.
  22. NotionCommotion

    cURL both a file and POST data

    I would rather use http_build_query() if possible. https://gist.github.com/maxivak/18fcac476a2f4ea02e5f80b303811d5f seems to give a solution. Think it is a preferred solution?
  23. slproject

    Help with sqlite

    It seems I just solved it It was the isset() that was giving me trouble... Without it, it works fine. Thank you all!
  24. slproject

    Help with sqlite

    <center><img src=img/glogo.png width=300> <form action=search.php method=GET> <input type=text size=30 name=search value=<?= $_GET['search'] ?>> <input type="submit" value="Search"> <?php $search = isset($_GET['search']) ? $_GET['search'] : null; if (is_null($search)) { exit("<p>Nothing to display, please enter a searchstring."); } $fileName = __DIR__ . $database2; $dsn = "sqlite:$fileName"; try { $db = new PDO($dsn); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch (PDOException $e) { echo "Failed to connect to the database using DSN:<br>$dsn<br>"; throw $e; } $sql = "SELECT * FROM familyMembers WHERE Name LIKE ? OR Relation LIKE ? OR Age LIKE ?"; $stmt = $db->prepare($sql); $params = [$search, $search, $search]; $stmt->execute($params); $result = $stmt->fetchAll(PDO::FETCH_ASSOC); $rows = null; foreach ($result as $row) { echo "<p>|$row|</p>"; $rows .= "<tr>"; $rows .= "<td>{$row['Name']}</td>"; $rows .= "<td>{$row['Age']}</td>"; $rows .= "<td>{$row['Relation']}</td>"; $rows .= "</tr>\n"; } echo <<<EOD <table> <tr> <th>Name</th> <th>Age</th> <th>Relation</th> </tr> $rows </table> EOD; ?>
  25. mac_gyver

    Help with sqlite

    it would be nice if you posted your code that's setting the $search variable (you could be doing something that you think is correct, but isn't) and your code using $result (you could be doing something that you think is correct, but isn't.)
  26. slproject

    Help with sqlite

    I totally respect that
  27. Barand

    Help with sqlite

    My mother told me not to accept files from strangers.
  28. slproject

    Help with sqlite

    Sorry, not that good at the command line stuff 😐 If anyone want to try or check the database it can be found here: http://www.student.bth.se/~kear18/dbwebb-kurser/htmlphp/me/kmom05/me5/db/family.sqlite
  1. Load more activity
  • Newsletter

    Want to keep up to date with all our latest news and information?

    Sign Up
×

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.