-
Posts
3,372 -
Joined
-
Last visited
-
Days Won
18
Everything posted by Muddy_Funster
-
Appending a string in a foreach loop
Muddy_Funster replied to HanneSThEGreaT's topic in PHP Coding Help
it's storing both: strOrder String == 0,2;1,11;2,20; the array index is the number before the , and the value of that index is the number between the , and the ; what I think you want is $strOrder .= $id." ".$prod['$id']['name']; If I'm wrong show me an example of what you expect $strOrder to look like. -
Appending a string in a foreach loop
Muddy_Funster replied to HanneSThEGreaT's topic in PHP Coding Help
well $strOrder is getting assigned values from the array using that, so just change the echo "strOrder String == $strOrder"; to your original code and you should be good to go. -
ok, fistly, there is no need at all to use the {} for flat variables, only array key values. Secondly, if you are not inserting a value to a field it should not be included in the insert statement. Insert only to the fields that you are changing the data with your input. $sql2 = "INSERT INTO mailbox (fieldName2, fieldName4, fieldName6, filedName8) VALUES ('locked', '$username', <see below>, 'locked')"; for the field that you aere inserting NOW() into, if it is a timestamp field you would be better using CURRENT_TIMESTAMP() instead.
-
could you cover what you have actaly tried, and what the outcomes were so we dont go over old ground?
-
Appending a string in a foreach loop
Muddy_Funster replied to HanneSThEGreaT's topic in PHP Coding Help
I'm suprised you're not getting any errors. what happens if you change it to this? foreach ($_POST['ordered'] as $key=>$id) { echo '<p/>'; echo "ProdName: {$prod[$id]['name']}<br/>"; echo "ProdPrice: {$prod[$id]['price']}<br/>"; echo "ProdQty: {$prod[$id]['qty']}<hr/>"; //not sire what <hr/> is but i'm sure you have a reason for it $strOrder .= $key . "," . $id.";"; } echo "strOrder String == $strOrder"; -
redirect_to() is likely a custom function that has been written to do just that, and there is no need to encrypt a $_GET variable, as logout.php does not render the end user automaticly logged in, I think you may have missunderstood that bit as it's not even a page, it's a function. Besides, $_POST would be much easier for what you're suggesting. P.S. urlencode is not an encryption method. P.P.S. There is no PHP 'ONCLICK:()' function.
-
wouldn't it make more senese to change $partNames to a multidimensional array?
-
what do you get with this? <?php if(!empty($_FILES)){ //proceed with code $target = "upload/"; $target = $target . basename( $_FILES['uploaded']['name']) ; $ok=1; //This is our size condition if ($uploaded_size > 350000) { echo "Your file is too large.<br>"; $ok=0; } //This is our limit file type condition if ($uploaded_type =="text/php") { echo "No PHP files<br>"; $ok=0; } //Here we check that $ok was not set to 0 by an error if ($ok==0) { Echo "Sorry your file was not uploaded"; } //If everything is ok we try to upload it else { if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; } else { echo "Sorry, there was a problem uploading your file."; } } } else { /* this part can either be in the same file as the form or it can be in a different file. If you want this in a different file, make the "action" of the form go to that file */ if(sizeof($_POST)) { $body = ""; while(list($key, $val) = each($HTTP_POST_VARS)) { $body .= "$key: $val \n"; } mail("[email protected]", // to "Resume", $body, "From:".$Email); } } // end form processing ?>
-
I can see a serious problem with the PHP, but what's wrong with the database?
-
I dunno about the wizards, but I would use a timestamp field with default value of NULL and no on update action. Update it it with CURRENT_TIMESTAMP() when something is deleted, then select the info by NOT using * with the WHERE <timestamp_filed> IS NOT NULL. Using a date time formated field lets you report against the filed (as I am assuming you want to do or else you would just be using a flag field) without having to convert values to get the ranges that you are looking for.
-
you could try: DELIMITER $$ CREATE TRIGGER ins_masterid AFTER INSERT ON `table1` FOR EACH ROW BEGIN INSERT INTO mastertable (table1id) SELECT MAX(LAST_INSERT_ID(id)) FROM table1; END$$ DELIMITER ; not sure if it is only the most recent id value that you are after or not, but the code above is assuming that it is. Let me know how you get on with it.
-
why did your url change?
-
I'd start with reading up on PHP date functions, DateTime::Add() would be a likely place to begin I think.
-
To be honest, it's better to work how you feel comfortable at the moment. If you're happy using two pages, then use two pages, if you preffer one, then use one. Once you're more settled in the language you can worry about which is better long term. Still need you to tell us what setup you are using just now so we can help with the code .
-
INSERT With Indeterminate Number of Columns
Muddy_Funster replied to AltarofScience's topic in MySQL Help
doesn't have to, you can use an another table to link users to buildings: id | user_id | building_id 1 | 1 | 1 2 | 1 | 2 3 | 2 | 1 4 | 2 | 3 then use a building_catalogue table to refference the building id's to relevent details, like name, size cost, number of towns people required before building, time to build resources needed, that sort of thing. -
ok, you shouldn't be using SELECT * for that query, you only need to SELECT forename, surname You also need to assign forename and surname to to your variables $forename and $surname. As well as this, unless the form and the query are on the same page you will need to move the values accross the pages before you assign them. Are these on the same page or two different ones?
-
How do I find a single record and the next record after it only.
Muddy_Funster replied to jasonc's topic in MySQL Help
erm...I can't see any logic to that at all. You are storing shopping cart items - items you are going to be billing people for - with no definitive id structure? Also, if all the numbers are random, and in random locations, why bother trying to pull two consecutive records when they could have absoloutly no relevance to each other, why not just select your single item and then any other random record? This just makes no sense to me at all. I'm either going to need you to explain in detail what you are doing here, and exactly why you think it's a good idea, or I'm affraid I'll be of little help at all. -
How do I find a single record and the next record after it only.
Muddy_Funster replied to jasonc's topic in MySQL Help
How big is your table, can you make a column fill it then rename it an auto increment column or build another table? Also I have a small site but my picture info db has auto increment and then I use three queries to retrieve the display pic, the next pic and the previous pic. I'm sure there are better ways but like I said it's a small site. SELECT pic FROM table WHERE id IN(SELECT id, id+1, id-1 FROM table where id = $id) would be one way of doing it. SELECT pic FROM table WHERE ((id = $id) OR (id = $id+1) OR (id = $id-1)) is another. How big is your table, can you make a column fill it then rename it an auto increment column or build another table? Also I have a small site but my picture info db has auto increment and then I use three queries to retrieve the display pic, the next pic and the previous pic. I'm sure there are better ways but like I said it's a small site. Because Pid is not unique and not in order and that I add items in between, i can not use a primary key as adding an item in the middle later on will cause that item to have a higher primary key id. OK, you can still index the column regardless of the duplicate values. what do you meen by "add items in the middle"? what exactly are you using this table for? -
How do I find a single record and the next record after it only.
Muddy_Funster replied to jasonc's topic in MySQL Help
you can't refference the Pid field directly in the WHERE clause if you you are looking to get multiple different records from it without a common factor in the search. You will need to search against another field (prefferably a primary key int index) using a subquery. Something along the lines of: SELECT Pid, Item FROM table WHERE id IN ( SELECT id from table where id > ((SELECT id from from table WHERE Pid = '$variable')-1) ORDER BY id LIMIT 2 ) -
you seem to have your variables mixed up, your using $id when you should be using $clickid $SQL = "SELECT * FROM loads"; $result = mysql_query($SQL); while ($db_field = mysql_fetch_assoc($result)) { $clickid = $_GET['id']; print $db_field['id'] ."<a href=\"load_info.php?id=$clickid" . $clickid . "\" target=\"_self\" title=\"\">More Info</a>;"; print $db_field['depart:'] . "<BR>"; print $db_field['dest'] . "<BR>"; } then on the next page myou are trying to get clickid when it should be id $var = $_GET['id']; I am surprised that you didn't get undeclared variable warnings when you ran your code.
-
How do I find a single record and the next record after it only.
Muddy_Funster replied to jasonc's topic in MySQL Help
Why would you not index a text field if you are searching against it? what do you get just now if you use "ORDER BY Pid LIMIT 2"? -
it looks to me that you're using the $this object in other functions as well, could we see them also? if any of them are private or protected there could be problems coming from that. Also, could you please try and be as specific as possible when reporting the issues that you are having: nothing as a term is not helpfull, and even less helpfull is saying "nothing" and then without any changes saying "i'm only getting the numbers". What exactly is on the screen, and what do you see if you view page source?
-
is your php ini file set to allow the fopen url wrapper? have you tried pointing the script to another page, like google.com?
-
For the date time issue I persoanly would have 4 fields for that: event_date, event_stat_time, event_end_time, am_pm_flag. By including additional ID P/K Fields in all three databases, with columns for relational table id fields in the tables that need them you make things much easier to refference and maintain. Just my thoughts on it.
-
could you post a sample dataset? and a breakdown of what each field is being used to store?