-
Posts
35 -
Joined
-
Last visited
Everything posted by 0xMatt
-
To any of my fellow IRC users reading this, we are in ##phpfreaks on freenode until this is resolved, come play with us
-
Any news on when IRC is gonna be back?
-
Store the ID Number Inside "One" Array Inside For Loop?
0xMatt replied to glassfish's topic in PHP Coding Help
Based on what you've said you know what you should do you just haven't written any code to do so. You want to insert the related IDs onto the thread tables image_file_id column as comma-separated-values. I may be misunderstanding your issue, but this is what it sounds like you want: <?php $desired_width = 110; if (isset($_POST['submit'])) { $j = 0; //Variable for indexing uploaded image for ($i = 0; $i < count($_FILES['file']['name']); $i++) {//loop to get individual element from the array $target_path = $_SERVER['DOCUMENT_ROOT'] . "/gallerysite/multiple_image_upload/uploads/"; //Declaring Path for uploaded images $validextensions = array("jpeg", "jpg", "png"); //Extensions which are allowed $ext = explode('.', basename($_FILES['file']['name'][$i]));//explode file name from dot(.) $file_extension = end($ext); //store extensions in the variable $new_image_name = md5(uniqid()) . "." . $ext[count($ext) - 1]; $target_path = $target_path . $new_image_name;//set the target path with a new name of image $j = $j + 1;//increment the number of uploaded images according to the files in array if (($_FILES["file"]["size"][$i] < 100000) //Approx. 100kb files can be uploaded. && in_array($file_extension, $validextensions)) { if (move_uploaded_file($_FILES['file']['tmp_name'][$i], $target_path)) {//if file moved to uploads folder echo $j. ').<span id="noerror">Image uploaded successfully!.</span><br/><br/>'; $tqs = "INSERT INTO images (`original_image_name`, `image_file`, `date_created`) VALUES ('" . $_FILES['file']['name'][$i] . "', '" . $new_image_name . "', now())"; $tqr = mysqli_query($dbc, $tqs); // Select the ID numbers of the last inserted images and store them inside an array. // Use the implode() function on the array to have a string of the ID numbers separated by commas. // Store the ID numbers in the "image_file_id" column of the "thread" table. $tqs = "SELECT `id` FROM `images` WHERE `image_file` IN ('$new_image_name')"; $tqr = mysqli_query($dbc, $tqs) or die(mysqli_error($dbc)); $fetch_array = array(); $row = mysqli_fetch_array($tqr); $fetch_array[] = $row['id']; /* * This prints e.g.: Array ( [0] => 542 ) Array ( [0] => 543 ) Array ( [0] => 544 ) */ $values = rtrim(implode(', ', $fetch_array)); // Should print, "542, 543, 544" no whitespace if(!mysqli_query($dbc, "INSERT INTO thread (image_file_id) VALUES ('{$values}')")) { die(mysqli_error($dbc)); } // Goes over to create the thumbnail images. $src = $target_path; $dest = $_SERVER['DOCUMENT_ROOT'] . "/gallerysite/multiple_image_upload/thumbs/" . $new_image_name; make_thumb($src, $dest, $desired_width); } else {//if file was not moved. echo $j. ').<span id="error">please try again!.</span><br/><br/>'; } } else {//if file size and file type was incorrect. echo $j. ').<span id="error">***Invalid file Size or Type***</span><br/><br/>'; } } } If this isn't what you want, I would need you to elaborate more on what your end goal is. -
Here's the same question you're asking over on reddit. The first response is by the creator of Laravel. Also, googling the phrase "why choose Laravel" yields a lot of results. I've been using it quite some time, and though I'd really like to learn Symfony, I'm fine with Laravel for the time being.
-
You cannot receive a redirect error if the page isn't even trying to redirect or send with a 3xx. Double check and make sure you modified and saved the correct file and cleared your browsers cache just in case.
-
That has nothing to do with his issue and I question if you actually read the OP's post. stefanlesik, I would ask what your real issue is apart from you not liking how your code is setup. There is another method however, you can build your own custom array set storing the page id as a key and the value as the page url you want. <?php // This pseudo code would need to be replaced with your own setup.// The key is the page id while the value is the url you want to provide. $data = array(1 => 'first_route', 2 => 'second_route'); foreach($data as $page_id => $url){ if(is_page($page_id)) { $appLink = 'http://site.com/' . $url; }} Remember, is_page() accepts things other than the pages id such as the title or slug. e.g is_page('Homepage');
-
Of course you are getting that error, you are redirecting inside your while loop. As for the query failure, you'll need to post the error message supplied.
-
I disagree. If you build your own framework and document the code well, it'd be quite easy to build documentation with tools like apigen or phpdoc, making it easy for developers to understand. Actually, doing that is anything but lazy. Also, say a big company like facebook uses their own framework(if not, the example still stands) which is proprietary. So if I get hired by facebook and later decide to leave, will my knowledge of that framework be 100% useless? In a sense, yes, but only in the sense that I can no longer use their framework. What matters is that you get to broaden your horizons and open up your eyes to new perspectives. That is what PHP and programming in general is all about: learning, creating and then doing it better, over and over again. Nothing is ever useless if you put your time and effort into it, trial and error.
-
eduTrac: An Open Source Student Information System
0xMatt replied to NomadicJosh's topic in Beta Test Your Stuff!
I like it and I think it looks really good. I'm just not too fond of the framework you used as the foundation. -
A problem with a new php website that we're building...
0xMatt replied to eddyb's topic in Miscellaneous
Why are you using phpbb2? even phpbb3 is outdated having it's last release 3.0.11 come out 8/25/2012. Anyway, if you really insist on phpbb2 then I recommend a reCaptcha plugin which still works effectively well. -
It should be done in CI configuration. Honestly though, CI is dead and no longer being updated or maintained. It's even listed as a legacy framework: https://github.com/codeguy/php-the-right-way/wiki/Frameworks
-
return $conn -> affected_rows > 0; Will always return false. return ($conn->affected_rows > 0) ? true : false; is what you want. Edit: Yeah, I had messed up my return statement which threw me off as well.
-
array as session variable on click to some image
0xMatt replied to jasmeet's topic in PHP Coding Help
<?phpsession_start(); $animals = array('cat', 'dog', 'mouse', 'bird', 'crocodile', 'wombat', 'koala', 'kangaroo'); if(isset($_GET['add_animal'])){$_SESSION['animals'][$animals[$_GET['add_animal']]] = 1;} echo '<h1>Animals to choose from</h1>'; foreach($animals as $key=> $value){// and print out the valuesecho "<a href='test2.php?add_animal={$key}'>{$value}</a></br>";} echo '<br/><br/>'; $added_animals = '';foreach($_SESSION['animals'] as $animal => $value){$added_animals .= $animal. ',';} echo 'The animal you have added are: ' . $added_animals; Try that. Obviously change test2.php t your file name before you try it. -
I'm not sure what you mean but it sounds like removing the where clause is what you want. $sql = mysql_query("select imagelocation from store");
-
php registration login functionality using class
0xMatt replied to zohab's topic in Third Party Scripts
Where have you looked? Google has many answers. http://bit.ly/143dznq -
Help on error: mysql_fetch_array() expects parameter 1 to be resource
0xMatt replied to SkilletZA's topic in PHP Coding Help
He may not even understand what you mean by that since he's a self-proclaimed noob. What jazzman1 is saying is that you are using mysqli_connect() to establish a database connection and you are using mysql_ functions for everything else. mysqli_connect() is actually just an alias for the mysqli extension constructor and is all you need to make a db connection, you just need to define the database table inside the parameters like so: $link = mysqli_connect('localhost', 'my_user', 'my_password', 'my_db'); Like I said, mysqli_connect() is just an alias so people can use the procedural method which isn't recommended these days. Instead I'd use something like this: <?php $mysqli = new mysqli('192.168.0.3', 'demo', 'demo', 'my_db'); $result = $mysqli->query("SELECT * FROM persons WHERE Age = '28'"); while($rows = $result->fetch_assoc()) { $FirstName = $rows['FirstName']; $LastName = $rows['LastName']; $Age = $rows['Age']; echo "$FirstName $LastName $Age"; } Remember that you cannot use mysql_ functions with mysqli_functions. -
You need to setup a WAMP server for windows(Windows, Apache, MySQL, PHP) to execute php files. Good but big wampp server for Windows: http://www.apachefriends.org/en/xampp.html Haven't used this but it's an alternative: http://www.wampserver.com/en/
-
If it comes from a local machine(127.0.0.1) it's most likely going to end up in spam. If not you need to make sure you're using a valid email address and that you are using the appropriate headers. http://php.net/manual/en/function.mail.php And check out this relative post that others found useful on stackoverflow: http://stackoverflow.com/questions/12188334/php-mail-form-sending-to-gmail-spam
-
checking if forms are filled on submission
0xMatt replied to ryanmetzler3's topic in PHP Coding Help
What you're doing to process the form is only checking if those specific variable names are set which you have done. $username = mysql_real_escape_string($_POST['username']); So your code checks to see if $username is set, which you have just done above, even if the $_POST data for username is empty, $username is an empty string. So instead of using isset(), you'll want to replace all that with empty() in your argument. e.g if(empty($username)) { echo 'Username Empty'; } -
It means the query you are passing to mysql_query is returning null. You'll need to check to see if the query returns any data before executing mysql_result. From PHP.net: $result = mysql_query('SELECT what FROM where');if (!$result) { die('Could not query:' . mysql_error());}echo mysql_result($result, 2);
-
The issue may have something to do with your defined host. Try changing it to localhost and see if that works. If PHP says you're experience a connection error than that's what it is. The issue is definitely within your connection details and so you are overlooking something.
-
Save <?php printf("%s",$row["discount"]);?>%<br />
-
Your connection information is wrong. Double check your host, username, password and database.
-
How to eliminate space from textbox, if user enters space's
0xMatt replied to Chatrapati's topic in PHP Coding Help
There is no function provided by php that does what you are asking. So the answer is correct, you're just wanting somebody to make the code for you instead of doing it yourself. Maybe try learning a bit more basic php so you don't have to wait all day to solve simple dilemmas. if( empty( trim($_POST['name']) ) ) { echo 'Text field _name_ cannot be empty.'; } -
How to eliminate space from textbox, if user enters space's
0xMatt replied to Chatrapati's topic in PHP Coding Help
trim()