sanderphp
Members-
Posts
122 -
Joined
-
Last visited
Never
Everything posted by sanderphp
-
Good afternoon, I'm just getting started with mySQL and had been testing some imports and queries using a hosted mySQL db and I had been learning a lot. I just registered a domain and got a host and started using it. I created a db and tables and went to do my import but I'm getting: Error SQL query: LOAD DATA INFILE'/home2/woodchuc/tmp/phpoTUM64' INTOTABLE`transactions`FIELDSTERMINATEDBY',' ENCLOSEDBY'"' ESCAPEDBY'\\' LINESTERMINATEDBY'\r\n' IGNORE 6LINES ( `date` ,`description` ,`amount` ) MySQL said: #1045 - Access denied for user 'woodchuc'@'localhost' (using password: YES) Doesn't really make any sense to me because I logged into phpadmin via the admin panel for my host and am able to create db's and tables. It doesn't give me the option to choose a user so I assume that the user that is being logged in has rights as I'm able to create db's, tables, write to the table, etc. I can't import data though I hope I'm missing something basic, been scratching my head for a while now. Thanks
-
Thanks, that's all I needed was the tr and td tags. I forgot that those were required for a table to function correctly.
-
What color font are you seeing? I just checked on another pc and this one shows white text while the other shows black text and not table box
-
http://www.sanderandmeena.com/php/notes/examples/complete/quotes.php
-
I don't want to post my public domain here, but it's just the text, with a table underneath it. I want the text to be inside the box.
-
Even this way, the output is still displayed above the table. <head> <link rel="stylesheet" href="styles.css" type="text/css"> </head> <TABLE HEIGHT=75% WIDTH=75% BORDER="2" VALIGN="Middle" ALIGN="center"> <?php require( "config.php" ); $Quote = new CQuote; if( $Quote->Get( $strQuote ) == 0 ) echo $strQuote; ?> </table>
-
My table is appearing below the php script output. How do I return the value if the script inside the table?
-
Other than that typo it should work correctly right? I can't get it to.
-
I'm using a simple script to display a quote on the screen. I added the table line to get the output to appear in the center, but its still at the top of the screen. How do I get it centered in the middle of the page vertically? <TABLE HEIGTH=75% WIDTH=75% BORDER="0" VALIGN="Middle" ALIGN="center"> <?php echo '<head>'; echo ' <link rel="stylesheet" href="styles.css" type="text/css">'; echo '</head>'; require( "config.php" ); $Quote = new CQuote; if( $Quote->Get( $strQuote ) == 0 ) echo $strQuote; ?> </table>
-
Do you guys recommend putting the alignment in the styles.css or just in the php. All I'm doing is reading a random quote from a file and then displaying in on a page. I want the quote to be in the center vertically and horizontally. <TABLE HEIGTH=75% WIDTH=75% BORDER="0" VALIGN="Middle" ALIGN="center"> <?php echo '<head>'; echo ' <link rel="stylesheet" href="styles.css" type="text/css">'; echo '</head>'; require( "config.php" ); $Quote = new CQuote; if( $Quote->Get( $strQuote ) == 0 ) echo $strQuote; ?> </table>
-
It was the slash in front of /styles.css like fantomel suggested. Thanks for everyones help. This is great stuff.
-
Below is my styles.css file. I'm not seeing any errors, but my php file is not using it. body { background-color: #330000; } body, td, th { color: #FFCC99; } h1 { color: #FF6666; } h2 { color: #FF99CC; } h3, h4 { color: #CC9999; } h5, h6 { color: #FFCCCC; } a { color: #FF0033; } form { background-color: #990000; }
-
<head> <link rel="stylesheet" href="/styles.css" type="text/css"> </head> <?php require( "config.php" ); $Quote = new CQuote; if( $Quote->Get( $strQuote ) == 0 ) echo $strQuote; ?> So if this doesn't work then the problem is in my styles.css right?
-
I've done a few php scripts and db's but I have never incorporatated css. I'm trying to set some backgrounds and some font colors and wanted to make sure I am doing this correctly. Do I just put my style sheet reference within the php tags like I have listed below? <?php <link rel="stylesheet" href="/styles.css" type="text/css"> require( "config.php" ); $Quote = new CQuote; if( $Quote->Get( $strQuote ) == 0 ) echo $strQuote; ?>
-
[SOLVED] What does this mean?
sanderphp replied to sanderphp's topic in PHP Installation and Configuration
OMG!!!! I've been fighting this for a week!! hahahah. Thanks for helping me get this fixed. Looks like -
I can create a file called x.php and simply put <?php print("TEST<br>"); ?> in it and that works. However, if I create a file called y.php and put <?php phpinfo() >? in it but that gives me a 500 error. Is this a code error or a php config error? Thanks Running php 5.2.6 on Windows 2003 IIS
-
I just installed PHP 5 on a Windows 2003 IIS6 server and am unable to get php to function correctly. I have gone through several tutorials to try to make this work. In the beginning I used the installer, but it seemed to fail so then I uninstalled and used the zip file and manually added a c:\php5 folder. I also added php.ini to c:\windows and php5ts.dll to c:\windows\system32. And I have double checked to make sure I have PHP listed as a web extension. When I try to run http://localhost/index.php from c:\inetpub\wwwroot\ I get a message that says the website cannot be displayed, most likely causes: The website is under maintenance or the website has a programming error. Where should I look first to find my problem? Thanks
-
I'm trying to run 2 sql statements in one function. Is this where I am supposed to use a join? I haven't ever needed to do run 2 statements before but I'm trying to display the name on the same page. $sql_user_data="SELECT * FROM info WHERE rider_id = '$rider_id' ORDER by date "; $sql_rider_name = "SELECT cyclist FROM riders WHERE id ='$rider_id'"; // this statement actually executes the sql $result = mysql_query($sql_user_data) or die("ERROR! user_data".mysql_error($dataConn)); $result_name = mysql_query($sql_rider_name) or die("ERROR! rider_name".mysql_error($dataConn));
-
finally got it!!!!! I had a typo in the dataConn file!!!! jeez, that is really annoying. Thanks for everyone's help.
-
ERROR! user_data line 513No database selected
-
$result = mysql_query($sql_user_data) or die("ERROR! user_data line 513".mysql_user_data($dataConn)); Fatal error: Call to undefined function mysql_user_data() in /home/sanderan/public_html/php/cycling/info.php on line 513
-
Adding the or die text now gives me this... Fatal error: Call to undefined function mysql_user_data() in /home/sanderan/public_html/php/cycling/info1.php on line 489 //$result = mysql_query($sql_user_data); $result = mysql_query($sql_user_data) or die("ERROR!".mysql_user_data($dataConn));
-
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/sanderan/public_html/php/cycling/info.php on line 530 I will try chaning the Error! to the query name.
-
Is there any chance I'm getting this error because I deleted a row in the table? The code was working and then I used my new delete button to delete a row.
-
Here is the whole page. <? session_start(); # include ("secure.php"); include("dataConn.php"); // include("config.php"); // include("opendb.php"); $pgflow = $_GET[pgflow]; #global $application; if ( $application != "yes" ) { print(" <html> <head> <title>Cycling Stats</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"); // include("config.php"); // include("opendb.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"); // include("config.php"); // include("opendb.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"); // include("config.php"); // include("opendb.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"); // include("config.php"); // include("opendb.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); $result = mysql_query($sql_user_data) or die("ERROR!".mysql_error($dataConn)); //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"); // include("config.php"); // include("opendb.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>Stats</h3></center>"; // this pulls in connection specific information to connect to the database include("dataConn.php"); $rider_id = $_SESSION['login_id']; //connect to database mysql_select_db($database_dataConn, $dataConn); //create sql $sql_user_data="SELECT * FROM info"; // WHERE rider_id = '$rider_id'"; // this statement actually executes the sql $result = mysql_query($sql_user_data); // 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>"); //Create table print("<table border='1' align='center'><tr>"); //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>"); //add edit column header print("<th>Edit"); //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>"); 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='delete'></a></td>"); // 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("</tr>"); } #end while( = mysql_fetch_array()) // finally we close the table print("</table>"); } ?>