jsladek
Members-
Posts
154 -
Joined
-
Last visited
Never
About jsladek
- Birthday 11/05/1971
Contact Methods
-
AIM
johnnysladek
-
Website URL
http://www.iobe.net
Profile Information
-
Gender
Male
-
Location
Folcroft
jsladek's Achievements
Newbie (1/5)
0
Reputation
-
not sure if this will help but I had to add this line to mine. Options -MultiViews
-
No I did not write it, well maybe I did. I wrote a program that generates that code based off of the tables in the database. Efforts on the idea stalled but it does work somewhat well. It can be seen here http://www.iobe.net/proj/ It actually builds a whole application here is an example of the app it builds. http://www.iobe.net/proj/workshop/index.php?pg=info I designed it so the pages can stand on their own too, like the one I showed you. http://www.iobe.net/proj/workshop/info.php -John
-
I doubt it, if it were in the IF statments then you would not have been able to print out the sql. I know that the ID is auto incremental but for somereason I think that you may need it (although you said it worked before). As I mentioned earlier, if you have phpMyAdmin or QuickAdmin you can test the sql to see if it works in there just to rule it out.
-
Have you tried running that insert in phpMyAdmin or a similar db interface and see if it works there? Are the birthday feilds TEXT type or a date feild. Also I dont see an id feild in that statement it may have to look like this (or something like it) I added the id feild and '' for the insert INSERT INTO addressbook (id, firstname, lastname, address, home, mobile, work, email, email2, bday, bmonth, byear, address2, phone2, accnt) VALUES ('','asd','asd','','','','','','','0','-','','','','') -John
-
I made a table called info using the following sql... CREATE TABLE `info` ( `id` INT(11) NOT NULL AUTO_INCREMENT , `date` DATE NOT NULL , `total_distance` INT(11) NOT NULL , `total_time` INT(11) NOT NULL , `ave_speed` INT(11) NOT NULL , `rider_id` TEXT NOT NULL , PRIMARY KEY ( `id` ) ) TYPE = MyISAM ; Here is a link to a php script that handles all of the CRUD functions.... (of course icons and such wont work for you) http://iobe.net/proj/workshop/info.php Here is the code.... <? # include ("secure.php"); $pgflow = $_GET[pgflow]; #global $application; if ( $application != "yes" ) { print(" <html> <head> <title>IOBE - PHP - MySQL </title> <link rel='stylesheet' href='styles/style.css' type='text/css' media='all' /> <script language=\"javascript\" type=\"text/javascript\" src=\"js/datetimepicker.js\"></script> <script language=\"javascript\" type=\"text/javascript\"> <!-- function confirmLink() { return confirm(\"Are you sure you want to Delete this Record?\") } //--> </script> </head> <body> "); } # Conditional statements to determine program flow switch ($pgflow) { case 'addrecord': new_record(); break; case 'insertrecord': insert_record(); break; case 'deleterecord': delete_record(); break; case 'editrecord': edit_record(); break; case 'showchanges': show_changes(); break; case 'verified': update_database(); break; default: show_data(); } #------------------------------------------------------------------------------------------------------------------------------- function delete_record(){ //get the variable datakey //database info include("dataConn.php"); $id = $_GET[id]; //print out variables so we can see if they made it #print ("$id <br>"); $date = $_GET[date]; //print out variables so we can see if they made it #print ("$date <br>"); $total_distance = $_GET[total_distance]; //print out variables so we can see if they made it #print ("$total_distance <br>"); $total_time = $_GET[total_time]; //print out variables so we can see if they made it #print ("$total_time <br>"); $ave_speed = $_GET[ave_speed]; //print out variables so we can see if they made it #print ("$ave_speed <br>"); $rider_id = $_GET[rider_id]; //print out variables so we can see if they made it #print ("$rider_id <br>"); //connect to database mysql_select_db($database_dataConn, $dataConn); // create sql $sql_delete_record ="DELETE FROM `info` WHERE `id` ='$id' LIMIT 1 ; "; #print ("$sql_delete_record"); // delete the old record if it exists $result = mysql_query($sql_delete_record); // close database mysql_close(); //show records in table show_data(); } #------------------------------------------------------------------------------------------------------------------------------- function new_record(){ //title of page and open table print ("<br><br><center><h3> Add New Record in Table: info</h3></center> <form action='".$_SERVER['PHP_SELF']."?pg=info&pgflow=insertrecord' method='POST' name='log_entry'> <TABLE align='center' border='1'>"); print("<tr><td>id</td><td><input name='id' type='text' id='id'><img src='images/primarykey_icon.png' width='16' height='16' border='0' alt='Primary Key Feild'><img src='images/autoincrement_icon.png' width='16' height='16' border='0' alt='Auto Incrementing'></td></tr> "); print("<tr><td>date</td><td><input name='date' type='text' id='date'><a href=\"javascript:NewCal('date','ddmmmyyyy')\"><img src=\"images/calendar_icon.png\" width=\"16\" height=\"16\" border=\"0\" alt=\"Pick a date\"></a> </td></tr> "); print("<tr><td>total_distance</td><td><input name='total_distance' type='text' id='total_distance'></td></tr> "); print("<tr><td>total_time</td><td><input name='total_time' type='text' id='total_time'></td></tr> "); print("<tr><td>ave_speed</td><td><input name='ave_speed' type='text' id='ave_speed'></td></tr> "); print("<tr><td>rider_id</td><td><input name='rider_id' type='text' id='rider_id'></td></tr> "); //add submit and reset buttons print(" <tr> <td><input type='submit' name='submit' value='submit'></td> <td><input type='reset' name='reset' value='reset'></td> </tr> </table> </form> "); } #------------------------------------------------------------------------------------------------------------------------------- function insert_record(){ include("dataConn.php"); // Variables can be declared here $id = $_POST[id]; //print out variables so we can see if they made it #print ("$id <br>"); $date = $_POST[date]; //print out variables so we can see if they made it #print ("$date <br>"); $total_distance = $_POST[total_distance]; //print out variables so we can see if they made it #print ("$total_distance <br>"); $total_time = $_POST[total_time]; //print out variables so we can see if they made it #print ("$total_time <br>"); $ave_speed = $_POST[ave_speed]; //print out variables so we can see if they made it #print ("$ave_speed <br>"); $rider_id = $_POST[rider_id]; //print out variables so we can see if they made it #print ("$rider_id <br>"); //connect to database mysql_select_db($database_dataConn, $dataConn); //create sql $sql_insert = "INSERT INTO info (id, date, total_distance, total_time, ave_speed, rider_id) VALUES ('$id', '$date', '$total_distance', '$total_time', '$ave_speed', '$rider_id')"; #print("$sql_insert"); // this statement actually executes the sql $result = mysql_query($sql_insert); # make this vaiable match the last one // close database mysql_close(); //show records in table show_data(); } #------------------------------------------------------------------------------------------------------------------------------- function edit_record(){ // this pulls in connection specific information to connect to the database include ("dataConn.php"); //get vars $id = $_GET[id]; //print out variables so we can see if they made it #print ("$id <br>"); $date = $_GET[date]; //print out variables so we can see if they made it #print ("$date <br>"); $total_distance = $_GET[total_distance]; //print out variables so we can see if they made it #print ("$total_distance <br>"); $total_time = $_GET[total_time]; //print out variables so we can see if they made it #print ("$total_time <br>"); $ave_speed = $_GET[ave_speed]; //print out variables so we can see if they made it #print ("$ave_speed <br>"); $rider_id = $_GET[rider_id]; //print out variables so we can see if they made it #print ("$rider_id <br>"); //connect to database mysql_select_db($database_dataConn, $dataConn); //create sql $sql_table_data="SELECT * FROM info WHERE `id` ='$id' LIMIT 1 ;"; #print("$sql_table_data"); // this statement actually executes the sql $result = mysql_query($sql_table_data); //access record info and build form while($row = mysql_fetch_array($result)) { //title of page and open table print ("<br><br><center><h3> Edit Log entry </h3></center> <form action='".$_SERVER['PHP_SELF']."?pg=info&pgflow=showchanges' method='POST' name='log_entry'> <TABLE border='1'>"); print("<tr><td>id</td><td><input name='id' type='text' id='id' value='$row[id]'><img src='images/primarykey_icon.png' width='16' height='16' border='0' alt='Primary Key Feild'> <img src='images/autoincrement_icon.png' width='16' height='16' border='0' alt='Auto Incrementing'> </td></tr> "); print("<input name='orig_id' type='hidden' id='orig_id' value='$row[id]'> "); print("<tr><td>date</td><td><input name='date' type='text' id='date' value='$row[date]'><a href=\"javascript:NewCal('date','ddmmmyyyy')\"><img src=\"images/calendar_icon.png\" width=\"16\" height=\"16\" border=\"0\" alt=\"Pick a date\"></a> </td></tr> "); print("<input name='orig_date' type='hidden' id='orig_date' value='$row[date]'> "); print("<tr><td>total_distance</td><td><input name='total_distance' type='text' id='total_distance' value='$row[total_distance]'></td></tr> "); print("<input name='orig_total_distance' type='hidden' id='orig_total_distance' value='$row[total_distance]'> "); print("<tr><td>total_time</td><td><input name='total_time' type='text' id='total_time' value='$row[total_time]'></td></tr> "); print("<input name='orig_total_time' type='hidden' id='orig_total_time' value='$row[total_time]'> "); print("<tr><td>ave_speed</td><td><input name='ave_speed' type='text' id='ave_speed' value='$row[ave_speed]'></td></tr> "); print("<input name='orig_ave_speed' type='hidden' id='orig_ave_speed' value='$row[ave_speed]'> "); print("<tr><td>rider_id</td><td><input name='rider_id' type='text' id='rider_id' value='$row[rider_id]'></td></tr> "); print("<input name='orig_rider_id' type='hidden' id='orig_rider_id' value='$row[rider_id]'> "); //add submit and reset buttons print(" <tr> <td><input type='submit' name='submit' value='submit'></td> <td><input type='reset' name='reset' value='reset'></td> </tr> </table> </form> "); } } #------------------------------------------------------------------------------------------------------------------------------- function show_changes(){ // Variables can be declared here $id = $_POST[id]; $orig_id = $_POST[orig_id]; //print out variables so we can see if they made it #print ("$id <br>"); #print ("$orig_id <br>"); $date = $_POST[date]; $orig_date = $_POST[orig_date]; //print out variables so we can see if they made it #print ("$date <br>"); #print ("$orig_date <br>"); $total_distance = $_POST[total_distance]; $orig_total_distance = $_POST[orig_total_distance]; //print out variables so we can see if they made it #print ("$total_distance <br>"); #print ("$orig_total_distance <br>"); $total_time = $_POST[total_time]; $orig_total_time = $_POST[orig_total_time]; //print out variables so we can see if they made it #print ("$total_time <br>"); #print ("$orig_total_time <br>"); $ave_speed = $_POST[ave_speed]; $orig_ave_speed = $_POST[orig_ave_speed]; //print out variables so we can see if they made it #print ("$ave_speed <br>"); #print ("$orig_ave_speed <br>"); $rider_id = $_POST[rider_id]; $orig_rider_id = $_POST[orig_rider_id]; //print out variables so we can see if they made it #print ("$rider_id <br>"); #print ("$orig_rider_id <br>"); // this pulls in connection specific information to connect to the database include ("dataConn.php"); //connect to database mysql_select_db($database_dataConn, $dataConn); //create sql $sql_user_data="SELECT * FROM info WHERE `id` ='$orig_id' LIMIT 1 ;"; #print("$sql_user_data"); // this statement actually executes the sql $result = mysql_query($sql_user_data); //access record info and build form while($row = mysql_fetch_array($result)) { //title of page and open table print ("<br><br><center><h3> Please Verify Changed below and Submit to database if correct. </h3></center> <form action='".$_SERVER['PHP_SELF']."?pg=info&pgflow=verified' method='POST' name='log_entry'> <TABLE>"); if ($row[id]== $id) {$fontcolor = 'black';} else {$fontcolor = 'red';} print("<tr><td><font color=$fontcolor>id</font></td><td><input name='xid' type='text' id='xid' value='$id' disabled></td></tr>"); print("<input name='id' type='hidden' id='id' value='$id'>"); print("<input name='orig_id' type='hidden' id='orig_id' value='$orig_id'>"); if ($row[date]== $date) {$fontcolor = 'black';} else {$fontcolor = 'red';} print("<tr><td><font color=$fontcolor>date</font></td><td><input name='xdate' type='text' id='xdate' value='$date' disabled></td></tr>"); print("<input name='date' type='hidden' id='date' value='$date'>"); print("<input name='orig_date' type='hidden' id='orig_date' value='$orig_date'>"); if ($row[total_distance]== $total_distance) {$fontcolor = 'black';} else {$fontcolor = 'red';} print("<tr><td><font color=$fontcolor>total_distance</font></td><td><input name='xtotal_distance' type='text' id='xtotal_distance' value='$total_distance' disabled></td></tr>"); print("<input name='total_distance' type='hidden' id='total_distance' value='$total_distance'>"); print("<input name='orig_total_distance' type='hidden' id='orig_total_distance' value='$orig_total_distance'>"); if ($row[total_time]== $total_time) {$fontcolor = 'black';} else {$fontcolor = 'red';} print("<tr><td><font color=$fontcolor>total_time</font></td><td><input name='xtotal_time' type='text' id='xtotal_time' value='$total_time' disabled></td></tr>"); print("<input name='total_time' type='hidden' id='total_time' value='$total_time'>"); print("<input name='orig_total_time' type='hidden' id='orig_total_time' value='$orig_total_time'>"); if ($row[ave_speed]== $ave_speed) {$fontcolor = 'black';} else {$fontcolor = 'red';} print("<tr><td><font color=$fontcolor>ave_speed</font></td><td><input name='xave_speed' type='text' id='xave_speed' value='$ave_speed' disabled></td></tr>"); print("<input name='ave_speed' type='hidden' id='ave_speed' value='$ave_speed'>"); print("<input name='orig_ave_speed' type='hidden' id='orig_ave_speed' value='$orig_ave_speed'>"); if ($row[rider_id]== $rider_id) {$fontcolor = 'black';} else {$fontcolor = 'red';} print("<tr><td><font color=$fontcolor>rider_id</font></td><td><input name='xrider_id' type='text' id='xrider_id' value='$rider_id' disabled></td></tr>"); print("<input name='rider_id' type='hidden' id='rider_id' value='$rider_id'>"); print("<input name='orig_rider_id' type='hidden' id='orig_rider_id' value='$orig_rider_id'>"); //add submit and reset buttons print(" <tr> <td><input type='submit' name='submit' value='submit'></td> <td><input type='reset' name='reset' value='reset'></td> </tr> </table> </form> "); } #end while($row = mysql_fetch_array($result)) exit; } #end function show_changes(){ #------------------------------------------------------------------------------------------------------------------------------- function update_database(){ include("dataConn.php"); // Variables can be declared here $id = $_POST[id]; $orig_id = $_POST[orig_id]; //print out variables so we can see if they made it #print ("$id <br>"); #print ("$orig_id <br>"); $date = $_POST[date]; $orig_date = $_POST[orig_date]; //print out variables so we can see if they made it #print ("$date <br>"); #print ("$orig_date <br>"); $total_distance = $_POST[total_distance]; $orig_total_distance = $_POST[orig_total_distance]; //print out variables so we can see if they made it #print ("$total_distance <br>"); #print ("$orig_total_distance <br>"); $total_time = $_POST[total_time]; $orig_total_time = $_POST[orig_total_time]; //print out variables so we can see if they made it #print ("$total_time <br>"); #print ("$orig_total_time <br>"); $ave_speed = $_POST[ave_speed]; $orig_ave_speed = $_POST[orig_ave_speed]; //print out variables so we can see if they made it #print ("$ave_speed <br>"); #print ("$orig_ave_speed <br>"); $rider_id = $_POST[rider_id]; $orig_rider_id = $_POST[orig_rider_id]; //print out variables so we can see if they made it #print ("$rider_id <br>"); #print ("$orig_rider_id <br>"); //connect to database mysql_select_db($database_dataConn, $dataConn); //create sql $sql_update="UPDATE `info` SET `id` = '$id',`date` = '$date',`total_distance` = '$total_distance',`total_time` = '$total_time',`ave_speed` = '$ave_speed',`rider_id` = '$rider_id' WHERE `id` ='$orig_id' LIMIT 1 ;"; #print("$sql_update"); // this statement actually executes the sql $result = mysql_query($sql_update); # make this vaiable match the last one // close database mysql_close(); //show records in table show_data(); exit; } function show_data(){ // Title of page print "<center><h3>info</h3></center>"; // this pulls in connection specific information to connect to the database include ("dataConn.php"); //connect to database mysql_select_db($database_dataConn, $dataConn); //create sql $sql_user_data="SELECT * FROM info"; // this statement actually executes the sql $result = mysql_query($sql_user_data); //Create table print("<table border='1' align='center'><tr>"); //add edit column header print("<th>Edit"); //create column headers based on feilds from table print("<th>id"); print("<th>date"); print("<th>total_distance"); print("<th>total_time"); print("<th>ave_speed"); print("<th>rider_id"); // add the delete column header print("<th>Delete</tr>"); //now we iterate through the results of the SQL Query while($row = mysql_fetch_array($result)) { //create a new row in the table print("<tr>"); // add an edit icon for the row print("<td align='center'><a href='".$_SERVER['PHP_SELF']."?pg=info&pgflow=editrecord&id=$row[id]'><img src='images/edit_icon.png' width='16' height='16' border='0' alt='edit'></a></td>"); print("<td>$row[id] </td>"); print("<td>$row[date] </td>"); print("<td>$row[total_distance] </td>"); print("<td>$row[total_time] </td>"); print("<td>$row[ave_speed] </td>"); print("<td>$row[rider_id] </td>"); // add a delete icon for the row print("<td align='center'><a href='".$_SERVER['PHP_SELF']."?pg=info&pgflow=deleterecord&id=$row[id]' ONCLICK=\"return confirmLink()\"><img src='images/delete_icon.png' width='16' height='16' border='0' alt='edit'></a></td>"); print("</tr>"); } #end while( = mysql_fetch_array()) // add a final row to the end of the table that has a link to add a record print("<tr><td align='right'><a href='".$_SERVER['PHP_SELF']."?pg=info&pgflow=addrecord'>New Record</a><td></tr>"); // finally we close the table print("</table>"); } ?> There is another file that is used called include("dataConn.php"); That file looks like this... <? $hostname_dataConn = "localhost"; # <- change this if database on a different server $database_dataConn = "your_table_name_here"; # <- change this to the name of your table $username_dataConn = "your_username_here"; # <- change this to the user name for the database $password_dataConn = "your_password_here"; # <- change this to the password of your username $dataConn = mysql_pconnect($hostname_dataConn, $username_dataConn, $password_dataConn) or trigger_error(mysql_error(),E_USER_ERROR); ?> You can edit that with your info to test the script.. -John
-
what is the name of the table?
-
Post the Sql and lets take a look at them.
-
then the program is getting in there. Have you tried printing out the sql to see what the statment looks like?? $sql = "INSERT INTO $table (firstname, lastname, address, home, mobile, work, email, email2, bday, bmonth, byear, address2, phone2, accnt) VALUES ('$firstname','$lastname','$address','$home','$mobile','$work','$email','$email2','$bday','$bmonth','$byear','$address2','$phone2','$accnt')"; $result = mysql_query($sql); print "Insert Statement: $sql"; $sql = "INSERT INTO address_in_groups SELECT LAST_INSERT_ID() id, group_id FROM group_list WHERE group_name = '".$group_name."'"; $result = mysql_query($sql); print "Insert Into address statement: $sql"; -John
-
are you getting this message when you try to insert a record? Information entered into address book
-
Hi sanderphp, Can you post the SQL to create the table you are working on? -John
-
Just a little additional info. I was shown another way to do this and it has apache actually check to see if the file or directory exists on the server. This is probably a better way. RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /public.php?sub=$1 [L] -Regards John
-
Here is a rule that I came up with that seems to work. RewriteRule ^([^/\.]+)/?$ /public.php?org=$1 it looks for a period in the filename Maybe it will help someone in the future. -john
-
Damn it, public.php is what the url needs to become, this will be a little trickier than I thought. -John
-
so the trick is to write a rule that only triggers on public.php (if that is what I use). Makes sense..