Jump to content

wildteen88

Staff Alumni
  • Posts

    10,480
  • Joined

  • Last visited

    Never

Everything posted by wildteen88

  1. Use function_exists for procedual functions. Or for methods you can use method_exists
  2. I think you'll have to use COM to send queries to your .mdb database. Some example code can be found here for using COM with an MS Access Database.
  3. You need to check that $_GET['cat'] exists first before using it if(isset($_GET['cat']) && is_numeric($_GET['cat'])) { $cat = (int) $_GET['cat']; $get_items = "SELECT * FROM poj_products WHERE cat='$cat'"; $get_items = mysql_query($get_items); if($get_items){ $item_row = mysql_fetch_assoc($get_items); echo '<a href="'.$sitelocation.$item_row['url'].'?item_desc='.$item_row['id'].'>view details/order</a>'; }else{ die("Unable to connect to database.".mysql_error()); } }
  4. You forgot to close your if statement (started on line 30). You need to place a } after line 55
  5. By this do you mean you get a page similar to the following. If thats correct then you have Apache and PHP configured correctly. Make sure you save your code in .php files. In most setups by default PHP will not be parsed in .html files. However you can place HTML within .php files. You can configure Apache so PHP is parsed within .html files. You should also be going to http://localhost to run your .php files and make sure you're saving your files in Apaches htdocs folder.
  6. Reading the manual on Variable Scope will help you more.
  7. If you're running the sample PHP code from W3CShool locally. Then all you need to do is open your plain text editor and paste the code into a new file. Save the file as filename.php (change filename to whatever you want to call your file) and place it MAMP's htdocs folder. Now open your browser and go to http://localhost to run your .php files. EDIT: You wont be able to place PHP code into .html files unless your Server is confiigured to do so. By default only .php files can contain PHP code.
  8. Look at mjdamato's post above. That is the correct syntax to use.
  9. You cannot assign an echo to a variable. $post_title = echo $rev_title; $post_author = echo "7"; $post_content = echo $all; $post_type = echo "post"; $post_status = echo "publish"; $comment_status = echo "publish"; $post_date_gmt = echo $gmtdate; $post_date = echo $date; $post_category = echo "1"; The correct syntax for defining variables is $myVariable = 'somevalue'; // or $myVariable = $someOtherVariable You also do not need to keep connecting to/closing mysql everytime you perform a MySQL query. You should only connect once at the start of the script and close then connection at the end of the script (however PHP will automaitcally close the connection once the script has been processed).
  10. Lines that start with // or a block of code contained within /* and */ are commented out However blocks of code looking like the following /** * something * @bar whatever * @foo somethinge here * etc */ Is used for phpDocumenter. This allows devlopers to easily create documentation for their code.
  11. If you're wanting to use site.com/home instead of site.com/index.php or site.com/adverstise instead of site.com/advertise.php etc Then you'd need to use only 1 single require rule RewriteRule ^(.*+)$ /$1.php [L,QSA][L] You will have to modify your script so it generates the links with the tutorial title contained within in it. Example code echo '<a href="'.$row['tutorial_id'].'-'.str_replace(' ', '_', strtolower($row['tutorial_title'])).'">'.$row['tutorial_title'].'</a>'; That code will produce a link like site.com/123-how_to_install_php Now for your rewriteRule you can use RewriteRule ^tutorial/([0-9]+)$ view_tutorial.php?tutorial_id=$1
  12. I'm asumming D:\STG\ is your sites document root folder? In which you can use require_once ($_SERVER['DOCUMENT_ROOT'].'/settings/config.inc.php'); Or you can use ../ to go up a level in the directory tree require_once ('../settings/config.inc.php');
  13. You need to be restarting Apache when making any changes to the php.ini Also you should leave the php.ini (and any files that come with PHP) in C:/php and add PHP to the PATH Environment Variable. You should enable a setting called display_startup_errors too within the php.ini. With this enabled PHP errors should pop up while Apache is starting up.
  14. Isnt that just basic SQL? SELECT * FROM users LIMIT 10 The above translated into Active Record $query = $this->db->get('users_table', 10);
  15. I guess you have used the PHP installer. In this case the installer only installs the extensions you choose in the setup wizard. To enable extensions you need to reconfigure your PHP installation from the Windows Add /Remove Programs utility Its the new MySQL connector (client library called mysqlnd) that is built in to php5.3. The mysql or mysqli extensions still need to be enabled to use PHP with MySQL.
  16. FF3.5 is alot quicker for me on Win7. Loads in a few secounds. Although I did do a clean install.
  17. Seems the link you're using is not quite right. You should setup you links like so <a href="filename.php?date=YOUR_DATE_ID_HERE Now in your code you'd use the variabled called $_GET['date'] to retrive the requested date id.
  18. Make sure you're saving your code within .php files. You should also be saving these files within WAMP's www folder (C:/wamp/www). To run your php files you need to be going to http://localhost Do not try to open your .php files from windows explorer (Rigth click > Open With) or by going to File > Open in your browser. This is not the same as going to http://localhost Also ensure you are using full PHP tags (<?php ?>) and not short tags (<? ?> or <?= ?>). By default short tags are disabled. To enable short tags left click wamp tray icon and select PHP > PHP Settings > short open tag.
  19. min expects an array. Change this line $result = min($strings) ; to $result = min(explode(',', $strings)) ;
  20. You need to escape any double quotes within your string, like so print ("<td align=\"left\" valign=\"top\">"); If you don't escape your quotes PHP will end your string prematurely and thus you'll get the error you're retrieving. Or start your string with single quotes print ('<td align="left" valign="top">'); Also there's no need to echo each line separately. echo/print can span multiple lines, like so echo '<table> <tr> <td>smooth</td> </tr> <tr> <td>lala</td> <td align="left" valign="top"> <h2>Description</h2>'. stripslashes($video['description']).' </td> </tr> </table>';
  21. Having empty if statements is pointless. You're better of doing if (isset($ibforums->input["id"], $ibforums->input["num"])) { if(!is_numeric($ibforums->input["id"]) && !is_numeric($ibforums->input["num"])) { die("Your ip has been saved in the Database and will be reported to your ISP."); } $id = $ibforums->input["id"]; $num = $ibforums->input["num"]; }
  22. The only to do this in html is to use Server Side Includes if your host uses Apache. There is no other way to include files if you host does not support PHP, SSI or any other server side language.
  23. You should use then following when placing any data from the user $name = mysql_real_escape_string($_POST['name']); $query = "SELECT * FROM $usertable WHERE name = '$name'"; There is a time limit for editing posts. I think it is something like 10mins or so. However a moderator has edited your post for you and removed your database credentials.
  24. Your using the incorrect syntax here: print "".$row{$yourfield}." ".$row{$yourfield2}." ".$row{$yourfield3}." ".$row{$yourfield4}."<br>"; it should be print $row['yourfield']." ".$row['yourfield2']." ".$row['yourfield3']." ".$row['yourfield4']."<br>"; You should edit your post and remove the hostname/username/password for mysql from your code.
  25. Thats code snippet makes no sense. Your secound echo will not work as its invalid syntax. Are you wanting to call that function when the user clicks on the div? This is not possible with PHP, PHP is unable to respond to events happening on the page. The only way you can do this is by using AJAX (using the xmlhttprequest object in javascript). You need to be more clear on what you're wanting to do.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.