Maq
Administrators-
Posts
9,363 -
Joined
-
Last visited
-
Days Won
3
Everything posted by Maq
-
Now I'm confused. UPDATE have to use the format: UPDATE table SET blah = '$blah' INSERT can use both ways ?
-
Well is this file, "site1\elections\index.php"? Is it an include?
-
[SOLVED] Having trouble getting a function to work
Maq replied to N1CK3RS0N's topic in PHP Coding Help
Why don't you return a string... Then you can echo $permissions wherever you want. function permissions() { $perm = "</pre> <table class='\"form_area\"' width='\"100%\"' border='\"0\"' cellpadding='\"0\"' cellspacing='\"10\"'>"; $perm .= check_perms( "../config.php", "config.php", "0777" ); $perm .= check_perms( "../downloads/uploads", "downloads/uploads/", "0777" ); $perm .= check_perms( "../images/uploads", "images/uploads/", "0777" ); $perm .= "</table>";<br><br> return $perm -
The syntax is fine, either way is valid for an UPDATE. Thanks for clearing that up, I thought I remembered people using it that way, but I never have.
-
I didn't think that UPDATE was formatted like that, I though that was for INSERT. Isn't it supposed to be? UPDATE status SET Site_Status = '$Site_Status', Inactive_msg = '$Inactive_msg', Main_Inactive_msg = '$Main_Inactive_msg', NewReleaseMsg = '$NewReleaseMsg' WHERE StatusID='$id' add or die(mysql_error()) after your query executions. You should also put your queries in strings before you execute them so you can echo them out and see what's actually being passed in.
-
You had a backtip rather than a single quote after $id}... $query=("DELETE * FROM `players` WHERE `GameID` = '{$id}'");
-
Ignoring the file extension?challenging one for me!!
Maq replied to divadiva's topic in PHP Coding Help
Wherever you it is being entered just do a trim() and strtolower() on it, along with the all the cleansing functions of course. -
[SOLVED] Having trouble getting a function to work
Maq replied to N1CK3RS0N's topic in PHP Coding Help
You need to echo out the functions function permissions() { echo "</pre> <table class='\"form_area\"' width='\"100%\"' border='\"0\"' cellpadding='\"0\"' cellspacing='\"10\"'>"; echo check_perms( "../config.php", "config.php", "0777" ); echo check_perms( "../downloads/uploads", "downloads/uploads/", "0777" ); echo check_perms( "../images/uploads", "images/uploads/", "0777" ); echo "</table>" -
$_SERVER look at DOCUMENT_ROOT, that might help you.
-
Instead of using this: $result=mysql_query("UPDATE events SET name='$name',date='$date',location='$location',description='$description',image='$image',time='$time',detail='$detail',site='$site',phone='$phone',image='$image' WHERE id='$id'"); Why don't you put the sql statement in a string, echo it out and use mysql_errors() $sql = "UPDATE events SET name='$name',date='$date',location='$location',description='$description',image='$image',time='$time',detail='$detail',site='$site',phone='$phone',image='$image' WHERE id='$id'"; echo $sql; myql_query($sql) or die(mysql_error());
-
[SOLVED] WAMP server Problem and Correct way to install PHP and MySQL???
Maq replied to sashi34u's topic in MySQL Help
If you have more trouble you may have more success on this forum, as it relates to your question better. There are child boards (linux/windows) for mysql, apache and php installations. PHP Installation -
I assume username is unique... so use that since you have it. //clean it first, may want to use additional cleaning functions. $user_name = mysql_real_escape_string($_POST['userid']); $sql = "UPDATE taken_exam = 0 WHERE username = '$user_name'";
-
How about show us line 242 and some of the surrounding code?
-
[SOLVED] WAMP server Problem and Correct way to install PHP and MySQL???
Maq replied to sashi34u's topic in MySQL Help
There are plenty of tutorials online to guide you through, even on this forum. You have to install PHP on your server to use PHP. You can connect to any database on any server (given the credentials) with PHP. If I were you I would just install WAMP, but if you want to install each component individually: -Get Apache working -install PHP -install MySQL That's what I would do maybe someone else has a better way. Good luck. -
okay... so instead of using SESSION use $_POST['user_field'];
-
I don't understand this: if ($num_rows > 4){ for ($counter=10; $num_rows > 4; $counter++){ I mean I understand it but I don't get the point of it. How is $num_rows being assigned? Cause if it's running some kind of infinite loop it will delete everything since you have MAX(date). Every time you delete a column the next MAX(date) will be deleted. Add the echo statement in here: $todelete = "DELETE FROM newitems WHERE date = '{$delete['date']}'"; echo $sql . " ";
-
Like uniflare and I had already mentioned, at the top of your script put: ini_set ("display_errors", "1"); error_reporting(E_ALL); The only thing that you have on is mysql errors.
-
[SOLVED] WAMP server Problem and Correct way to install PHP and MySQL???
Maq replied to sashi34u's topic in MySQL Help
I'm not sure what exactly you mean... WAMP comes with all of this... WAMP - Apache, MySQL, PHP on Windows -
Use both of our suggestions. Have a submit button to update the DB but you should have an extra field like "taken_exam". 1 means the user has taken the exam and 0 means they have not. I'm not sure where you get the userid from, but assuming it's in the session: if(isset($_POST['update'])) { //don't need LIMIT 1 as the ID should be unique (auto-incremented) $sql = "UPDATE taken_exam = 0 WHERE user_id = '{$_SESSION['userid']}'"; mysql_query($sql) or die(mysql_error()); echo $_SESSION['userid'] . " is able to retake the exam!"; } ?> </pre> <form method="POST" action="<?php%20echo%20%24_SERVER%5B'PHP_SELF'%5D;%20?>"> </form> <br><br><br><b
-
Hey there, Ok tried out this tutorial, customized it to my db...and applied it to my page, but its not displaying any news articles at all. Im not getting any errors from the script, my page is just coming up blank.. You did that tutorial in 15 minutes, man that's quick. Do you have error reporting turned on? Do you echo out variables and sql errors? Can we see your code?
-
You need single quotes around the date comparator. That's the whole point of the curly brackets... $todelete = "DELETE FROM newitems WHERE date = '{$delete['date']}'";
-
And the reason why is because $delete = mysql_fetch_assoc($dateresult); returns an array ($delete) with the results. $delete['date'] is encapsulated with { } so that it allows single quotes inside single quotes.
-
Ignoring the file extension?challenging one for me!!
Maq replied to divadiva's topic in PHP Coding Help
I don't think there's a way, unless they are all lower case extensions in the directory then you could just do strtolower(). The best but longest way would be changing the names to be consistent in the DB and server but if you can't touch it then we have to go a different route. You have to: -take the extension by exploding it by the dot. -do a strtoupper and string to lower on it -check if either the lower case or upper case exists in the directory -which ever one exists, display it. Example (from another forum): if(file_exists($housepicJPG)) { $thumbpiccode=""; $thumbJPG="(Found it)"; } elseif (file_exists($housepicJPG2)) { $thumbpiccode=""; $thumbJPG="(Found it)"; } -
In Eclipse, (and I'm sure in any popular IDE's) you can import your own style or use the default one to format the code for you. preferences >> java >> code style >> formatter i think? I think the hot key is ctl+r, but I'm not sure, it will re-format all the code nice and neat for you.
-
haku is right, you should have some sort of flag to tell whether that id has taken the test instead of changing their userid, cause then you can't keep track of them. You mean something like this: if(isset($_POST['update'])) { $sql = "UPDATE `TableName` SET `name` = 'Joe Smith', `username` = 'joe.smith@email.com', `pwid` = 'JS101', `user_id` = '562' WHERE `user_id` = 561 LIMIT 1"; mysql_query($sql) or die(mysql_error()); echo "Succesfully updated!"; } ?> </pre> <form method="POST" action="<?php%20echo%20%24_SERVER%5B'PHP_SELF'%5D;%20?>"> </form> <b I don't know how you're getting the userid but this is how you would go about creating a button that would execute the query when it is pressed.