-
Posts
422 -
Joined
-
Last visited
-
Days Won
1
Everything posted by awjudd
-
Then shouldn't the <PRE> be replaced before going into the query function? ... or does your query function handle it for you? ~juddster
-
What is the <PRE> in the field name? ~juddster
-
It appears that your field names in your list are in single quotes. This is invalid because they will be treated as individual strings. If you want to delimit the field values use the `. i.e. INSERT INTO `blah` ( `id`, `blah2` ) VALUES ( NULL, 'Hi' ) That should resolve your issue. ~juddster
-
I believe that the error you are getting caused by the exact thing that bh was saying ... your strings aren't in quotes, so it looks in the database for those fields and when it can't find a field called 'bobo' (assuming $_POST [ 'username' ] = 'bobo' ) then it'll error. ~juddster
-
There is no need for a LEFT JOIN here ... you will be mostly eliminating the benefits with your where clause anyways (original set that is returned will be much larger than it needs to be) ... SELECT `p`.`name` FROM `players` p JOIN `users` u ON `p`.`player_id` = `u`.`player_id` WHERE `u`.`mem_id` = $mId Or you could move the restriction of the member id to the ON clause so it has more conditions (returning less results from the beginning of the join). SELECT `p`.`name` FROM `players` p JOIN `users` u ON ( `p`.`player_id` = `u`.`player_id` AND `u`.`mem_id` = $mId ) ~juddster
-
ORDER BY comes after GROUP BY $search = "SELECT p1.rating, MAX(p1.date_of_pr) as date_of_pr, e1.employee_ID FROM performance_review p1 JOIN employee e1 ON e1.employee_ID = p1.employee_ID WHERE e.manager_ID = '".$m_id."' GROUP BY p1.employee_ID, p1.rating ORDER BY p1.date_of_pr"; ~juddster
-
I have an attempt as well ... this was my first trial ... I'm pretty sure that this could be simplified some more ... but here it is ... SELECT e.employee_id, pr.rating FROM Employee e JOIN ( SELECT employee_id, MAX(date_of_pr) AS date_of_pr FROM performance_review pr WHERE e.employee_id = pr.employee_id GROUP BY pr.employee_id ) p ON e.employee_id = p.employee_id JOIN ( SELECT employee_id, rating FROM performance_review pr WHERE p.employee_id = pr.employee_id AND p.date_of_pr = pr.date_of_pr ) pr ON p.employee_id = pr.employee_id AND p.date_of_pr WHERE e.manager_id = $mid The first join (p) will basically get a list for each employee under specific manager and the day of their last review. The second join (pr) will then grab the corresponding reviews. However, this will have the same problem as premiso's ... Something doesn't look right ... and now it's bothering me ... ~juddster
-
Please define 'not working' ... can't debug without information. ~juddster
-
Have you added the second SELECT that I previously mentioned? ... or moving the initial select to after where you have the UPDATE in your code? ~juddster
-
Are you wanting the actual unique IDs to be decreased by 1 ... or do you just want to do it on the PHP side? ~juddster
-
To make it easier for them you could make a form of sorts to make the CSS file for them ... i.e. Cell 1: Font Name: >input< Font Colour: >input< Background Colour: >input< Cell 2: Font Name: >input< Font Colour: >input< Background Colour: >input< Then when its posted ... you change it to: .cell1 { color: $_POST [ 'cell1_colour' ]; background-color: $_POST [ 'cell1_bg' ]; } ... This way all they need to know is font names and colours ... not CSS. Then you save that generated CSS file to the database. ~juddster
-
Yet again ... my first post here contains code which would be very useful for the conversion to the $_POST foreach ( $_POST as $key => $value ) // Loop through all of the posted values (and their associated keys (keys are the 'name' field from the HTML) ) { // TODO: Add some verification to make sure that the field specified exists $value = msyql_real_escape_string ( $value ); // Sanitize the input (more should probably be done) $query = "UPDATE `teksty` SET `" . $key . "` = '" . $value . "'"; // Generate the query mysql_query ( $query ); // Update the table } Your script does the following: i) Grabs the data ii) Updates the database iii) Displays the data from step 1 This will make it so that you will never get the updated values until you actually refresh. Move the update up, or re-do the SELECT query within the block of code where it is being updated and it will work as expected. ~juddster
-
I was saying let them set all of the CSS for themselves in that area.. or if you don't want it directly in the text area like that, make it so that they have individual fields for each of the classes you want and then build the css file before entering it into the database. Then you will basically be able to do a query on the user, and just echo whatever they have as their CSS on the page. ~juddster
-
You are using $_GET to check against, when all of the information is being posted ($_POST). Please refer to my first post. ~juddster
-
For starters, you are going to have to throw all of your text areas into a <form> tag. This will tell the web browser where to send the data once the button has been pressed. After that, you will need to add the actual submit button and then process the information which is sent to the processing script. [php $connection = mysql_connect("localhost", "root", "root") or die('Brak po³¹czenia z serwerem MySQL'); $db = mysql_select_db("podreglami") or die('Nie mogê po³¹czyæ siê z baz¹ danych'); $query = "SELECT tresc FROM `teksty`"; $result= mysql_query($query); echo "<form method = 'post' action = ''>"; // Tell the form to send data through $_POST and then send it back to the current page while ($row = mysql_fetch_array($result)) { echo(' <textarea rows="10" cols="60" name="' .$row['tytul']. '">' .$row['tresc'].' </textarea><br /><br />'); } echo "<input type = 'submit' value = 'Save Settings' />"; // Add the 'sending' button echo "</form>"; [/code] Then for the processing part, which would probably end up being placed above the previous code, you could do something like this. foreach ( $_POST as $key => $value ) // Loop through all of the posted values (and their associated keys (keys are the 'name' field from the HTML) ) { // TODO: Add some verification to make sure that the field specified exists $value = msyql_real_escape_string ( $value ); // Sanitize the input (more should probably be done) $query = "UPDATE `teksty` SET `" . $key . "` = '" . $value . "'"; // Generate the query mysql_query ( $query ); // Update the table } Something along those lines should work I believe. ~juddster
-
Why would you have having 600 columns per user? Just make a text field in and you should be good to go ... CREATE TABLE user_styles ( user_id UNSIGNED INT PRIMARY KEY NOT NULL, style TEXT NOT NULL ) Something along those lines where user_id would actually be a foreign key to a users table of some sort. ~juddster
-
Will there only be one user? If yes, then this solution is fine (the CSS will require a page reload before it takes place). However, if there is more than one user, you may want to consider throwing it in a table in a database and then just echoing the contents whenever they load pages. ~juddster
-
Is this what you are looking for? http://www.tizag.com/phpT/filewrite.php ~juddster
-
It means that you haven't actually set a value to it before trying to use the value in a statement. Was this supposed to be a global variable? If yes, you need to tell PHP this. <?php function customError($errno, $errstr) { global $global_error_reporting; // Tell PHP to look in the global scope rather than local. ... } ~juddster
-
http://www.tizag.com/phpT/fileupload.php <-- is a good tutorial on single file upload which can then in turn be converted into multi-file upload with a few changes ~juddster
-
Getting level stats from another website HELP!
awjudd replied to respiant's topic in PHP Coding Help
I would run that script to download stats as a cron job and then store the results in a local database or flat file. I say this because each time the user visits the page, your server is currently putting in the request to the other site which will end up throttling you and use extra bandwidth. ~juddster -
As mentioned on IRC, there are two syntactical errors that you have here. <?php require_once('../auth.php'); require('connet.php'); // Missing semi-colon here (should this be connect.php?) $user_id = $login; $query = "SELECT * FROM `members` WHERE user_id = '$user_id'"; $resultm = mysql_query($query); $user = mysql_fetch_assoc($resultm); ?> <?php echo "Hello {$user['firstname']}:<br /><br />\n"; //Only display link four for users of level 1 if($user['level']=='1') { echo "<a href='#'>Link 4</a><br />\n"; // You used " as both the outside and inside the string ... so you would either have to escape it or swap to single quotes } ?> ~juddster
-
Too little too late man ~juddster
-
You have no protection against SQL injection anywhere in that script ... very risky business not accounting for that. ~juddster