premiso
Members-
Posts
6,951 -
Joined
-
Last visited
-
Days Won
2
Everything posted by premiso
-
If you, or your host updated PHP recently, $HTTP_POST_VARS is depreciated: http://www.php.net/manual/en/reserved.variables.post.php I would change them to be $_POST instead and see if that possibly fixes your problem. As far as the actual problem, you never really told us what was "wrong". You just stated you had a problem. What specifically is going wrong? As mini hinted, we need that information to better help you without it we are just in a sloppy pen trying to catch a crisco greased up pig, pretty tough.
-
Something like this "may" work: SELECT CASE tablea.field1 WHEN 1 THEN tableb.field1 WHEN 2 THEN tablec.field1 END FROM tablea, tableb, tablec WHERE (where statement here etc); Not really sure though, as I have never done it before , just found some stuff at http://dev.mysql.com/doc/refman/5.0/en/control-flow-functions.html and went from there. EDIT: I just ran a rough test on my server, given the joins etc are done properly this should work just fine.
-
problematic post / preview display
premiso replied to nrg_alpha's topic in PHPFreaks.com Website Feedback
=\ I don't see the XXX, what a huge let down. Firefox must have a bug in it too. -
Eh you should not need two loops if I am understanding you right (which I may not be). <?php echo '<li class="restaurants-offerings-' . $arrRestaurantsOfferings[0]['restaurant_offerings_id'] . '">'; foreach($arrRestaurantsOfferings as $arrRestaurantsOffering) { printf('<input type="checkbox" name="frmSearch[offerings][]" value="%u" id="restaurants-offerings-%u"%s> <span for="restaurants-offerings-%u" class="checkboxes23">%s</span>' ,$arrRestaurantsOffering['restaurant_offerings_id'] ,$arrRestaurantsOffering['restaurant_offerings_id'] ,in_array($arrRestaurantsOffering['restaurant_offerings_id'],$arrOfferings)?' checked="checked"':'' ,$arrRestaurantsOffering['restaurant_offerings_id'] ,$arrRestaurantsOffering['name'] ); } echo '</li>'; ?> I believe that is all you are looking for and it should work, given that the original array is 0-index based. However, I may have mis-read this and yea, mini may have the solution.
-
I think the way you have it will be the best / only way as far as I know how to do it. I tried doing an insert statement with a select from the current table. It will only work if you are selecting from a different table, unfortunately.
-
Also this statement if($_GET["page"]=""||!isset($_GET["page"])){ Is incorrect, it should be: if (!isset($_GET["page"]) || $_GET["page"] == ""){ A: you put the isset first, because if the variable is not set, there is nothing in it to test and will cause a notice error. B: you have 1 equals sign comparing the $_GET to "", that just assigns the $_GET to be "". So changing that to == fixes that issue as that is the comparison operator.
-
Note that turning on Register_globals is not recommended due to the security hole that can be created. That is why it is now defaulted to off and is preferred to be off. If you do have it on, make sure you define all your variables anyways before using, as not doing so is where the issue can come into play (at least the major variables). And as Marcus pointed out, it is being completely removed soon, so yea.
-
Depending on the MySQL version, this should work, if I read it correct: UPDATE table_name SET slot = slot+1 WHERE OWNDERID = (SELECT OWNERID FROM table_name ORDER BY SLOT DESC LIMIT 1) LIMIT 1 Un-tested and it does depend on Mysql 4+ I believe for the subquery.
-
I used to play until WotLK, then it was just lame. And I heard they are continuing on with Catalysim, so if he "beat" it, then yea. Wait 6 months and he has to go more levels and more grinding etc to beat it and wait another year for another expansions. I would rather play a game on PS3 vs WoW, at least you can beat most of those games and feel like you accomplished something and not be stuck in an endless grind. And I would agree with all the comments on that site, he needs to go get laid.
-
No clue, it generally takes them a while just because it tends to break a lot of scripts doing updates. I know some hosts still run 4.x EEEK. The best bet is to do a dedicated and you can update it yourself But yea, I am sure you can find some hosts with 5.3 on them right now. Or you can probably coerce your webhost to upgrade by paying them an admin fee to do it, as they can still keep everyone else at a PHP version lower than 5.3 by setting the version in php.ini (at least I think you can). I would say March 2010 is a good estimate.
-
The code below assumes that it is detail.php: <?php include('connect.php'); mysql_select_db("gracom1_widgets", $con) or die(mysql_error()); $custID = isset($_GET['custID']) ? (int) $_GET['custID'] : 0; // The ? and : are the ternary operator which is a short if/else $result = mysql_query("SELECT * FROM customers INNER JOIN states on states.stateID = customers.stateID WHERE customers.custID = " . $custID) or die(mysql_error()); echo "<table width='600px'> <tr> <th>Customer Name</th> <th>Phone</th> <th>Email</th> <th>Address</th> <th>State</th> </tr>"; while($row = mysql_fetch_assoc($result)) { echo "<tr>"; echo "<td>" . $row['custName'] . "</td>"; echo "<td>" . $row['custPhone'] . "</td>"; echo '<td><a href="mailto:' . $row['custEmail'] . '?subject=">' . $row['custEmail'] . "</a></td>"; echo "<td>" . $row['custAddress'] . "</td>"; echo "<td>" . $row['stateName'] . "</td>"; echo "</tr>"; } echo "</table>"; mysql_close($con); ?> See the comments, that is one way to do it, notice the (int) when calling the GET variable, this will cast it to an integer no matter what and will prevent SQL exploits from entering your code, since that should always be an int. Un-tested of course, but "should" work, if you would like a further explanation of the ternary operator let me know.
-
Easier and more organized way than if/else if?
premiso replied to slyte33's topic in PHP Coding Help
Pshhh that is crazy talk. -
Easier and more organized way than if/else if?
premiso replied to slyte33's topic in PHP Coding Help
That is called the ternary operators (? which is just a short if / else statement: $example = ($example2 > 0)?'Greater Than 0!':'Less Than 0!'; echo $example; So basically if example2 is greater than 0 set example to be "Greater Than 0!" else, set it to be "Less than 0!". You cannot do anything more complex then an if/else with the ternary operator. -
<?php include('connect.php'); mysql_select_db("gracom1_widgets", $con) or die(mysql_error()); $result = mysql_query("SELECT `custName`, custPhone, custEmail, custID FROM customers") or die(mysql_error()); echo "<table width='600px'> <tr> <th>Customer Name</td> <th>Phone</td> <th>Email</td> <th>Details</td> </tr>"; while($row = mysql_fetch_assoc($result)) { echo "<tr>"; echo "<td>" . $row['custName'] . "</td>"; echo "<td>" . $row['custPhone'] . "</td>"; echo '<td><a href="mailto:' . $row['custEmail'] . '?subject=someSubject">' . $row['custEmail'] . "</a></td>"; echo '<td><a href="page.php?custID=' . $row['custID'] . '">Show</a></td>'; echo "</tr>"; } echo "</table>"; mysql_close($con); ?> And for future reference, please code inside of .
-
Just a question, are you sure you have data inside of your MySQL database? I modified your code a bit, namely I changed the query to pull specific data, if you know what you need pull that out. Secondly I do not think MySQL allows for a space inside of a column name, maybe it does if you use back ticks to initiate it, either way the below should work. Part of the problem may have been your column names were being returned all lower case so when you tried accessing them in the associative array it saw customer name as being different than Customer Name (like it should). So by defining the columns you wanted to pull out, we were also able to set the case of the column names too, so this "should" work as long as you have data in your database and the column names are what you were trying to pull. <?php include('connect.php'); mysql_select_db("gracom1_widgets", $con) or die(mysql_error()); $result = mysql_query("SELECT `Customer Name`, Phone, Email, Details FROM customers") or die(mysql_error()); echo "<table width='600px'> <tr> <th>Customer Name</td> <th>Phone</td> <th>Email</td> <th>Details</td> </tr>"; while($row = mysql_fetch_assoc($result)) // notice I changed this as well. array feches both, you only need one { echo "<tr>"; echo "<td>" . $row['Customer Name'] . "</td>"; echo "<td>" . $row['Phone'] . "</td>"; echo "<td>" . $row['Email'] . "</td>"; echo "<td>" . $row['Details'] . "</td>"; echo "</tr>"; } echo "</table>"; mysql_close($con); ?> (I am assuming the mysql_connect part you posted is housed inside of connect.php, if not remember to put that back in)
-
It is very useful for storing many different cookies inside of a cookiejar.
-
mysql_select_db("gracom1_widgets", $con) or die(mysql_error()); $result = mysql_query("SELECT * FROM customers") or die(mysql_error()); mysql_select_db("my_db", $con); $result = mysql_query("SELECT * FROM customers"); Not sure if that is intended or not, but you have the same query for two separate tables, except that the second table is taking priority as it overwrites $result. Perhaps you need to remove the bottom select_db and query and it will work?
-
UPDATE `users` SET `sub_expires` = CASE WHEN `sub_expires` >= UNIX_TIMESTAMP() THEN `sub_expires` + 2592000 ELSE UNIX_TIMESTAMP() + 2592000 END WHERE `id` = 101 Unsure if that will work, but I think it should...
-
What field type is VehicleTimer? As it will need to be a TIME or Datetime field for this to work as I have shown above.
-
http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html Check out "UNIX_TIMESTAMP", perhaps that is the method you are looking for?
-
$row is an object, the -> is calling a function/property of the object password. Basically it says, access password inside of the object "row". I am not sure how to better explain it, but that is the gist of it.
-
Can I pull specific data from an associative array?
premiso replied to iPixel's topic in PHP Coding Help
You can inside of your loop that displays the data, you do a simple if: if ($result_1a['CALLTYPE'] == "INCOMING") { // print here } Would be how to do it. -
Not really sure how this is a PHP issue, but on the AJAX call back are you setting the table class attribute to editable? If not try to do that and see if it works, as it may need to have that attribute reset since it is a new field. Without seeing any code, especially the code that generates the returned table cell, it will be hard to provide quality help. Either way I fail to see how this is PHP and moving it to AJAX forum.
-
I am not 100% sure on this, but using the single quotes around the number you are adding could be making it take the string as a 1, or something different. Try this: NOW( ) + 2592000 and see if that works, as since it is a number you should not need quotes around it.
-
SELECT restaurants_id, FROM Note the , before the FROM, remove that and see if it works. SELECT restaurants_id FROM