
kr3m3r
Members-
Posts
36 -
Joined
-
Last visited
Never
Profile Information
-
Gender
Not Telling
kr3m3r's Achievements

Member (2/5)
0
Reputation
-
[SOLVED] effective due date? timestamp? FATAL error.
kr3m3r replied to kr3m3r's topic in PHP Coding Help
Well, the book I'm using said there was a timestamp()function, but I can't seem to find more on it. Now I'm trying to use date and the result I'm getting is: Warning: Wrong parameter count for date() in /home/.titch/rwkremer/kr3m3r.com/Sub_Check_Out.php on line 105 from the code: echo date(); I'm really just hoping to find a way to create a due date of 14 days from the date of check out. Thanks again for the help. -Robb -
Hi, I'm building a library with php, and want to create a way for the return date for an item to automatically be 14 days after they are checked out. I had hoped to use something like: $Check_Out_Date=TIMESTAMP[(]; and then manipulate that with substrings and whatnot, until i could put it back together as 2 weeks later. Unfortunately I'm getting a FATAL error, with this. Any recommendations would be really appreciated. Thanks for your time, -Robb
-
Is there anything I can write into my php page that will make it so the user only sees the www.domain.com rather than www.domain.com/foo.php ? thanks for any advice you guys have! -Robb
-
OK tried it: New code is: $UUserID = (substr($UFName,0,1).substr($ULName,0,); $query = "Select UserID from User where UserID regexp '".$UUserID."' order by UserID desc limit 1"; $result = mysql_query($query); echo '<br />Here is the query: '.$query; echo '<br />Here is the result: '.$result; here is what echos back to the browser: Here is the query: Select UserID from User where UserID regexp 'RPark' order by UserID desc limit 1 Here is the result: Resource id #2 How do I get somthing other than Resource id #2? It seems that the regexp is on the right track, but I can't get it to work. Thanks again for the help. -Robb
-
Hi guys, I'm trying to automate the way in which user ID's are generated for my site. I want it to be done using the first initial of the User's First Name, the first 8 letters of their last name, and here is the tricky part, a number, that gets incremented if a UserID already exists with that combination. i.e. John Doe -> JDoe1, if another John Doe were added to the table, they would go in as JDoe2, and the next would be JDoe3 and so on. I know I can use strlen(FirstName,0,1).strlen(LastName,0, for the Name portion. What I'm having a really hard time dealing with is how I can get the number portion to work. I've tried if statements: $TestUUserID = (substr($UFName,0,1).substr($ULName,0,."1"); $query = "select * from User where UserID = '".$TestUUserID."'"; $result = mysql_query($query); echo '<br />query: '.$query.'<br />result: '.$result.'<br />'; if(result) { $queryb = "insert into User values ('".$TestUUserID."','".$UFName."','".$ULName."','".$UAddress."','".$UCity."','".$UState."','".$UZip."','".$UEmail."','".$UPhone."','".$UAdmin."','".$UPassword."')"; $resultb = mysql_query($queryb); } if(result) {echo 'if 1<br />'; $TestUUserID = (substr($UFName,0,1).substr($ULName,0,."2"); $query = "select * from User where UserID = '".$TestUUserID."'"; $result = mysql_query($query); echo '<br />query: '.$query.'<br />result: '.$result.'<br />'; $queryb = "insert into User values ('".$TestUUserID."','".$UFName."','".$ULName."','".$UAddress."','".$UCity."','".$UState."','".$UZip."','".$UEmail."','".$UPhone."','".$UAdmin."','".$UPassword."')"; $resultb = mysql_query($queryb); } and I've tried looping: $i=1; while(result || $i<9) { $TestUUserID = (substr($UFName,0,1).substr($ULName,0,."'".$i."'"); $query = "select * from User where UserID = '".$TestUUserID."'"; $result = mysql_query($query); $i++; } and I'm stumped. Any help would be really appreciated. -Robb
-
making the field auto-incrementing will mean that whatever I put into it will automatically be post incremented? How does that affect insertions? Thanks Thorpe, you're saving my ass again. Can a string be autoincremented? This is my Primary key.
-
Hi guys, I've been working on this for too long, and am probably missing something obvious. I'm trying to insert a unique UserID into my database. To do this I'm using the substring to get the first letter of the first name, then substring to get the first 8 letters of the last name, and then I want to append the concatenated string with 1, or if that is taken, the next hightest available number. But I'm having a heck of a time getting it to work. I had it working at one point for a single name, but it wouldn't deal with duplicate names, I'm pretty mixed up as to why it doesn't work now. The code is: $TestUUserID = (substr($UFName,0,1).substr($ULName,0,."1"); $query = "select * from User where UserID = ".$TestUUserID; $result = mysql_query($query); if (!$result) { $i=2; while(!$result && $i<9) { $TestUUserID = (substr($UFName,0,1).substr($ULName,0,.$i); $query = "select * from User where UserID = ".$TestUUserID; $result = mysql_query($query); $i=$i+1; } } if ($result) { echo 'Sorry, at this time, there are too many with that name combination.'; exit; } Thanks for your time and help, I really appreciate it. -Robb
-
Hi guys, I'm trying to search my database for any rows in which one of the columns has part of the search term. It goes something like this: Search term foo. Select * from Library_Asset where UPC like %"foo" or Title like %"foo" or MajorAttribute like %"foo" or SecondaryAttribute like %"foo"; The php code I wrote is: $query = "select * from Library_Asset where UPC like '%".$searchterm."%'" or Title like '%".$searchterm."%'" or MajorAttribute like '%".$searchterm."%'" or SecondaryAttribute like '%".$searchterm."%'"; Which I'm pretty sure is awful. So any help you guys can give me would be incredibly appreciated. Thanks for your time -Robb
-
[SOLVED] Database won't accept more than one item!
kr3m3r replied to kr3m3r's topic in PHP Coding Help
UPC and ItemType in the SQL needed to be char -
Here is the code for my interface: <?php session_start(); ?> <html> <head> <title>Multimedia Library - New Item Entry</title> </head> <body> <h1>Multimedia Library - New Item Entry</h1> <?php //create short variable names $UPC=$_POST['UPC']; $title=$_POST['Title']; $MajorAttribute=$_POST['MajorAttribute']; $SecondaryAttribute=$_POST['SecondaryAttribute']; $itemtype = $_SESSION['itemtype']; if(!$UPC || !$title || !$MajorAttribute || !$SecondaryAttribute || !$itemtype) { echo 'You have not entered all the required details. <br />' .'Please go back and try again.'; exit; } $UPC=addslashes($UPC); $title=addslashes($title); $MajorAttribute=addslashes($MajorAttribute); $SecondaryAttribute=addslashes($SecondaryAttribute); $itemtype=addslashes($itemtype); @ $db = mysql_pconnect('school', 'library', 'alpha321'); if(!$db) { echo 'Error: Could not connect to database. Please try later.'; exit; } mysql_select_db('cisse'); $query = "insert into Library_Asset values ('".$UPC."','".$title."','".$MajorAttribute."','".$SecondaryAttribute."','".$itemtype."')"; echo '<br />'; echo $query; echo '<br />'; $result = mysql_query($query); if($result) { echo mysql_affected_rows().' item(s) inserted into database.<br /><br />'; echo 'You entered: <br />'; echo $UPC; echo '<br />'; echo $title; echo '<br />'; echo $MajorAttribute; echo '<br />'; echo $SecondaryAttribute; echo '<br />into the Library'; echo '<br /><br />'; } ?> <INPUT TYPE = BUTTON Value = "Add Another Item" onClick="window.location.href='http://www.kr3m3r.com/newitem.html'"> </body> </html> and here is the query which set up the database: SQL query: CREATE TABLE `Library_Asset` ( `UPC` INT( 13 ) UNSIGNED NOT NULL , `Title` CHAR( 100 ) NOT NULL , `MajorAttribute` CHAR( 100 ) NOT NULL , `SecondaryAttribute` CHAR( 100 ) NOT NULL , PRIMARY KEY ( `UPC` ) ) ; I can add a number of items with UPC values of 123 or 234 or 001234 but for some reason when I attempted to enter a few items to test the database, it will only add the first item I add. Two of the test cases were: 0024543151906 iRobot Alex Proyas Will Smith and 0042284347921 Live at the Apollo 1962 James Brown PolyGram Records which ever one I entered first would be added to the table with no problem (I looked at it through the command line interface) but when I'd go to add the other item, it would fail. (I tried deleting each item from the database, and then starting with the other, and only the first one entered would be added to the table, the second one would not be added to the table). Any help in reasolving this issue would be greatly appreciated. -Robb
-
I'm trying to pass a variable from the first page (tells me what type of item they are going to enter [dvd,cd,book]) i'm writing through the second page (where they enter all the pertinent information [title author etc.]) into a third page where the items are submitted into the database. I guess part of the question was, in the sticky posted above, they said header errors occured due to where something like session_start() was posted. I'm just not clear on what they meant. Thanks, -Robb
-
In my last posting someone suggested using session start() to pass a variable through multiple php pages using the $_SESSION['x']=$x;. I don't quite understand how to do it. Another individual suggested using which I'm not sure how to do either. Any help with this would be really appreciated. -Robb
-
[SOLVED] how do you pass a variable to a second php page?
kr3m3r replied to kr3m3r's topic in PHP Coding Help
I'm sorry guys, I can't seem to get the sessions thing to work. Maybe I'm not doing it right, but I tried the variations you guys gave me. If it might help, here is all the code I've done so far for this site: the initial html page is this (this is where the itemtype variable is first created): <html> <head> <title>Multimedia Library - New Item Entry</title> </head> <body> <h1>Multimedia Library - New Item Entry</h1> <form action="preinsert_item.php" method="post"> Choose Item Type to Add to Collection: <select name="itemtype"> <option value = "1">Book</option> <option value = "2">DVD</option> <option value = "3">CD</option> </select> <br /> <br /> <input type = "submit" value="Submit"> </form> </body> </html> I know this is already in this thread, but in case you fast-forwarded to this point here is the pre-insert item (I can call itemtype successfully here, using the $_POST method) <html> <head> <title>Multimedia Library - New Item Entry</title> </head> <body> <h1>Multimedia Library - New Item Entry</h1> <?php switch($itemtype) { case '1'; echo '<form action="insert_item.php" method="post">'; echo '<table boder="0">'; echo '<tr>'; echo '<td>UPC</td>'; echo '<td><input type="text" name="UPC" maxlength="13" size="13"> <br /></td>'; echo '</tr>'; echo '<tr>'; echo '<td>Title</td>'; echo '<td><input type="text" name="Title" maxlength="100" size="25"><br /></td>'; echo '</tr>'; echo '<tr>'; echo '<td>Author</td>'; echo '<td><input type="text" name="MajorAttribute" maxlength="100" size="25"><br /></td>'; echo '</tr>'; echo '<tr>'; echo '<td>Publisher</td>'; echo '<td><input type="text" name="SecondaryAttribute" maxlength="100" size="25"><br /></td>'; echo '</tr>'; echo '<tr>'; echo '<td colspan="2"><input type="submit" value="Register"></td>'; echo '</tr>'; echo '</table>'; echo '</form>'; break; case '2'; echo '<form action="insert_item.php" method="post">'; echo '<table boder="0">'; echo '<tr>'; echo '<td>UPC</td>'; echo '<td><input type="text" name="UPC" maxlength="13" size="13"> <br /></td>'; echo '</tr>'; echo '<tr>'; echo '<td>Title</td>'; echo '<td><input type="text" name="Title" maxlength="100" size="25"><br /></td>'; echo '</tr>'; echo '<tr>'; echo '<td>Main Star</td>'; echo '<td><input type="text" name="MajorAttribute" maxlength="100" size="25"><br /></td>'; echo '</tr>'; echo '<tr>'; echo '<td>Director</td>'; echo '<td><input type="text" name="SecondaryAttribute" maxlength="100" size="25"><br /></td>'; echo '</tr>'; echo '<tr>'; echo '<td colspan="2"><input type="submit" value="Register"></td>'; echo '</tr>'; echo '</table>'; echo '</form>'; break; case '3'; echo '<form action="insert_item.php" method="post">'; echo '<table boder="0">'; echo '<tr>'; echo '<td>UPC</td>'; echo '<td><input type="text" name="UPC" maxlength="13" size="13"> <br /></td>'; echo '</tr>'; echo '<tr>'; echo '<td>Title</td>'; echo '<td><input type="text" name="Title" maxlength="100" size="25"><br /></td>'; echo '</tr>'; echo '<tr>'; echo '<td>Band</td>'; echo '<td><input type="text" name="MajorAttribute" maxlength="100" size="25"><br /></td>'; echo '</tr>'; echo '<tr>'; echo '<td>Label</td>'; echo '<td><input type="text" name="SecondaryAttribute" maxlength="100" size="25"><br /></td>'; echo '</tr>'; echo '<tr>'; echo '<td colspan="2"><input type="submit" value="Register"></td>'; echo '</tr>'; echo '</table>'; echo '</form>'; break; } ?> </body> </html> and here is the last page, where I can no longer figure out a way to access the itemtype variable: <html> <head> <title>Multimedia Library - New Item Entry</title> </head> <body> <h1>Multimedia Library - New Item Entry</h1> <?php //create short variable names $UPC=$_POST['UPC']; $title=$_POST['Title']; $MajorAttribute=$_POST['MajorAttribute']; $SecondaryAttribute=$_POST['SecondaryAttribute']; $itemtype = $_POST['$itemtype']; if(!$UPC || !$title || !$MajorAttribute || !$SecondaryAttribute || !$itemtype) { echo 'You have not entered all the required details. <br />' .'Please go back and try again.'; exit; } $UPC=addslashes($UPC); $title=addslashes($title); $MajorAttribute=addslashes($MajorAttribute); $SecondaryAttribute=addslashes($SecondaryAttribute); $itemtype=addslashes($itemtype); @ $db = mysql_pconnect('school', 'library', 'alpha321'); if(!$db) { echo 'Error: Could not connect to database. Please try later.'; exit; } mysql_select_db('cisse'); $query = "insert into cisse values ('".$UPC."','".$title."','".$MajorAttribute."','".$SecondaryAttribute."','".$itemtype."')"; $result = mysql_query($query); if($result) { echo mysql_affected_rows().' item(s) inserted into database.<br /><br />'; } ?> <INPUT TYPE = BUTTON Value = "Add Another Book" onClick="window.location.href='http://www.kr3m3r.com/newitem.html'"> </body> </html> -
[SOLVED] how do you pass a variable to a second php page?
kr3m3r replied to kr3m3r's topic in PHP Coding Help
the itemtype is just a tracker I'm using to note if the user is inputing books(1), dvds(2), or cds (3). Then based on what that says, the itemtype will be used to insert the correct prefaces to the item's characteristics. i.e. if you have a book, then you'll be prompted for the UPC, the Title, the Author, and the Publisher, but if you have a dvd you'll be prompted for the UPC, the title, the main star, and the director. The information for these items is all stored in the same place, but how it is listed to the user will differ depending on the itemtype. I know it might be easier to use multiple tables maybe, but it also seems like that would be a lot more repetitive coding. Also, will the Session thing need an end or some sort of closure??? It sounds pretty cool. Thanks again for all the help. -Robb -
First, you have a few spelling mistakes which may be contributing to your problems. Secondly, are any of the if statements working? Have you tested them?