Jump to content

txrandom

Members
  • Posts

    21
  • Joined

  • Last visited

    Never

Everything posted by txrandom

  1. Well I think I found a work around. I'm already detecting to see if the valid is null. I'm just going to change the "locationId = ?" to a variable and have the other option be "locationId IS NULL" That way it doesn't even matter if the parameter is null since it won't be binding it anyways. Thanks for the help!
  2. That was a bad example: $slotRow = $slotTable->fetchRow(array("locationId = ?" => $locationRow->locationId, "timeId = ?" => $timeRow->timeId, "days = ?" => $days)); I'm using this for a data scrubber. I don't want to replicate data, so I need to make sure it's not already in there. For example, a slot may have the time and day fields filled, but this slot may not have a location. The location should be null since it doesn't have one. Well what if there is another slot with the same time and day, but actually has a location? I need to make sure I check whether that locationId is null. Does that make sense? Do you think there is a better approach to this?
  3. $departmentRow = $departmentTable->fetchRow(array("department = ?" => $department)); Let's say there is an off chance $department may be null. Doing this with Zend Framework throws a 'SQLSTATE[HY093]: Invalid parameter number: no parameters were bound' Is there any way to allow $department to be null?
  4. Thanks Barand. Should array_unique() not be used to remove unique objects? It seems like it's not using tostring() to compare objects.
  5. I've got an array of objects that are instantiated based on an ID, but it's possible that multiple objects of the same ID may be added to an array. I've tried using array_unique to get rid of duplicates, but if the object contains a null data field, it throws some error messages. How do I get PHP to compare objects by a certain field rather than every variable (null or set) declared in an object?
  6. I get the error 1054: Unknown column 'gid.gid' in 'on clause'.  Does that mean it's trying to access table gid . field gid? Cause that doesn't exist.  I've never used SQL like this so I have no idea.
  7. Thanks, I tested the script out and I'm getting a "mysql_fetch_array(): supplied argument is not a valid MySQL result resource" error.  I think the query statement must be wrong somewhere.
  8. here is my code: [code]$query = "SELECT * FROM gid"; $result=mysql_query($query); $num=mysql_num_rows($result); $i=0; while ($i<$num) { $gid=mysql_result($result,$i,"name"); $queryb = "SELECT * FROM testbracket WHERE gid='$gid'"; $resultb=mysql_query($queryb); $numb=mysql_num_rows($resultb); $ib=0; $grouppoints=0; while ($ib<$numb) { $points=mysql_result($resultb,$ib,"points"); $grouppoints += $points; $ib++; } //form an array or something else here $i++; } [/code]
  9. In my script I'm querying a set of names and numbers. Certain numbers are totaled up and associated with the name.  I am then trying to display the list of numbers in descending  order with the associated name with it.  Now I'm not really sure how I'm going to do this, I tried using an associated array, but I don't know how I would find the highest value to start the for loop. Is it possible to have an array that has two values that "stick" together.  So if I sorted the array by number, the numbers would stay associated with the name?
  10. Read the book at hudzilla.org, it has helped me a lot.
  11. Thanks everyone.  I swore I checked it for grammar and didn't find anything.  Just a stupid mistake!
  12. In my code, I have an inputted string exploded into an array.  I can type echo "$invitearray[0] $invitearray[1] ... "; and get it to display certain elements within an array.  The only problem is I'm trying to run a for loop, and to do that I need the total number of elements in the array.  When I run $sizearray = count($invitearray);, $sizearray equals 0.  Any idea what's wrong? [code]$invitearray = explode(',', $invitelist); echo "$invitearray[0] $invitearray[1] $invitearray[2] $invitearray[3]"; $sizearray = count($invitearrary); echo "<br><br>$sizearray"; for ($j=0; $j<$sizearray; $j++) { echo "$invitearray[$j]"; }[/code]
  13. Yah, I ended up doing that.  I'm just hoping this problem won't bug me when I absolutely have to be able to delete a row.
  14. Well, I found a different way to do a user activation.  But I'm still curious as to why I can't delete it!
  15. Could this problem have something to do with my MySQL accounts permissions? I'm going to test this script on my other server and see if it works.  If it does, I think it's a permissions issue.  How do I change an accounts permissions? I lost the walkthrough I use to have.
  16. I just tried it by itself and it didn't work either.  An exact script but with different table and field names works fine on another part of my site. [code]<?php include "config.php"; $activation = $_GET['id']; mysql_query("DELETE FROM 'uauser' WHERE activation='$activation'") or die(); echo "must of worked"; ?> [/code] No one has any idea what I'm doing wrong?
  17. In my script, the user enters his activation code. If the activation code matches the one found in the database, the users data associated with that activation code is selected from the unactivated user table and added to the activated user table.  My script also deletes activation codes that have already been used.  My only problem is that my script will not delete the row in the unactivated user table. [code]<?php include "config.php"; $activation = $_GET['id']; $query="SELECT * FROM uauser WHERE activation='$activation'"; $result=mysql_query($query); $num=mysql_num_rows($result); if ($num > 0 ) { $row = mysql_fetch_assoc ($result); $user = $row['user']; $password = $row['password']; $realname = $row['realname']; $email = $row['email']; $joineddate = $row['joindeddate']; mysql_query("DELETE FROM 'uauser' WHERE activation='$activation' LIMIT 1"); $query = "INSERT INTO user (user, password, realname, email, joineddate) VALUES('".$user."','".$password."','".$realname."','".$email."','".$joineddate."')"; $result = mysql_query($query); echo "Activation successful!"; } else { echo "Activation unsuccessful.  Your activation code wasn't found."; } ?> [/code] Help is much appreciated.  The deletion codes perfectly in a script that just deletes stuff.  I think since I queried the database before I tried deleting stuff, it is getting messed up.
  18. My array just printed out the four identical values 127.0.0.1127.0.0.1127.0.0.1127.0.0.1 from the database.  Thanks for the help, arrays aren't a must use, I just thought it would make it easier.  The SQL version should be easier. Thanks again!
  19. I'm trying to make a php script that checks a database for blocked IP addresses.  If the user's IP is on the blocked IP list, the page is suppose to not load and show a small message.  I'm trying to set it up by combining the database data into an array. [code]$sql = mysql_query("SELECT ip FROM blockedips") or die(0);         while ($array = mysql_fetch_array($sql)) {     $data[] = $array[0]; } for ($i = 0; $i < count($data); ++$i) {         print $data[$i];     }[/code] That code fetches the database data and compiles it into an array.  I printed the array just to make sure if works.  Now I'm trying to make a conditional statement using arrays.  I tried: [code]if($ip==$data[]) { code here } else { other code here }[/code] but I get an error saying I can't use [].  How do I get a conditional statement to check each value in an array?  I can sort of think of a very complex way, but I was thinking there would be an easy solution.  Thanks for the help!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.