
per1os
New Members-
Posts
3,095 -
Joined
-
Last visited
Everything posted by per1os
-
Another way of doing it, depending on how many pages you plan to have is by making the rank/order column go by 10's or 100's for each entry. So say you insert a page with a rank of 10. If you want to insert a page before it you can make that page 5 which in return leaves it open to have another page inserted before that or after that etc. 10 for a smal page system or 100 for a larger scale one. Just another option/idea.
-
I wouldn't use the id_main for ordering, create a new column called order or rank to order the data by (As Thorpe somewhat suggested) From there you can easily change that field with a looped update statement to do what you want. But the update statement has to start with the last rank and go to the inserted rank to work.
-
$connection = mysql_connect($hostname, $user, $pass) or die ("Unable to connect!"); mysql_select_db($database) or die ("UNABLE TO SELECT DATABASE"); Just an FYI the $_POST bit only applies to variables that have been posted, it would not apply to "$hostname" etc. Incase you did modify those to that also. Post the updated code.
-
Wrong code, we need the php file where cart.php is suppose to be included. That is the problem. For some reason the phpsession id is being appended to that.
-
www.php.net/isset It checks if a variable has been set or not.
-
Maybe posting the part that is going wrong will get you some help?
-
http://www.askdavetaylor.com/how_can_i_add_a_google_search_box_to_my_web_site.html http://news.softpedia.com/news/Add-Google-Search-To-Your-Site-40509.shtml
-
Remove the spaces from [ code] tags, I forgot to specify that.
-
www.php.net/setcookie The way you called setcookie with only a name/value will work for localhost. But for production servers you need it to have varname, value, timetoexpire, path, domain Thats your problem.
-
Why do you want it at a specific spot between 2 and 3. You do know that with the primary key you can only have one, 2 or one three. Your logic does not make any sense at all bud. You basically just want to overwrite the data, for that just use UPDATE keyword, no need to insert. Unless I am not understanding correctly.
-
Paste it here. Remember to use the [ code ] and [/ code ] tags But as far as why it works on the remote server and not your local, most likely the cookies are not being accepted. Since you are working with localhost I would suggest reading this article on how to properly set cookies for localhost. http://www.aeonity.com/frost/php-setcookie-localhost-apache But remember that you do not want to use that code on production as it will not work properly.
-
Auto_increment fields should be left null and not assigned a value. <?php $name = $_GET['name']; $ID_CAT = $_GET['ID_CAT']; $navi = $_GET['navi']; $body = $_GET['body']; mysql_query("INSERT INTO pages (name, ID_CAT, body) VALUES('$name', '$ID_CAT', '$body' ) ") or die(mysql_error()); $new_id = mysql_insert_id(); // grabs the new id assigned to what was just entered in ?> That will take care of your duplication problem. As the code you have is prone to fail as it is not being looped to modify every id in the table (which you do not want it to do)
-
www.php.net/chmod
-
Help with my form - passing array to another php script
per1os replied to chrisneedham's topic in PHP Coding Help
www.php.net/serialize www.php.net/unserialize And or www.php.net/session -
You will need to learn how to store data properly, retrieve data and how to build a table structure. MySQL is quite a bit different and sometimes hard for people to grasp the concept. Your main focus will be on SELECT statements, INSERT statements and UPDATE statements. You will also need to look into PHP While loops for retrieving data along with arrays. Along with mysql_connect; mysql_query; mysql_fetch_array; via PHP.net. But the key is to keep everything in Third Normal Form (3NF) google will have a bunch of articles/pages on that. Table structure and setup is important to keep a site running fast, clean and efficient. On another note it can be done with files, like stated above it is a pain in the ass to work with them because you have to open read them parse them append them and re-write them all in while that is happening no one else can work with that file. Which is why MySQL is preferred. Especially given that it is 1,000x faster than a file database could ever be, with searching sorting selecting etc.
-
$query = 'SELECT * FROM products WHERE id = '.$id.' AND (boy = '.$boyGirl.' OR girl = '.$boyGirl.')'; You need parenthesis's around the "OR" statement
-
$_SESSION would work, and no need to serialize it as thorpe said. Basically this would work: <?php include('class.def.php'); // has to be before session_Start session_start(); if (!isset($_SESSION['class_name'])) { $_SESSION['class_name'] = new class_name(); }else { $x=1; } $class &= $_SESSION['class_name']; // dunno if keeping the reference works but yea if ($x==1) echo $class->get_var('test'); $class->set_var('test', 'Testing'); $_SESSION['class_name'] = $class; ?>
-
surround it in < pre> and </ pre> tags.
-
Ok let's hold the horses here. Why not use an auto_increment field for the table via MySQL? You do know that is an option right? <?php $name = $_GET['name']; $ID_CAT = $_GET['ID_CAT']; $navi = $_GET['navi']; $body = $_GET['body']; $ID_MAIN = $navi + 1; $Update = ">=$ID_MAIN"; // Note that COLUMNS CANNOT HAVE single quotes around them, they need backticks or NOTHING (`) // Also note that '+1' is taken literally. (ID_MAIN+1) would be the correct syntax. // Below is proper syntax. mysql_query("UPDATE `pages` SET `ID_MAIN`= (ID_MAIN+1) WHERE `ID_MAIN` $Update") or die(mysql_error()); mysql_query("INSERT INTO pages (name, ID_CAT, ID_MAIN, body) VALUES('$name', '$ID_CAT', '$ID_MAIN', '$body' ) ") or die(mysql_error()); ?> Now it would probably be better to use the auto_increment field on your main ID field instead of the above, but to each his own. Give your logic is correct/what you need the above should produce the desired results.
-
//create and issue the first query $add_topic = "INSERT INTO forum_topics (topic_title, topic_create_" . "time, topic_owner) VALUES ('".$_POST["topic_title"] ."',now(), '".$_POST[" topic_owner"]."')"; $add_topic_res = mysqli_query($mysqli, $add_topic_sql) I don't know why you were using *'s but there was another star by topic_title, removed it try that.
-
$view = isset($_GET['view']) ? $_GET['view'] : "main"; No need for the $view = "main" just "main" will do.
-
Yea, it will die unless you use sessions to store the class in =)
-
I think your SOL, your server blocked the remote reading of files. If you are on a shared server, chances are you cannot get them to change that either and init_set will not work. BTW, the above returns 1 for me, but I also know my server allows me to read remote files.
-
'".$_POST[" topic_owner"]."')"; // removed the * //create and issue the first query $add_topic = "INSERT INTO forum_topics (topic_title, topic_create_" . "time, topic_owner) VALUES ("*.$_POST["topic_title"] ."',now(), '".$_POST[" topic_owner"]."')"; $add_topic_res = mysqli_query($mysqli, $add_topic_sql) Try that.