-
Posts
3,404 -
Joined
-
Last visited
-
Days Won
55
Everything posted by Ch0cu3r
-
Not quite understanding you. But from the screenshot I think I know what the issue is. I can tell you it is not PHP as you can clearly see from the screenshot the PHP code you posted is outputting the HTML for each "ad" from your MySQL database. The problem I do see is only one "ad" is being shown in the browser which means their is a problem with your HTML/CSS code. Without seeing the HTML/CSS code we cannot really help you futher. Any code you post please wrap it wihin tags (or click the <> button in the editor)
-
You cant delete you own posts. You can also find your own topics or posts you have made by visiting your profile (by clicking your username) and select the appropriate tab on the left hand side.
-
If Get Id from mysql db change id to a word !
Ch0cu3r replied to artursm15's topic in PHP Coding Help
So you want to associate the boss_id with a word? If so you could do something like this // define the words in an array. The boss id will be the key, and assign the word as the value for that key $words = array( 2000 => 'World One', 2032 => 'World Ten', ...etc ); ... while(list($boss_id,$respawn_time) = mysql_fetch_row($raidspawn)) { $text = '<font color="00FF00">'.$words[$boss_id].'</font>'; // use $boss_id as the key for $words array to get the associated word. ... } Alternatively you could have the list of words associated with ids stored in another mysql table and use a join to get the word that matches the boss_id. -
You have only defined the query. You have not executed the query, this is what ginerjm was pointing out.
-
Post the code you tried
-
You can use date to get the current month and year. You would then concatenate the month and year to construct the url for the link. Example code $month = use date() to get the current month; $year = use date() to get the current year; // concatate $month and $year to construct the url $url = 'https://www.pic-vert.fr/obm/availabilitycalendar.php?id=1&month='.$month.'&year='.$year.'&ln=nl'; // output hyperlink echo '<a href="'.$url.'">Whatever</a>';
-
How to capture incoming Post data from html page.
Ch0cu3r replied to tommytx's topic in PHP Coding Help
It already is. All data from the POST request is stored in the $_POST superglobal variable. To see the contents of $_POST use print_r (or var_dump) printf('<pre>Contents of $_POST %s</pre>', print_r($_POST, true)); -
These two lines will be overwriting your session variables here $_SESSION['userid'] = $dbid; $_SESSION['username'] = $dbuser; . Maybe you meant to get the data from the session variables. $userid = $_SESSION['userid']; $username = $_SESSION['username'];
-
Exlude .gif .png images from directory listing script
Ch0cu3r replied to astarmathsandphysics's topic in PHP Coding Help
@raphael75 why not use $extension = pathinfo($file, PATHINFO_EXTENSION); to get the file extension? -
What is the code for members.php? It appears to be the same as login.php? Is this a copy and paste issue? First in login php $_SESSION['userid'] = $dbid; $_SESSION['username'] = $dbuser; On line 5 & 6 where are the variables $dbid and $dbuser defined? All variables must be defined before using them, PHP does not jump ahead and look for variables further down the code. Using a variable before it is defined will result in a "Notice: Undefined variable" message being produced and those $_SESSION variables being set to null (empty) values. I would only set these session variables when the user has successfully logs in. When getting the users data from the users table you running three duplicate queries. Why? You have already got the users data returned from the first query there is no need for the other two queries. Before using $user in your query you should be sanitizing it to prevent SQL Injection attacks, you could use mysql_real_escape_string to do this. Or a better approach would be to update your code to use MySQLi or PDO and use prepared queries. Which I recommend as the mysql_ functions are deprecated, which means they are no longer supported and could be removed from future versions of PHP. Where defining the userid session variable after you have confirmed the user has entered the correct username/password you are using an undefined variable $dbid $_SESSION['userid'] = $dbid; I assume this should be set to the user id return from your query if so then use $row['id'] (note: change id to the name of the field that contains the user id in your users table).
-
Sorry I didn't reply to you earlier. You need to add the name of the file as a hidden input field because your action function takes the image path as an argument. Without this PHP will not know what file you are referring to when calling the action function. With my solution you first define the name of the image as a hidden input field called image by changing your forms code to the following <form class="form" action="" method="post"> <div> <img src="' . $image . '" alt="" /> </div> <label for="C1">FASHION</label> <input id="fashion" type="radio" name="fashion" id="C1" value="fashion" /> <label for="C2"> NON FASHION </label> <input id="nfashion" type="radio" name="nfashion" id="C2" value="nfashion" /> <input type="hidden" name="image" value="'.$image.'" /> <input type="submit" value="submit" /> </form>' Notice I have set the forms action to be empty, this so the form will be submitted to itself. The action only needs to be set if you are going to redirect the user to a different page. The other addition is the hidden input field called image before the submit button. This is set to the value of $image. To call your action function when the form has been submitted change echo listFolderFiles('images//'); to if($_SERVER['REQUEST_METHOD'] == 'POST') { // call the action function when a post request has been made. action($_POST['image']); } echo listFolderFiles('images//'); Now the action function will be called when you have submitted a form and the name of the file will passed to the function.
-
If you are going to allow the user to change their password then all you need to do is get the user to provide their current password and their new password. If hashing their current password matches the password hash stored in the database then you hash the new password they provided and update the password hash stored in the database.
-
Need help with using session outside foreach loop
Ch0cu3r replied to helloworld001's topic in PHP Coding Help
Initiate $_SESSION['userid'] to an array outside the foreach loop $_SESSION['userid'] = array(); foreach($result as $row) { ... -
Need help with using session outside foreach loop
Ch0cu3r replied to helloworld001's topic in PHP Coding Help
You are getting the last user id value because $_SESSION['userid'] is being overwritten as you iterate over $result If all you want is the first user id then why are you using a loop? You could just do something like $_SESSION['userid'] = $result[0]['userid']; // add the first userid value to session Or better yet reconstruct your query so it only returns the data you want. -
This line of code is not doing what you think it is doing <form class = "form" action="' . action($image) . '" method="post"> The action function will not be called when the form has been submitted. PHP will be calling that function immediately! PHP cannot react to events happening in the browser. PHP code will only be executed when a HTTP request takes place. What you need to do is only call the action function when the form has been submitted. Example code if($_SERVER['REQUEST_METHOD'] == 'POST') { // call the action function passing the name of the image action($_POST['image']); } You will now need to add a hidden input field to your form containing the name of the image.
-
If you are seeing \r\n then something in your code is applying slashes to escaped characters (most likely from the use of addslashes). However there is no need to replace \r\n with a html break tag yourself. PHP can do this for you check out the nl2br function
-
You dont need to use echo within PHP's "echo" short tags (that is what the <?= tag means). You should note however if you are not using PHP5.4 then this type of PHP tag is not available unless you enable a setting called short_open_tag. For this reason I always use full PHP tags <input type="text" name='iduser' id='iduser' value="<?php echo $fgmembersite->UserId(); ?>"> OR use the following as you have defined $userid line 9 <input type="text" name='iduser' id='iduser' value="<?php echo $userid; ?>">
-
You need to be wrapping the values in quotes within your query $query = "UPDATE User SET hash='$hash' WHERE email='$email' And username='$username_from_db'"; But still you should still be using a prepared query.
-
contact godaddy and make sure they have enabled the pdo extensions
-
Mysqli class missing from PHP version 5+.
Ch0cu3r replied to engy123's topic in PHP Installation and Configuration
Those files are for the old mysql extension. MySQLi requires the php_mysqli.dll extension to be enabled. You should not need to download the mysql extensions as they are bundled with PHP I would suggest you add your PHP installation folder to the Windows PATH Environment Variable first and then configure the extensions_dir directive in the php.in to be an absolute path to the ext/ folder in your PHP installation folder. -
echo dynamic data from api call to owl carousel
Ch0cu3r replied to didz666's topic in PHP Coding Help
owlcarousel as in the JQuery plugin? Read these steps here to add it to your page. For step 2 you just wrap <?php echo $results;?> with the div for the style of carousel you want (this is shown in the HTML tab for each demo), example html for the custom carousel effect <!-- example html for the custom carousel --> <div id="owl-demo" class="owl-carousel owl-theme"> <?php echo $results; /* this line gets wrapped in the div for the style of carousel */ ?> </div> <div class="customNavigation"> <a class="btn prev">Previous</a> <a class="btn next">Next</a> <a class="btn play">Autoplay</a> <a class="btn stop">Stop</a> </div> All you need to do now is apply the Javascript and CSS shown for the carousel you want. -
How do I use SMART tools to check on my notebooks hard drive?
Ch0cu3r replied to Maze's topic in Miscellaneous
If you are using the GNOME desktop environment for opensuse then you should be able to install the gnome-disk-utility package from your repository. -
The reason why your rewriterule will not match the url such as user/joe/x is because of the end anchor character (the dollar sign). When you use both anchor characters in your regex you are asking for an exact match (ie, the regex pattern should find a match from the very first character to the very last character of the url). If you want to allow extra characters in your url then remove the dollar.
-
Change the negative look ahead (?! ...) to a positive look ahead (?=...)