
pocobueno1388
Members-
Posts
3,369 -
Joined
-
Last visited
Never
Everything posted by pocobueno1388
-
The back sticks are for when you have a field name that is a MySQL reserved word. If you put them around that field, you won't get an error. Apostrophes are for putting around variables. There could be another use for back sticks, but that is the one I'm aware of.
-
Thanks GingerRobot, that gave me a good start, but it's still having one issue. If you uncheck all the checkboxes from a column, that columns field isn't added to the array...therefore it completely ignores anything you did to that column and just keeps all the original values how they were. I don't know why I'm having such a difficult time with this array. I need to figure out a way to keep all values in the array even if no checkboxes are checked. Any suggestions for that? Here is the code I'm using: <?php if (isset($_POST['update'])){ //echo '<pre>',print_r($_POST['power']),'</pre>'; $get_mods = mysql_query("SELECT userID FROM moderators"); while ($row = mysql_fetch_assoc($get_mods)){ $update = array(); foreach ($_POST['power'] as $field => $userID){ if(in_array($row['userID'], $userID)) $update[] = $field.'=1'; else $update[] = $field.'=0'; } $sql = "UPDATE moderators SET " . implode(", ", $update) . " WHERE userID={$row['userID']}"; mysql_query($sql) or die(mysql_error()."<p>$sql<p>"); echo $sql."<p>"; } } ?>
-
I am in the process of programming a page where an admin can give/delete powers that other moderators have on the site (screen shot attached). I have no problem updating the DB when a checkbox IS checked, the problem is I can't figure out a way to know which checkboxes were left unchecked, so I can update the DB to take away that power. Currently this is how my checkbox HTML looks: <input type='checkbox' name='power[chat][]' value='{$row['userID']}'> The name attribute varies depending on what the checkbox is for. So when I submit the form, the array looks like this giving me the CHECKED values: Array ( [forum_addDelCategory] => Array ( [0] => 1 [1] => 3 ) [chat] => Array ( [0] => 1 [1] => 3 ) [news] => Array ( [0] => 3 ) [forum_moderate] => Array ( [0] => 3 ) ) I have a DB table called moderators (screen shot attached). It holds the mods userID and lists all the powers they can have. If they have the power to do something, there is a 1 in the field. If they don't, there is a 0. Any advice is greatly appreciated, thanks. [attachment deleted by admin]
-
I think what your meaning to do is: for ( $j = 0; $j <= count( $optionvalue ) - 2; $j += 2 )
-
You didn't close a bracket, if you line your code up it will be a lot easier to spot. <? include "config2.php"; ?> <!doctype html public "-//w3c//dtd html 3.2//en"> <html> <head> </head> <body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000"> <? $name=mysql_real_escape_string($name); if ($rec=mysql_fetch_array(mysql_query("SELECT * FROM accounts WHERE name='$name'"))) { if (($rec['name']==$name)) { if (mysql_query("update accounts set loggedin='1' WHERE name='$name'")) { echo "<font face='Verdana' size='2' ><center>OK <br> Your account has been fix try to log in the game now!</font></center>"; } } }
-
<?php if (ereg("[^A-Za-z0-9]", $string)) { echo "Error: String can only contain letters and numbers!"; } ?>
-
Okay, lets try this and see if there is an issue with the variables within the query. Also, you are using backsticks instead of a single quote around your variables. <?php if($rowB['agency'] = $agency){ $query = "UPDATE $tableB SET gameid = '$gameid', totalTime = totalTime + $finalTime, date = '$date' WHERE agency='$agency'"; $result = mysql_query($query)or die(mysql_error()."<p>With Query:<br>$query"); echo $query; } ?>
-
Instead of `totalTime` += '$finalTime' Do `totalTime` = totalTime + $finalTime
-
That means there is a problem with the query. Put a die to catch the error. $joe = mysql_query("SELECT * FROM messages WHERE to_username = '".$suser."' AND read = 'n'")or die(mysql_error());
-
SOLVED: counting rows in someone else's code
pocobueno1388 replied to bad_gui's topic in PHP Coding Help
No, $result wouldn't hold the number of records. This line $rows = @mysql_fetch_assoc($result); actually extracts the data from the result and puts it into an array. The only reason I had to do that is because I aliased the number of records in the query. You can use mysql_num_rows() instead if you prefer. -
How is it outputting the data? Your function doesn't return anything, so try this: <?php function MD4($input) { return $MD4Hash=bin2hex(mhash(MHASH_MD4,$Input)); } ?>
-
There is no WHERE clause in an INSERT query. Are you sure your not needing to use an UPDATE query? UPDATE users SET quote ='$quote' WHERE username = '$session'
-
I think this is what your meaning to do: <?php // add these details to $gf which will be used later to write the googleform $gf .= "<input type=\"hidden\" name=\"item_description_$count\" value=\"$row['category_name']\" />"; $gf .= "<input type=\"hidden\" name=\"item_name_$count\" value=\"$row['product_name']\" />"; $gf .= "<input type=\"hidden\" name=\"item_price_$count\" value=\"$_SESSION['cart'][$row['product_id']]['price']\" />"; $gf .= "<input type=\"hidden\" name=\"item_quantity_$count\" value=\"$_SESSION['cart'][$row['product_id']]['quantity']\"/>"; $gf .= "<input type=\"hidden\" name=\"item_currency_$count\" value=\"GBP\"/>"; ?>
-
Variable is not printed in echo statement!
pocobueno1388 replied to omarshehab's topic in PHP Coding Help
Take away the var from the beginning of this line: var $length = strlen($this->mobileNumber); -
date("D jS F Y", strtotime($row['date'].' + 28 DAY'))
-
SOLVED: counting rows in someone else's code
pocobueno1388 replied to bad_gui's topic in PHP Coding Help
Try this: <?php $query = "SELECT COUNT(*) as num FROM library"; $result = @mysql_query ($query); $rows = @mysql_fetch_assoc($result); $articles = $rows['num']; $where = "overall"; @mysql_close($link); print "<BR><BR>$articles articles $where<BR><BR>"; ?> -
The error is coming from this large print: <?php print " <b>Vote here on each of these sites to help Ruins of Sera. Each one of your votes gives you 50 Credits.</b><br><br> <a href="http://www.toprpgames.com/vote.php?idno=1832"><img src="http://www.toprpgames.com/images/banners/toprpg_88x31-2.gif" border="0"></a> <br><br> <a href="http://best-rpg.com/games/vote/382/" title="Vote on Best Rpg 200" ><img src="http://www.ruinsofsera.x10hosting.com/index.php/bestrpg.jpg"></a> <br><br> <div style="width: 88px; height: 55;"> <a href="http://www.xtremetop100.com/in.php?site=1132239810"> <img src="http://www.xtremeTop100.com/votenew.jpg" border="0" alt="MMORPG & MPOG Free server" style="float: left;\ margin-top: -1px;"></a><br><a href="http://www.xtremetop100.com/"> <img src="http://www.xtremeTop100.com/tracker.jpg" border="0" alt="MMORPG & MPOG Free server" style="float: left;\ margin-top: -1px;"></a></td> </div><br><br><a href="http://www.gtop100.com/in.php?site=21959" title="MMORPG / MPOG" target="_blank"> <img src="http://www.gtop100.com/images/votebutton.jpg" border="0" alt="MMORPG / MPOG"></a>"; Instead, do this: <?php print<<<HERE <b>Vote here on each of these sites to help Ruins of Sera. Each one of your votes gives you 50 Credits.</b><br><br> <a href="http://www.toprpgames.com/vote.php?idno=1832"><img src="http://www.toprpgames.com/images/banners/toprpg_88x31-2.gif" border="0"></a> <br><br> <a href="http://best-rpg.com/games/vote/382/" title="Vote on Best Rpg 200" ><img src="http://www.ruinsofsera.x10hosting.com/index.php/bestrpg.jpg"></a> <br><br> <div style="width: 88px; height: 55;"> <a href="http://www.xtremetop100.com/in.php?site=1132239810"> <img src="http://www.xtremeTop100.com/votenew.jpg" border="0" alt="MMORPG & MPOG Free server" style="float: left;\ margin-top: -1px;"></a><br><a href="http://www.xtremetop100.com/"> <img src="http://www.xtremeTop100.com/tracker.jpg" border="0" alt="MMORPG & MPOG Free server" style="float: left;\ margin-top: -1px;"></a></td> </div><br><br><a href="http://www.gtop100.com/in.php?site=21959" title="MMORPG / MPOG" target="_blank"> <img src="http://www.gtop100.com/images/votebutton.jpg" border="0" alt="MMORPG / MPOG"></a> HERE; The reason your getting the error is because you can't use double quotes within double quotes. If you don't want to do it the way I showed you, you can go through and either escape all the double quotes with backslashes, or replace them with single quotes.
-
Here is an example of how to get an average of a column. <?php $query = mysql_query("SELECT AVG(field_name) as average FROM table"); $row = mysql_fetch_assoc($query); echo $row['average']; ?>
-
Put it where it will be at the very top every time. So if you call your header.php file at the top of every page, then put it at the top of the header file.
-
The cookies IS set, but you can't do anything with it until the next page load. In the manual it says:
-
Don't forget to press solved.
-
There is an error with your query, so put a die statement at the end of this line: $row = mysql_fetch_array($sql)or die(mysql_error() . "<p>With Query<br>$sql");
-
You should be using mysql_query() instead of mysql_result(). So change: $result = mysql_result("SELECT Event_Name FROM EventType"); To: $result = mysql_query("SELECT Event_Name FROM EventType");
-
Try <?php include ("../databaseConnect/dbfuncs.inc.php"); $link = connectToDatabase(); $result = mysql_result("SELECT Event_Name FROM EventType"); $rows = mysql_num_rows($result); echo "<select name='Events'>"; echo "<option>Select Event</option>"; while ($row = mysql_fetch_assoc($result)){ echo "<option value='{$row['Event_Name']}'>{$row['Event_Name']}</option>"; } echo "</select><td/>"; ?>
-
If your talking about my code, I did use $_GET. Also, why loop through the MySQL result when your only expecting one result set?