-
Posts
3,404 -
Joined
-
Last visited
-
Days Won
55
Everything posted by Ch0cu3r
-
Yes. You use the mysql username/password for the server you are connecting to.
-
You need to first insert the new category into the categories table. You then use mysql_insert_id (provided the id column in the category table is auto increment) to get the id of the new category. When you insert the book details into the book table you insert the category id into the category column. The cat_name column in the category table should also be set to unique to prevent duplicate entries from occurring.
-
You cant just dump a PHP variable into raw HTML. You need to wrap the variable in PHP tags and then echo it <p><a href='pdfAct.php?dataInicio=<?php echo $dataInicio; ?>&dataFim=<?php echo $dataFim ?>'>Imprimir estas atividades</a></p>
-
Have you got columns actually named as prev, pres, price and id within that table? Could you post your table structure?
-
Either change c.cat_name to c.cat_name AS category within your query OR change $row['category'] to $row['cat_name'] in your PHP code.
-
You need to use a join to get the category name. Example query #Query SELECT b.id, b.title, b.author, b.isbn, # return the id, title, author and isbn columns from the book table c.cat_name # return the cat_name column from the category table FROM book AS b INNER JOIN category AS c ON b.category = c.id # join the row where the category column in the books table matches the id column in the category table #Result +----+-----------------+-----------+----------+----------+ | id | title | author | isbn | cat_name | +----+-----------------+-----------+----------+----------+ | 1 | Treasure Chest | Jim Jones | 14252637 | Horror | | 2 | Pirates Boat | Sue Smith | 88447737 | Kids | | 3 | Adventure Land | Harry Jo | 191873 | Fiction | | 4 | Winter Week | Sam Dill | 99337 | Fiction | +----+-----------------+-----------+----------+----------+ The foreign key constrain only applies to insert, update or delete queries.
-
Yup I got some. Weirdly if you use any other bbcode after the closing nobbc tag it does not have an effect [ nobbc ][ m ]printf[ / m ][ /nobbc ] [ b][/ b] = printf
-
Basic example using the example code from curl_init <?php if(isset($_POST['send_update'])) { // create a new cURL resource $ch = curl_init(); // set URL and other appropriate options curl_setopt($ch, CURLOPT_URL, "http://microprocessor.ddns.net/?update=1"); curl_setopt($ch, CURLOPT_HEADER, 0); // grab URL and pass it to the browser curl_exec($ch); // close cURL resource, and free up system resources curl_close($ch); } ?> <form action="" method="post"> <input type="submit" name="send_update" value="Update Microprocessor Button" /> </form>
-
Rather than the button submit to directly to microprocessor ip address instead make the button submit to your site. But then use curl to send the request to your microprocessor
-
When you click the pages links the post data which contains the keywords will not be remembered. You could use session for remembering the keywords here are the changes required for this to work Change these lines <?php $keywords=''; $display_search_results=''; if(isset($_POST['search_submitted'])) { $keywords=$_POST['keywords']; To the following <?php // start session session_start(); // add submitted keywords to the keywords session variable if(isset($_POST['search_submitted'])) { $_SESSION['keywords'] = $_POST['keywords']; } // retrieve the keywords from the session $keywords = isset($_SESSION['keywords']) ? $_SESSION['keywords'] : ''; // only display the page links if $keywords is not empty if(!empty($keywords)) { No matter what page link is clicked the entered keywords will be remembered. When you submit the form with new keywords the session will be updated with the new values.
-
update php mysql using fancybox not working please help
Ch0cu3r replied to pips's topic in PHP Coding Help
Cool -
You echo it as Barand has told you to do in posts #8, #10 and #12 all of you which you have ignored!
-
So did you comment out the header() lines in login.php? I told you to do this to prevent it from redirecting so we can debug the script.
-
You would get a better results if you goggled that term
-
The login script is not setting the $_SESSION['loggedIn'] session variable. To solve the notice use isset before checking the value. Example if(isset($_SESSION['loggedIn']) && $_SESSION['loggedIn'] != true) { ... } else if(isset($_SESSION['loggedIn']) && $_SESSION['loggedIn'] == true) { In your login script commend out the lines that use header(). Does the login script display a blank page or any messages now?
-
If were to use a dropdown menu you need to output each generated sequence within the <option></option> tags. Example assuming GenStats() generates a new stat each time it is called // if a stat has been submitted if(isset($_POST['stat'])) { echo "The stat to insert into the database will be: " . $_POST['stat']; // your code for inserting stat to database here } // generate the stats $Stat_Results = array(); for($i=1; $i<=$Sets; $i++) { $Stat_Results[] = GenStats($SpecId, $min, $Quantity, $Type); } // output stats witin a HTML dropdown menu echo ' <form action="" method="post"> <select name="stat"> <option>'. implode('</option><option>', $Stat_Results). '</option> </select> <input type="submit" value="Insert Selected Stat" /> </form>';
-
Code is working fine. The problem is these lines are in the wrong place! if($row['user_level'] == 1) { $_SESSION['user_level'] == 1; header("Location: admin.php"); exit(); } else if($row['user_level'] == -1) { $_SESSION['user_level'] == -1; $_SESSION['username'] == trim($_POST['username']); header("Location: banned.php"); exit(); } if($_SESSION['loggedIn'] == true) { header("index.php"); } if($_SESSION['loggedIn'] == 1 && $_SESSION['user_level'] == -1) { $_SESSION['user_level'] == -1; $_SESSION['username'] == trim($_POST['username']); header("Location: banned.php"); } $_SESSION['loggedIn'] == 1; $_SESSION['user_level'] == 1; $_SESSION['username'] == trim($_POST['username']); header("Location: index.php"); exit(); They should of replaced these lines // output contents of $row printf('<pre>%s</pre>', print_r($row, 1)); I merged the two topics because are you are in the process of converting your code over to mysqli. There is was no need to start a new topic for every error you get in the process.
-
My bad. Try // execute query $result = $con->query("SELECT * FROM $tbl_name WHERE username='$username' AND password='$password'"); // check to make sure query did execute. if($result) { // query did return result if($result->num_rows > 0 ) { // get result from query $row = $result->fetch_array(); // output contents of $row printf('<pre>%s</pre>', print_r($row, 1)); } // query did not return result else { echo 'Invalid Username/Password'; } } // problem with query trigger an error else { trigger_error('Login Query failed: ' . $con->error); }
-
You need to be connected to mysql before you can start to use queries. To fetch the results from the query call the fetch_array method on $count variable not $tbl_name $tbl_name = "x_users"; // connect to mysql $con = new mysqli("$server", "$username", "$password", "$db_name"); if($con->connect_error) { echo 'There was an error while connecting to the server or database, please check your configuration.'; } // execute query $count= $con->query("SELECT * FROM $tbl_name WHERE username='$username' AND password='$password'"); // check to make sure query did execute. If it did not then trigger error use mysqli::error to see why it failed if(!$count) { trigger_error('Query error: ', $con->error); } else { // get result from query $row = $count->fetch_array(); // output contents of $row printf('<pre>%s</pre>', print_r($row, 1)); } $count is rather ambiguous. I fell naming it as $result to be a better name
-
I have merged your two topics. What is $table_name and $count? Can you post more code?
-
The QSA flag will merge the two query strings. The rewritten url will become https://example.com/?page=page1&controller=controller1&var=1&var2=foo If you did not apply the QSA flag the var=1&var2=foo query string will be ignored Wrap it in nobbc tags or click the Special Tags button and select no parse
-
You can assign the table name to a variable or hard code it. If you are getting an Access Denied error then there is an issue with your database credentials for connecting to mysql
-
ORDER BY count should be ORDER BY countCountry
-
By not reading the documentation for mysqli mysqli functions are completely different to the mysql functions. The only similarities is the name of the function. Everything else is completely different! The only way you are going to learn the differences is to read the documentation. I will say it again read the documentation to learn the differences. http://php.net/mysqli < link to the documentation.
-
Differentiate between products for E-commerce site from database
Ch0cu3r replied to louiscb's topic in PHP Coding Help
You need to output a separate form foreach product which contains the buy button and product id in a hidden input field. When you click the buy button next to the product it will be the products id being submitted to your receiving script. This is how you'll identify which product the user chose Example code while ($row = mysql_fetch_array($query)) { $id = $row['id']; $name = $row{'Name'}; $price = $row{'Price'}; $desc = $row{'Description'}; echo $id; echo $name; echo $price; echo $desc; // out put buy button for product // product is in hidden input field echo ' <form action="checkout.php" method="post"> <input type="hidden" name="productId" value="'.$id.'" /> Qty: <input type="input" name="quantity" /> <input type="submit" name="buy" value="Buy" /> </form>'; }