kenrbnsn
Staff Alumni-
Posts
8,234 -
Joined
-
Last visited
Everything posted by kenrbnsn
-
Do you want to style the link to look like a button? If so see http://webdesign.about.com/od/css/a/aa041904.htm Ken
-
What do you mean by " that doesn't seem to work so far." What is happening or not happening? Ken
-
Error in my php. (unexpected T_STRING, expecting T_VARIABLE or '$' )
kenrbnsn replied to auzz's topic in PHP Coding Help
These two lines <?php mysql_connect($mysql['host'],$ mysql['username'],$mysql['password']); ?> should be written as one line <?php mysql_connect($mysql['host'],$mysql['username'],$mysql['password']); ?> Ken -
Error in my php. (unexpected T_STRING, expecting T_VARIABLE or '$' )
kenrbnsn replied to auzz's topic in PHP Coding Help
We need to see more of your code. Ken -
This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=331038.0
-
You're problem stem from the fact that in some fonts a "1" looks like a "l" (small el). In your form you have the name "i1Text", but you test form $_POST['ilText'] Either change the 1 to a "l" or change the "l" to a 1 Ken
-
This topic has been moved to PHP Freelancing. http://www.phpfreaks.com/forums/index.php?topic=331097.0
-
As for the mysql error, that is tell you that your username and/or password is incorrect or something else is wrong in your config.php. The other error, the semi-colon is missing from the end of <?php include 'includes/config.php' ?> Ken
-
The Unix timestamp is the number of seconds elapsed since January 1, 1970. The time function returns that number for "right now". I assume that $deadlinedate is the number of seconds for a date in the future. To get the number of days between those two dates, you use the formula you have: 60 = number of seconds/minute, 60 = number of minutes/hour, 24 = number of hours/day. Or you could just divide by 86400 -- the number of seconds in a day. To get the number of months is harder, since the number of days/month is variable. You can get an approximate value by: <?php $months = floor($days/30); ?> or <?php $months = floor($days/31); ?> Ken
-
I would change your first script to <?php include 'includes/config.php'; $delete_sql ="SELECT sno,cname, sname FROM student ORDER BY sno DESC"; $delete_query = mysql_query($delete_sql) or die("Problem with the query: $delete_sql<br>" . mysql_error()); $tmp = array(); while ($rsDelete = mysql_fetch_assoc($delete_query)) { $tmp[] = "<p><a href='deletecomfirm.php?sno={$rsDelete['sno']}'>{$rsDelete['cname']} by {$rsDelete['fname']}</a></p>"; } ?> <html> <head> </head> <body> <p> select student to delete </p> <?php echo implode("\n",$tmp) . "\n"; ?> </body> </html> In your Confirmation page, you had some misspellings and left out some code: <?php session_start(); include 'includes/config.php' $_SESSION['deletestudent']['sno'] =$_GET['snp']; $confirm_sql = "SELECT * FROM student WHERE sno='{$_GET['sno']}'"; $rs = mysql_query($confirm_sql) or die("Problem with the query: $confirm_sql<br>" . mysql_error()); // you left out this line $rsConfirm = mysql_fetch_assoc($rs); //you left out this line ?> <html> <head> </head> <body> <p> Confirm student to delete:</p> <?php echo "<p>{$rsConfirm['cname']}</p>\n"; echo "<p>{$rsConfirm['sname']}</p>\n"; echo "<p>{$rsConfirm['fname']}</p>\n"; ?> <p><a href="deleteselect.php"> Oops, made a mistake</a></p> <p><a href="deletestudent.php"> Delete this student</a></p> <body> </html> The Delete page had a few errors: <?php session_start(); include 'includes/config.php' $delete_sql = "DELETE FROM student WHERE sno = '{$_SESSION['deletestudent']['sno']}'"; $delete_query = mysql_query($delete_sql) or die("Problem with the query: $delete_sql<br>" . mysql_error()); unset($_SESSION['deletestudent']; ?> <html> <body> <p> Student has been deleted </p> </body> <html> Ken
-
Please help, trying to input data into DB driving me crazy.
kenrbnsn replied to VinceGledhill's topic in PHP Coding Help
If you're commenting out the includes, that's why you get a mysql error. The includes hold your connection statements. Ken -
mysql_fetch_array() expects parameter 1 to be resource error =P
kenrbnsn replied to imod3rn's topic in PHP Coding Help
That error means you have a syntax error in your query. Write that single line as multiple lines so you can find out what the error is: <?php $q = "select username,password,email,desc,keys,logo,webclient,forums,hiscores,chatbox,staff,newstitle,newsimage,news,op1,op2,op3 from users where username='{$_SESSION['username']}'"; $rs = mysql_query($q) or die("Problem with the query: $q<br>" . mysql_error()); $dnn = mysql_fetch_assoc($rs); ?> Ken -
Please help, trying to input data into DB driving me crazy.
kenrbnsn replied to VinceGledhill's topic in PHP Coding Help
Why are you commenting out the includes? Ken -
You're not even getting to <?php if (isset($sql) && !empty($sql)) { mysql_query($sql); } ?> Since you're using the header function to go to another page before that point is reached. Ken
-
Please put your code between tags in the future. That code is fine -- i.e. no syntax errors, but out of context it means nothing to us. Please post a better explanation and more code. Ken
-
No host in their right mind should be running PHP4 anymore. Either convince your client to move to another host -- one that is running PHP5, or get your client to have his host upgrade to PHP5. Ken
-
How to create a text file while runnning PHP program from browser?
kenrbnsn replied to reksss's topic in PHP Coding Help
Try writing the file the directory "/tmp". Everyone should have write permissions to that directory. After the file is created do an "ls -l" on the file and see who the owner is. It's probably not your userid. That is probably where you're getting confused. Ken -
But, those conventions are not enforced in any browser or code that I know of. You can use GET to set data to be updated, etc and it will work as long as you code your script to use the data that way. Ken
-
Also, there is usually a limit to how much data can be sent using GET. Ken
-
PHP/HTML Form sent through E-mail Problem
kenrbnsn replied to Bloodmorphed's topic in PHP Coding Help
Give the submit button a name and check to see if the form was submitted before sending the email: <form method="post" action="viewpage.php?page_id=5"> Email: <input name="email" type="text"><br> Message:<br> <textarea name="message" rows="15" cols="40"></textarea><br> <input type="submit" name="submit"> </form> <?php if (isset($_POST['submit'])) { $to = "hidden for privacy"; $subject = "LoL Recruitment"; $email = $_REQUEST['email'] ; $message = $_REQUEST['message'] ; $headers = "From: $email"; $sent = mail($to, $subject, $message, $headers) ; if($sent) {print "Your mail was sent successfully"; } else {print "We encountered an error sending your mail"; } } ?> Ken -
The preg_match function in your function is checking to see whether the email is valid and is returning "true" or "false" accordingly. Ken
-
The mysql fetch functions return one row at a time, to see all the rows you need to put it into a loop: <?php $query = "SELECT displayname FROM login WHERE rank = 1"; $rs = mysql_query($query); while ($row = mysql_fetch_assoc($rs)) { echo $row['displayname'] . '<br>'; } ?> Ken
-
The function mysql_fetch_array returns an array containing two entries for each field. You probably want to use the function mysql_fetch_assoc instead. Ken