Jump to content

Search the Community

Showing results for tags 'php'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

  1. I'm generating a PNG image (transparent background) of some text on the fly. The text will be whatever the user typed, using English 111 Vivace BT (a script) as the font. The image will always be 100px tall by 200px wide, regardless of how large the text is. I want the text to be horizontally centered and positioned as close to the top of the image as possible. This all works generally fine except that imagettfbbox() appears to be returning incorrect points for the bounding box, it thinks the text is taller than it really is, and therefore some blank space is appearing at the top of the image, before the text. Please see the attached example png, I drew some red guidelines to demonstrate the problem. The left side shows a guideline that is 38px tall, which is what imagettfbbox() thinks is the height of the text. The right side shows a line measured against the text itself, and it's only 26px tall. is there a more accurate way to get the box?
  2. Hello, I am making an eCommerce-solution at this URL: http://skaugsport.effektivhjemmeside.no I am using Wordpress 3.4.2, the "Elegant Themes"-theme Boutique 2.5. and the shopping cart plugin from http://www.getshopped.com, WP e-Commerce 3.8.8.5. Here is my problem: The store has about 110 product categories if you add up all the main and sub categories. When i am using the menu-option in Wordpress admin-panel i am not able to save my menu when it exceeds about 60 menu items. The saving process fails, and mye menu is set back to how i looked last time i was able to save. I have narrowed it down to beeing about 58–64 menu items that is the limit. I haved talked to my ISP about solving this problem by setting a longer allowed save time before the servers cancel the action (this is a field i know nothing about, but i googled up this as a probable solution). The answer was that this could not be done/allowed due to safty issues. The tip they gave me thoug was to hardcode a PHP-code that wrote out all my product categories directly for me and not use the Wordpress menu system. I was wondering if anyone can help me out, as i do not know how to code this in PHP. I need the PHP-code that outputs mye product categories and subcategories with names and URLs so that i can make a menu of them, and style it using CSS. The product categories are not the "same" as the Wordpress default post categories. The product categories are an addition you get by using the WP e-Commerce plugin, so the code would need to target thoose categories, not Wordpress default. Anyone able to help me out? Anders
  3. I have installed a PHP/AJAX "instant search" (like Google) on our website. The results should appear immediately below the input box, but they appear way up and to the left. Using a document.getelementByID(name).style.position along with top and left have no effect on the result box location. Here's the details: Here's the problem in action: Enter an a into the search box at http://www.woofwoofwoof.org/is01/search.htm and you'll see the results up and to the left rather than just below the input box. The original search code on the w3school's site (located at http://www.w3schools..._livesearch.asp ) has worked well until I inserted into our web site; can anyone spot the problem? Here's our HTML-- I believe the problem lies in the relevant CSS, javascript or the inputbox lines. I've tried to mark them in green and surrounded them with a title and lots of equal signs. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Search page - SupportWorks</title> <meta name="description" content="Directory of resources in the Charlotte, NC region for nonprofit non-poltical support groups"> <meta name="keywords" content="SupportWorks search page, Charlotte NC, support groups"> <meta name="generator" content="WYSIWYG [url="http://www.php-forum.com/phpforum/viewtopic.php?f=26&t=21108#"]Web Builder[/url] 8 - http://www.wysiwygwebbuilder.com"> <style type="text/css"> div#container { width: 994px; position: relative; margin-top: 0px; margin-left: auto; margin-right: auto; text-align: left; } body { text-align: center; margin: 0; background-color: #9999CC; color: #000000; } </style> <style type="text/css"> a { color: #282828; text-decoration: none; } a:visited { color: #282828; } a:active { color: #282828; } a:hover { color: #FF0000; text-decoration: none; } </style> <style type="text/css"> #Line1 { color: #3300CC; background-color: #3300CC; border-width: 0px; } #wb_Shape8 a img { position: absolute; } #wb_Shape8 span { position: absolute; } #wb_Shape8 a .hover { visibility: hidden; } #wb_Shape8 a:hover .hover { visibility: visible; } #wb_Shape8 a:hover span { visibility: hidden; } #wb_Shape9 a img { position: absolute; } #wb_Shape9 span { position: absolute; } #wb_Shape9 a .hover { visibility: hidden; } #wb_Shape9 a:hover .hover { visibility: visible; } #wb_Shape9 a:hover span { visibility: hidden; } #wb_Shape10 a img { position: absolute; } #wb_Shape10 span { position: absolute; } #wb_Shape10 a .hover { visibility: hidden; } #wb_Shape10 a:hover .hover { visibility: visible; } #wb_Shape10 a:hover span { visibility: hidden; } #wb_Shape4 a img { position: absolute; } #wb_Shape4 span { position: absolute; } #wb_Shape4 a .hover { visibility: hidden; } #wb_Shape4 a:hover .hover { visibility: visible; } #wb_Shape4 a:hover span { visibility: hidden; } #Image2 { border: 0px #000000 solid; } #Layer1 { background-color: #FAFAFA; opacity: 0.00; -moz-opacity: 0.00; -khtml-opacity: 0.00; filter: alpha(opacity=0); } #Image1 { border: 0px #000000 solid; } [color=#008000][b]================================ CSS and SCRIPT ============================== [color=#800080][color=#8000FF][list]#Editbox1 { border: 2px #000000 solid; -moz-border-radius: 25px; -webkit-border-radius: 25px; border-radius: 25px; background-color: #CCFFFF; color :#282828; font-family: Arial; font-size: 20px; padding: 0px 0px 0px 20px; text-align: left; vertical-align: middle; } [/color][/list][/color]</style> [b][color=#4000FF]<script type="text/javascript"> function showResult(str) { if (str.length==0) { document.getElementById("livesearch").innerHTML=""; document.getElementById("livesearch").style.border="0px" return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("livesearch").innerHTML=xmlhttp.responseText; document.getElementById("livesearch").style.fontFamily="Arial"; document.getElementByID("livesearch").style.position="absolute"; document.getElementByID("livesearch").style.top="500px"; document.getElementByID("livesearch").style.left="500px" } } xmlhttp.open("GET","livesearch.php?q="+str,true); xmlhttp.send(); } </script>[/b][/color] [/color]</head> [/b] ===================== END CSS AND SCRIPT ================================= <body> <div id="container"> <div id="wb_Shape2" style="position:absolute;left:73px;top:142px;width:753px;height:44px;z-index:1;"> <img src="images/img0026.gif" id="Shape2" alt="" style="border-width:0;width:753px;height:44px;"></div> <div id="wb_Shape7" style="position:absolute;left:2px;top:28px;width:959px;height:578px;z-index:2;"> <img src="images/img0027.gif" id="Shape7" alt="" style="border-width:0;width:959px;height:578px;"></div> <hr id="Line1" style="margin:0;padding:0;position:absolute;left:437px;top:116px;width:442px;height:3px;z-index:3;"> <div id="wb_Shape5" style="position:absolute;left:511px;top:63px;width:2px;height:44px;z-index:4;"> <img src="images/img0028.gif" id="Shape5" alt="" style="border-width:0;width:2px;height:44px;"></div> <div id="wb_Shape8" style="position:absolute;left:599px;top:56px;width:111px;height:66px;z-index:5;"> <a href="./discover.htm"><img class="hover" src="images/img0029_hover.png" alt="" style="border-width:0;width:111px;height:66px;"><span><img src="images/img0029.png" id="Shape8" alt="" style="border-width:0;width:111px;height:66px;"></span></a></div> <div id="wb_Shape9" style="position:absolute;left:712px;top:57px;width:98px;height:66px;z-index:6;"> <a href="./learn.htm"><img class="hover" src="images/img0030_hover.png" alt="" style="border-width:0;width:98px;height:66px;"><span><img src="images/img0030.png" id="Shape9" alt="" style="border-width:0;width:98px;height:66px;"></span></a></div> <div id="wb_Shape10" style="position:absolute;left:812px;top:57px;width:89px;height:66px;z-index:7;"> <a href="./contact.htm"><img class="hover" src="images/img0031_hover.png" alt="" style="border-width:0;width:89px;height:66px;"><span><img src="images/img0031.png" id="Shape10" alt="" style="border-width:0;width:89px;height:66px;"></span></a></div> <div id="wb_Shape11" style="position:absolute;left:592px;top:63px;width:2px;height:44px;z-index:8;"> <img src="images/img0032.gif" id="Shape11" alt="" style="border-width:0;width:2px;height:44px;"></div> <div id="wb_Shape12" style="position:absolute;left:706px;top:61px;width:2px;height:44px;z-index:9;"> <img src="images/img0033.gif" id="Shape12" alt="" style="border-width:0;width:2px;height:44px;"></div> <div id="wb_Shape13" style="position:absolute;left:805px;top:61px;width:2px;height:44px;z-index:10;"> <img src="images/img0034.gif" id="Shape13" alt="" style="border-width:0;width:2px;height:44px;"></div> <div id="wb_Shape4" style="position:absolute;left:517px;top:55px;width:81px;height:69px;z-index:11;"> <a href="./form.htm"><img class="hover" src="images/img0035_hover.png" alt="" style="border-width:0;width:81px;height:69px;"><span><img src="images/img0035.png" id="Shape4" alt="" style="border-width:0;width:81px;height:69px;"></span></a></div> <div id="wb_Shape1" style="position:absolute;left:436px;top:55px;width:81px;height:68px;z-index:12;"> <img src="images/img0036.png" id="Shape1" alt="" style="border-width:0;width:81px;height:68px;"></div> <div id="wb_Image2" style="position:absolute;left:64px;top:53px;width:334px;height:61px;z-index:13;"> <img src="images/SWLavLogo.JPG" id="Image2" alt="" border="0" style="width:334px;height:61px;"></div> <div id="Layer1" style="position:absolute;text-align:left;left:50px;top:36px;width:368px;height:96px;z-index:14;" title="Go home!"> <div id="wb_Image1" style="position:absolute;left:11px;top:5px;width:344px;height:82px;opacity:0.00;-moz-opacity:0.00;-khtml-opacity:0.00;filter:alpha(opacity=0);z-index:0;"> <a href="./index.htm"><img src="images/SW-Logo.jpg" id="Image1" alt="" border="0" style="width:344px;height:82px;"></a></div> </div> [color=#008000]=========================== HTML FOR INPUT BOX FORM ========================= [color=#4000FF]<form> <input type="text" id="Editbox1" onkeyup="showResult(this.value)" style="position:absolute;left:107px;top:139px;width:724px;height:41px;line-height:41px;z-index:15;" name="SearchBox" value="" autocomplete="off" placeholder="Start your search here" autofocus="autofocus" placeholder="Start your search here"> <div id="livesearch"></div> </form> =================================END FORM HTML =============================[/color] [/color]<div id="wb_Shape6" style="position:absolute;left:787px;top:146px;width:53px;height:28px;z-index:16;"> <img src="images/img0038.gif" id="Shape6" alt="" style="border-width:0;width:53px;height:28px;"></div> </div> </body> </html> Thank you very much for taking the time. -- DrC
  4. Hey everyone! i am having some problem. In my code i am fetching data from multiple tables, but the code is having some problem it give me "mysql_fetch_array() expects parameter 1 to be resource, boolean given " error ... here is my code <?php $localhost="localhost"; $dbuser="root"; $dbpass=""; $dbname="shoppro"; $connect=mysql_connect($localhost,$dbuser,$dbpass); if ( !$connect ) { echo "Error connecting to database.\n"; } mysql_select_db("$dbname",$connect); $count = "select count(*)-1 from core_store_group"; $i = ''; $sql = ''; for($i=0;$i<$count;$i++){ $sql = "select name,price,short_description,sku,weight,promotion from catalog_product_flat_'".$i."'". "UNION ALL"; } $query=$sql.substr(0,$sql.strlen($sql)-9); $result=mysql_query($query); while($row=mysql_fetch_array($result)){ echo $row['name']; } ?> please help me..
  5. Here is a row from my merchandise table: <tr> <td>Product ID</td> <td>Artist</td> <td>Title</td> <td>Album Art</td> <td>Label</td> <td>Year</td> <td>Price</td> <td> <input type='text' name='cart[dawn of chaos][]' value='0' size='2'/> </td> </tr> I would like to direct your attention to the input row. In my PHP, the input field actually says "name=cart[$title][]" etc... Then I would like to reference the multidimensional array with PHP. To begin I just added a simple foreach. foreach($_POST['cart'] as $item){ echo $item; } PHP says this: Array ( ) Notice: Undefined index: cart in /you/probably/don't/need/my/filepath/cart.php on line 6 Warning: Invalid argument supplied for foreach() in....
  6. Hi, I have a problem with a contactform om my website. When I try to fill in the form I get a message that something is wrong. I´m not familiar with php-script, so I don´t know how to correct it. But you guys know how to fix this problem. So please give me a hand and tell me how to do and what to write, so that the script works. The messages I get in the browser is this : Notice: Undefined index: Rubrik in \\atm.binero.net\content\56\161156\mywebsite.se\public_html\Test_2\mail.php on line 18 Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in \\atm.binero.net\content\56\161156\mywebsite.se\public_html\Test_2\mail.php on line 27 The file mail.php looks like this: LINE 18, $rubrik = $_POST["Rubrik"]; LINE 27, if (mail($till, $rubrik, $med, $header )) { If you know how to fix this, please let me know. Thank´s so far
  7. I am a young php developer who also does pen-testing for websites and company's. I am looking for some people interested in getting their web applications tested for security flaws. I am doing this just for experience (so it is free). All i need is a comment in one of your pages giving me permission to do so. That proves it is your website and that I have permission. I do not mess with any data or functionality, all I do is test your website security and send you a report with what I find. I can also offer to fix the bugs I find. Looking forward to helping some people secure their websites!
  8. This website that has been running for a few years now. I needed to add two menu items to the dwt template and ever since I made the changes the site loads up to the <head> tag. Here is the dwt,php file <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <?php require('..Connections/qmbl.php'); $sqlstr = "select i_html from SiteInfo where i_type = 'NEWS_SCROLL'"; $rs_scroll = mysq1_query($sqlstr, $cid); $scroll = mysql_result($rs_scroll,0,0); $sqlstr = "select team_id, t_name from Team t, Settings s where t.t_season = s.cur_season order by t_name"; $rs_teams = mysql_query($sqlstr, $cid); $count=0; $templateTeams=""; while($row = mysql_fetch_assoc($rs_teams)){$templateTeams .= '<a href="team.php?t='.$row['team_id'].'">'.$row['t_name'].'</a><br />'; } //end while ?> <!-- TemplateBeginEditable name="head" --> <!-- TemplateEndEditable --><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!-- TemplateBeginEditable name="doctitle" --> <title>Untitled Document</title> <!-- TemplateEndEditable --> <link href="../qmbl2010.css" rel="stylesheet" type="text/css" /> </head> <body> <table id="page" width="960" border="0" align="center" > <tr> <td><img src="../images/1ptTrans.gif" width="1" height="200" alt="image"/></td> <td> <div id="header"> <div id="topMenu"> <table width="100%" border="0"> <tr> <td align="center" valign="middle"><img src="../images/1ptTrans.gif" width="1" height="24" alt="image"/></td> <td align="center" valign="middle"><a href="../field.php">Weather</a></td> <td align="center" valign="middle"><a href="../sponsors.php">Sponsors</a></td> <td align="center" valign="middle"><a href="../advertising.php">Advertising</a></td> <td align="center" valign="middle"><a href="../contact.php">Contact</a></td> <td width="25" align="center" valign="middle"> </td> <td width="65" align="right" valign="middle"><a href="../register.php">Register</a> </td> <td align="center" valign="middle">|</td> <td width="45" align="left" valign="middle"><a href="../login.php"> Login</a> </td> </tr> </table> </div> <div id="mainMenu"> <table width="100%" border="0"> <tr> <td height="100%" align="center" valign="middle"><img src="../images/1ptTrans.gif" width="1" height="30" alt="image"/></td> <td height="100%" align="center" valign="middle"><a href="../about.php">league</a></td> <td height="100%" align="center" valign="middle"><a href="../standings.php">standings</a></td> <td height="100%" align="center" valign="middle"><a href="../schedule.php">schedules</a></td> <td height="100%" align="center" valign="middle"><a href="../scorecard.php">scorecard</a></td> <td height="100%" align="center" valign="middle"><a href="../thedugout.php">the dugout</a></td> <td height="100%" align="center" valign="middle"><a href="../news.php">news</a></td> <td height="100%" align="center" valign="middle"><a href="../products.php">products</a></td> <td height="100%" align="center" valign="middle"><a href="../rules.php">rules</a></td> <td height="100%" align="center" valign="middle"><a href="../wavier.php">wavier</a></td> <td height="100%" align="center" valign="middle"><a href="../events.php">events</a></td> </tr> </table> </div> <div id="homelink"><a href="../index.php"><img src="../images/1ptTrans.gif" width="184" height="177" border="0" alt="image" /></a></div> </div></td> </tr> <tr> <td colspan="2"><div id="scroll"><?php echo $scroll; ?></div> </td> </tr> <tr> <td><img src="../images/1ptTrans.gif" width="1" height="250" alt="image"/></td> <td class="body"><!-- TemplateBeginEditable name="body" --><!-- TemplateEndEditable --></td> </tr> <tr> <td><img src="../images/1ptTrans.gif" width="1" height="150" alt="image"/></td> <td valign="top" class="bottomMenu"><table width="100%" border="0"> <tr> <th scope="col"><a href="../index.php">QMBL</a></th> <th scope="col"><a href="../thedugout.php">The Dugout</a></th> <th scope="col">QMBL League</th> <th scope="col">QMBL Links</th> <th scope="col">QMBL Office</th> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td><a href="../about.php">About</a><br /> <a href="../awards.php">Awareds</a><br /> <a href="../news.php">News</a><br /> <a href="../events.php">Special Events</a><br /> <a href="../products.php">Products</a><br /> <a href="../field.php">Weather</a></td> <td><?php echo $templateTeams; ?></td> <td><a href="../scorecard.php">Scorecard</a><br /> <a href="../standings.php">Standings</a><br /> <a href="../schedule.php">Schedules</a></td> <td><a href="http://www.mlb.com">MLB</a><br /> <a href="http://www.nfl.com">NFL</a><br /> <a href="http://www.nba.com">NBA</a><br /> <a href="http://www.nhl.com">NHL</a><br /> <a href="http://www.espn.com">ESPN</a><br /> <a href="../games.php">Fun</a></td> <td><a href="../contact.php">Contact</a><br /> <a href="../advertising.php">Advertise with us</a><br /> <a href="../sponsors.php">Sponsors</a><br /> <a href="../poll.php">Poll</a></td> </tr> </table></td> </tr> </table> </body> </html> It error checks but it wont load. Thanks in advance for you help. Kohron J Burton Kohron J Burton LLC
  9. Hi! I need to know when the php file has sent the email from the a HTML Form and passsing it to Jquery. i did some research in internet and i found the "submit" option with .serialize() in Jquery, but 'cause i'm new in php i can't get it work. How .serialize() works exactly? Because i'm having my "alert" just by clicing the submit bottom and not when the email has been sent. If someone could help me with a link to begginers to learn that or make a correction in my code, i would be very greatfull. Here's my code : HTML : <html> <form method="post" action="form-to-email.php" id="myform"> <div class="field"> <label for="name">Your Name :</label> <input type="text" name="name" id="name" class="required" /> </div> <div class="field"> <label for="email">Please, give us an email :</label> <input type="text" name="email" id="email" class="required email" /> </div> <div class="field"> <label for="message" id="message-bg">Tell us about your project :</label> <textarea name="message" rows="20" cols="20" id="message" class="required"></textarea> </div> <img id="icon-contact" src="images/icon-contact.png" alt="icon-contact" /> <div class="field"> <input type="submit" name="submit" value="Submit" class="submit-button" /> </div> </form> </html> PHP : <?php if(!isset($_POST['submit'])) { echo "error; you need to submit the form!"; } $name = $_POST['name']; $visitor_email = $_POST['email']; $message = $_POST['message']; //Validate first if(empty($name)||empty($visitor_email)) { echo "Name and email are mandatory!"; exit; } if(IsInjected($visitor_email)) { echo "Bad email value!"; exit; } $email_from = 'website-clientes@blabla.com';//<== update the email address $email_subject = "Mensaje del amigo/a $name"; $email_body = "Hola! Me llamo $name, y quisiera decirles :\n \n$message \n \n \n". $to = "blbla@blabla.com";//<== update the email address $headers = "From: $email_from \r\n"; $headers .= "Reply-To: $visitor_email \n"; //Send the email! mail($to,$email_subject,$email_body,$headers); header('Location: index.html'); ?> JQUERY : $("#myform").submit(function(event) { /* stop form from submitting normally */ event.preventDefault(); $.post( 'form-to-email.php', $("#myform").serialize(), function() { $('#myform').get(0).reset(); alert("Your message has been sent, Thanks!") ; } ); }); Thanks a lot for your help !
  10. can anybody tell me what this message mean? this is my code... <?php session_start(); require_once ('test.php'); echo '<pre>'; print_r( $_SERVER); echo '</pre>'; $ip = $_SERVER['REMOTE_ADDR']; $ip = ip2long($ip); $browser = $_SERVER['HTTP_USER_AGENT']; $referer = $_SERVER['HTTP_REFERER']; $url = $_SERVER['REQUEST_URI']; $session = session_id(); $query = "INSERT INTO page_views SET ip = '$ip', browser = '$browser', url = '$url', session_id = '$session', start_time = NOW()"; $result = mysqli_query($dbc, $query); if ( $result ) { echo 'good'; } else { echo 'bad'; echo '<p>' . mysqli_error($dbc) . '<br />Query: ' . $query . '</p>'; // Debugging message. } ?>
  11. I have created this form. I am trying to capture the values of the drop down lists but am having a hard time trying to do so, and was hoping someone here might be able to help me. They are being declared using a unique identifier of their respective tables from my sql db. each section of product in that form has its own table and own table id which the drop down lists are using. They are declared in the form like this. echo "<td><select name=". $row['goosedown_id'] ."> <option value=''> 0 </option> <option>1</option> <option>2</option> <option>3</option> <option>4</option> <option>5</option> <option>6</option> <option>7</option> <option>8</option> </select> </td>"; Once the user hits submit I then try to capture these drop down lists in my orderform.php like so (this is also where I am having trouble) $goosedown_id = ($_POST[$row['goosedown_id']]); //.. /*-------------------First Email--------------------*/ /* Set Email for Redgraves, so they can for-full the order form */ $message = "Your contact form has been submitted by: Order number : $random Name: $yourname E-mail: $email Phone Number: $phonenumber Mobile Number: $mobilenumber Delivery Address : $deliveryaddress Order: ----------------------------------------------------------------- test goosedown_id: $goosedown_id "foreach ($_POST[$row['goosedown_id']] != 0) { "test goosedown_id: $goosedown_id" }" ----------------------------------------------------------------- Comments: $comments End of message "; /* Send the message using mail() function */ mail($myemail, "Order Submitted", $message); As you can see I have made a minor attempt at getting the drop down lists values that are not equal to 0.. but this code is defiantly not working.. but hopefully it serves a purpose to show you waht I am trying to achieve.. any help would be greatly appreciated.. been stuck on this problem all weekend.
  12. I have an html form that takes a date and send it to an php script: <form action='tupdatecompletiondate.php' method='post'><input type='hidden' name='idtosubmit' value=$id><tr> <td><label>Date:</label></td> <td><input type= 'date' name= 'date' value='Select Date' id='popupDatepicker'></td> </tr><input type='submit' value='Click to Update'></form> I've got it going to this script: $id = $_POST['idtosubmit']; $date = $_POST['date']; $datetoset = date('Y-m-d', strtotime($date)); $sql = "UPDATE needs SET completiondate=$datetoset WHERE ID=$id"; if (!mysql_query($sql)) { die('Error: ' . mysql_error()); } mysql_close(); Confused as to why it's not working. It takes the date, sends it to the php script, makes it into a format that is accepted by the DATE column, and then puts it in that column....well at least its supposed to.
  13. I have a script that I need some help with. Its a reminder script (posted below). Basically I have a completiondate (which in the database is a varchar...don't know if that makes a difference) that is made up like day, month, year (Ex: 06102012) and I want the script (which is a cron job) to look at todays date and see if it is 2 days before todays date. If it is then I want an email sent. I'm confused on where I'm going wrong. Please help! Thanks. An example would be: Todays date is: 06102012 If completiondate = 2 days before todays date { send email } $todaysdate = date('d/m/Y'); $query = "SELECT completiondate FROM needs WHERE completiondate =($todaysdate, strtotime('-1 days'))"; $result = mysql_query($query); mail('derekshull@gmail.com', 'Important Stuff', 'Hey there.'); ?>
  14. Hi PHP Freaks, I have written a php email form and then this code behind it. When I run it comes up with the error page however all inputs are filled in and valid. Here is my code: <?php //variables from form $firstname = ucwords(strtolower($_POST['firstname'])); $lastname = ucwords(strtolower($_POST['lastname'])); $client_email_address = $_POST['email_address']; $subject = $_POST['subject']; $message = wordwrap($_POST['message'], 150, '<br />'); $fullname = $firstname.' '.$lastname; //error pages $email_successful_page = 'mail_successful.php'; //create mail_successful.php; $email_failed_page = 'delivery_failed.php'; //create delivery_failed.php; //create emailform.php (and in it the ability to read the error from this script and tell the user //set date date_default_timezone_set('Australia/NSW'); //email 1 is sent to the scd admin email $email_1_recipient_address = 'joshua.paduch@gmail.com'; //'systemadministrator@shellharbourcitydental.com.au'; $email_1_subject = 'Email sent to '.$dentist_name.' from '.$client_email.' regarding '.$subject; $email_1_message = '<html>\n\t<body>\n\t\t<img src=\"emailheader.jpg\" width="" height="" style="float:center;"/>\n\t\t'; $email_1_message .= '\n\t\t<h1>Hi System Administrator, </h1>'; $email_1_message .= '\n\t\t<br /><p>For records, </p>'; //$email_1_message .= ''; //$email_1_message .= ''; $email_1_headers = "From: autoresponder@shellharbourcitydental.com.au \r\n"; $email_1_headers .= "Reply-To: donotreply@shellharbourcitydental.com.au \r\n"; $email_1_headers .= "X-Mailer: PHP/".phpversion()." \r\n"; $email_1_headers .= "To: joshua.paduch@gmail.com \r\n"; $email_1_headers .= "Content-type: text/html; charset=UTF-8 \r\n"; $email_1_headers .= "MIME-Version: 1.0 \r\n"; //$email_1_headers .= " \r\n"; //email 2 is sent to the intended dentist / practitioner $email_2_recipient_address = 'joshua.paduch@gmail.com'; //'info@shellharbourcitydental.com.au'; $email_2_subject = $subject; $email_2_message = 'message'; //$email_2_message .= ''; //$email_2_message .= ''; $email_2_headers = "From: autoresponder@shellharbourcitydental.com.au \r\n"; $email_2_headers .= "Reply-To: donotreply@shellharbourcitydental.com.au \r\n"; $email_2_headers .= "X-Mailer: PHP/".phpversion()." \r\n"; $email_2_headers .= "To: joshua.paduch@gmail.com \r\n"; $email_2_headers .= "Content-type: text/html; charset=UTF-8 \r\n"; $email_2_headers .= "MIME-Version: 1.0 \r\n"; //$email_2_headers .= " \r\n"; //email 3 is a confirmation email sent to the client $email_3_recipient_address = $client_email_address; $email_3_subject = 'Confirmation Email Regarding: '.$subject; $email_3_message = 'message'; //$email_3_message .= ''; //$email_3_message .= ''; $email_3_headers = "From: autoresponder@shellharbourcitydental.com.au \r\n"; $email_3_headers .= "Reply-To: donotreply@shellharbourcitydental.com.au \r\n"; $email_3_headers .= "X-Mailer: PHP/".phpversion()." \r\n"; $email_3_headers .= "To: ".$client_email." \r\n"; $email_3_headers .= "Content-type: text/html; charset=UTF-8 \r\n"; $email_3_headers .= "MIME-Version: 1.0 \r\n"; //$email_3_headers .= " \r\n"; //form validation function function form_validation($var1,$var2,$var3,$var4,$var5){ if(isset($_POST['firstname']) && isset($_POST['lastname']) && isset($_POST['email_address']) && isset($_POST['subject']) && isset($_POST['message'])){ if(strlen($var1) < 1){ return false; $error = "firstname"; } elseif(strlen($var2) < 1){ return false; $error = "lastname"; } elseif(!filter_var($var3, FILTER_VALIDATE_EMAIL)){ return false; $error = "invalid email address"; } elseif(strlen($var4) < 1){ return false; $error = "subject"; } elseif(strlen($var5) < 1){ return false; $error = "message"; } else{ return true; } } else{ return false; } } //emailing function function email($email_1_var_1,$email_1_var_2,$email_1_var_3,$email_1_var_4,$email_2_var_1,$email_2_var_2,$email_2_var_3,$email_2_var_4,$email_3_var_1,$email_3_var_2,$email_3_var_3,$email_3_var_4){ if(!mail($email_1_var_1,$email_1_var_2,$email_1_var_3,$email_1_var_4)){ $email_error = "email 1 error"; } if(!mail($email_2_var_1,$email_2_var_2,$email_2_var_3,$email_2_var_4)){ $email_error = "email 2 error"; } if(!mail($email_3_var_1,$email_3_var_2,$email_3_var_3,$email_3_var_4)){ $email_error = "email 3 error"; } } //if form validation fails - redirect to error page - mail if(!form_validation($firstname,$lastname,$email_address,$subject,$message)){ header('Location: '.$email_failed_page.'?error='.$error); } else{ if(!email($email_1_recipient_address,$email_1_subject,$email_1_message,$email_1_headers,$email_2_recipient_address,$email_2_subject,$email_2_message,$email_2_headers,$email_3_recipient_address,$email_3_subject,$email_3_message,$email_3_headers)){ header('Location: '.$email_failed_page.'?email_error='.$email_error); } else{ header('Location: '.$email_succesful_page); } } Any advice is welcome. Thanks everyone, Timothy
  15. Hey guys this has been asked before and i was wondering what technics you guys use for displaying dynamic content. Basicly when a link is clicked it would send you to www.explample.com/?page=new How would i check in php and display the page with that article. if issset() page $name{ include ('includes/$name' . '.php') else echo page does not exist Ya i know shoot me for the most horrible example but im doing this from my iphone right now !! Any help greatly apreciated
  16. I have doubt on how to include two fields(Productcode,Effectivedate) that is to be considered on deletion. Following is the code, Following is the code for delete function, if(isset($_POST['Delete'])) { $checkbox = $_POST['checkbox']; //from name="checkbox[]" $countCheck = count($_POST['checkbox']); for($i=0;$i<$countCheck;$i++) { $prodidd = $checkbox[$i]; $prod1 = $checkbox[$i]; ///$prodid= $_POST['checkbox']; $sql = "DELETE FROM `oemanucfacturemapping` WHERE Productcode ='".$prodidd."' and Effectivedate = '".$prod1."'"; $result = mysql_query($sql); } if($result){ ?> <script type="text/javascript"> alert("Deleted Successfully!!");document.location='oemanufacturermap.php'; </script> <? } } The checkbox value is taken from the following code, <table align="center" class="sortable" bgcolor="#FF0000" border="1" width="900px"> <td>#</td><strong><td>OEManufacturer Name</td></strong><td>Product Code</td><td>Manufacturer Warranty</td><td>Sales Warranty</td><td>Effective Date</td><td>KMRun</td><td>####</td> <?php // This while will loop through all of the records as long as there is another record left. while( $record = mysql_fetch_array($query)) { // Basically as long as $record isn't false, we'll keep looping. // You'll see below here the short hand for echoing php strings. // <?=$record[key] - will display the value for that array. ?> <tr> <td align="center" bgcolor="#FFFFFF"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<?php echo $record['Productcode'],$record['Effectivedate'];?>"></td> <td bgcolor="#FFFFFF"> <?=$record['OEManufacturename']?> </td> <td bgcolor="#FFFFFF" align="left" valign="top"> <?=$record['Productcode']?> </td> <td bgcolor="#FFFFFF" align="left" valign="top"> <?=$record['ManufacturingWarranty']?> </td> <td bgcolor="#FFFFFF" align="left" valign="top"> <?=$record['Saleswarranty']?> </td> <td bgcolor="#FFFFFF" align="left" valign="top"> <?=$record['Effectivedate']?> </td> <td bgcolor="#FFFFFF" align="left" valign="top"> <?=$record['KMRun']?> </td> <td bgcolor="#FFFFFF" align="left" valign="top"> <a name="edit" href="oemanufacturermap.php?Productcode=<?=$record['Productcode']?>&Effectivedate=<?=$record['Effectivedate'];?>">Edit</a></td> <?php } ?> </table> Help pls, How can i do this?
  17. Hi Guys This "simple" problem has me pulling my hair out. Source code attached. I have the same Database and Table on 4 different machines. I have been trying to solve this for a few days. When I run the attached source on my local boxes it works exactly as one would expect. That is inserts 1 record into the table. When I run the attached source on my 2 different web hosts, it inserts 2 records into the table. I have tried this MANY times. Does anyone even have a theory? My only thoughts now are thought some lib is screwed up some where. I am about 99.9% sure it is NOT my php code BUT figuered this would be the best place to ask.simple.php
  18. Hi PHP Freaks, I am currently having trouble with my mailing script. When I load it in the browser it comes up with the following error: 500 Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, webmaster@domain-name.com and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. There is no errors in the error_log and in the email failure email sent to my webmaster email it says it contained no recipient address but I have set that in the code. Here is the Code HTML Form: <form method="post" action="mail.php"> <label for="firstname">Firstname:</label> <input type="text" name="firstname" id="firstname" value="" /> <label for="lastname">Lastname:</label> <input type="text" name="lastname" id="lastname" value="" /> <label for="email_address">Email Address:</label> <input type="text" name="email_address" id="email_address" value="" /> <label for="subject">Subject:</label> <select name="subject" id="subject"> <option name="request_appointment" id="request_appointment" value="Request an Appointment">Request an Appointment</option> <option name="request_callback" id="request_callback" value="Request a Call-Back">Request a Call-Back</option> <option name="question" id="question" value="I Have a Question">I Have a Question</option> <option name="emergency" id="emergency" value="Emergency">Emergency (Call 0422 036 768)</option> <option name="other" id="other" value="Other">Other</option> </select><br /> <label for="message">Message:</label> <textarea name="message" id="message" cols="45" rows="10"></textarea> <button type="submit" value="submit"><span>Submit</span></button> </form> PHP Scripting <?php //declare variables $email_successful_page = 'mail_successful.php'; //create mail_successful.php; $email_failed_page = 'delivery_failed.php'; //create delivery_failed.php; //create emailform.php (and in it the ability to read the error from this script and tell the user //declare email variables $firstname = ucwords(strtolower($_REQUEST['firstname'])); $lastname = ucwords(strtolower($_REQUEST['lastname'])); $subject = $_POST['subject']; $message = wordwrap($_POST['message'], 150, '<br />'); $client_name = $firstname." ".$lastname; $dentist_name = $_REQUEST['dentist']; $dentist_email = $dentist_name.'@domain-name.com.au'; $client_email = $_POST['email_address']; //date date_default_timezone_set('Australia/NSW'); global $email_1_recipient_address, $email_1_subject, $email_1_message, $email_1_headers, $email_2_recipient_address, $email_2_subject, $email_2_message, $email_2_headers, $email_3_recipient_address, $email_3_subject, $email_3_message, $email_3_headers; //email 1 is sent to the scd admin email $email_1_recipient_address = 'systemadministrator@domain-name.com.au'; $email_1_subject = 'Email sent to '.$dentist_name.' from '.$client_email.' regarding '.$subject; $email_1_message = '<html>\n\t<body>\n\t\t<img src=\"emailheader.jpg\" width="" height="" style="float:center;"/>\n\t\t'; $email_1_message .= '\n\t\t<h1>Hi System Administrator, </h1>'; $email_1_message .= '\n\t\t<br /><p>For records, </p>'; $email_1_message .= ''; $email_1_message .= ''; $email_1_headers = "From: autoresponder@domain-name.com.au \r\n"; $email_1_headers .= "Reply-To: donotreply@domain-name.com.au \r\n"; $email_1_headers .= "X-Mailer: PHP/".phpversion()." \r\n"; $email_1_headers .= "To: joshua.paduch@gmail.com \r\n"; $email_1_headers .= "Content-type: text/html; charset=UTF-8 \r\n"; $email_1_headers .= "MIME-Version: 1.0 \r\n"; //$email_1_headers .= " \r\n"; //email 2 is sent to the intended dentist / practitioner $email_2_recipient_address = 'info@domain-name.com.au'; $email_2_subject = $subject; $email_2_message = 'message'; $email_2_message .= ''; $email_2_message .= ''; $email_2_headers = "From: autoresponder@domain-name.com.au \r\n"; $email_2_headers .= "Reply-To: donotreply@domain-name.com.au \r\n"; $email_2_headers .= "X-Mailer: PHP/".phpversion()." \r\n"; $email_2_headers .= "To: joshua.paduch@gmail.com \r\n"; $email_2_headers .= "Content-type: text/html; charset=UTF-8 \r\n"; $email_2_headers .= "MIME-Version: 1.0 \r\n"; //$email_2_headers .= " \r\n"; //email 3 is a confirmation email sent to the client $email_3_recipient_address = $client_email; $email_3_subject = 'Confirmation Email Regarding: '.$subject; $email_3_message = 'message'; $email_3_message .= ''; $email_3_message .= ''; $email_3_headers = "From: autoresponder@domain-name.com.au \r\n"; $email_3_headers .= "Reply-To: donotreply@domain-name.com.au \r\n"; $email_3_headers .= "X-Mailer: PHP/".phpversion()." \r\n"; $email_3_headers .= "To: ".$client_email." \r\n"; $email_3_headers .= "Content-type: text/html; charset=UTF-8 \r\n"; $email_3_headers .= "MIME-Version: 1.0 \r\n"; //$email_3_headers .= " \r\n"; //validate inputs function form_validation(){ function email_address_validation(){ //Validates & Sanitizes the email address if(!filter_var($client_email, FILTER_VALIDATE_EMAIL) && strlen($client_email) < 1){ global $error; global $error_page; $error = "Email Address was empty or had a invalid value."; $error_page = "email address error"; return true; } else{ return false; } } function firstname_validation(){ if(strlen($firstname) > 0){ global $error; global $error_page; $error = "Firstname was empty or had a invalid value."; $error_page = "firstname error"; return true; } else{ return false; } } function lastname_validation(){ if(strlen($lastname) > 0){ global $error; global $error_page; $error = "Lastname was empty or had a invalid value."; $error_page = "lastname error"; return true; } else{ return false; } } function subject_validation(){ if(!isset($subject)){ global $error; global $error_page; $error = "Subject was empty or had a invalid value."; $error_page = "subject error"; return true; } else{ return false; } } function message_validation(){ if(!isset($message)){ global $error; global $error_page; $error = "Message was empty or had a invalid value."; $error_page = "message content error"; return true; } else{ return false; } } //call to above validation function to be executed when form_validation is called global $email_address_validation, $firstname_validation, $lastname_validation, $subject_validation, $message_validation; $email_address_validation = email_address_validation(); $firstname_validation = firstname_validation(); $lastname_validation = lastname_validation(); $subject_validation = subject_validation(); $message_validation = message_validation(); if(!isset($error) || $email_address_validation == false || $firstname_validation == false || $lastname_validation == false || $subject_validation == false || $message_validation == false){ return true; } else{ return false; } } $form_validation = form_validation(); //if the form validation returns false - break the code - write the error and contact form to page if($form_validation != true){ header($email_failed_page); break; //check to see this breaks the entire script not just the if loop } //declare email functions function send_emails(){ /* mail($email_1_recipient_address, $email_1_subject, $email_1_message, $email_1_headers); mail($email_2_recipient_address, $email_2_subject, $email_2_message, $email_2_headers); mail($email_3_recipient_address, $email_3_subject, $email_3_message, $email_3_headers); */ if(mail($email_1_recipient_address, $email_1_subject, $email_1_message, $email_1_headers) && mail($email_2_recipient_address, $email_2_subject, $email_2_message, $email_2_headers) && mail($email_3_recipient_address, $email_3_subject, $email_3_message, $email_3_headers)){ header($email_sucessful_page); } else{ header($email_failed_page.'?error='.urlencode(htmlentities($error_page))); //add in read error from $_GET } } $send_emails = send_emails(); if(!$send_emails){ header($email_failed_page.'?error='.urlencode(htmlentities($error_page))); } else{ header($email_sucessful_page); } ?> Any ideas or comments are welcome. Thanks in advance guys, Timothy Call Send SMS Add to Skype You'll need Skype CreditFree via Skype
  19. I have the following code below. I have added buttons to each entry that pops up but I need the buttons to do certain things and I'm stuck. When the Approve button is pressed I want the entire entry to go to another table called "incomplete" (no quotations) and then I want the record to be deleted from the table "needs" (no quotations), which it currently resides in. When the Deny button is pushed I want the entry to just be deleted from the table "needs" (no quotations). Tried to figure it out on my own but I have nothing. I'm new to all this and the fact that I've gotten this far makes me excited :-) $query = mysql_query("SELECT * FROM needs"); while ($rows = mysql_fetch_array($query)): $firstname = $rows['firstname']; $lastname = $rows['lastname']; $address = $rows['address']; $city = $rows['city']; $state = $rows['state']; $phone = $rows['phone']; $email = $rows['email']; $typeofneed = $rows['typeofneed']; echo "$firstname $lastname<br>$address<br>$city $state<br>$phone<br>$email<br>$typeofneed<br>"; echo "<button name='approve' type='button'>Approve</button><button name='deny' type='button'>Deny</button><br>---------------------------<br>"; endwhile;
  20. hello there, i need some help to display some items from my articles table, the articles table is related whit the other table of mine called category, and in the table categorys there are on column that is called category, inside there are 3 type, and one of them that cals "profile" is the one i need, i need the display all of my articles that is related whit the table categorys and column named "profile", above is the original query Original query: $sql = "SELECT * FROM articles order by articles.id DESC LIMIT ".$from.", 20"; Query i tryed to change: $sql = "SELECT * FROM articles WHERE category = profile and order by articles.id DESC LIMIT ".$from.", 20"; I cant put this work i tryed many thign but no suscess, could someone help me? Could someone help me
  21. my question now is everything is working like my template and the content all i want is to include keywods description and title for each page different it is giving me headache i have a database name pages it has 6 columns id,name,title,description,keywords ,status.where name=home,about,contact etc <?php // Set document: include ('config/setup.php'); if(!isset($_GET['page'])) { $pg= 'page'; }else{ $pg= $_GET['page']; } ?> <!DOCTYPE HTML> <html> <head> <meta charset="utf-8"> <title>help</title> <meta name="description" content="." /> <meta name="keywords" content=" " /> </head> <body> <!-- Header Start --> <div id="logo"> <a class="logo" =pic"> <div class="right"> <?php include('template/right_logo.php');?> </div> </div> <div id="header"> <?php include('template/header.php');?> </div> <!-- Header End --> <!-- Main Start --> <div id="main"> <!-- ### Main Left Start ### --> <div id="left"> <?php //include('content/'.$pg.'.php'); $q="SELECT*FROM pages WHERE name='$pg' "; $r=mysqli_query($dbc,$q); $page= mysqli_fetch_assoc($r); echo '<div class="content_body">'.$page['body'].'</div>'; ?> </div> <!-- ### Main Left End ### --> <!-- ### Main Rigt Start ### --> <div id="right"> <?php include('template/right.php');?> </div> <!-- ### Main Rigt End ### --> <div class="clear"></div> <div id="footer"> <?php include('template/footer.php');?> </div> </div> </div> <!-- Main End --> </body> </html>
  22. Hi guys I needed some help and I found this forum so I thought I'd give it a try. I have this lab that Im doing and instructor really didnt go into detail on how to do it even the code that was demoed was not really helpful in the class . My issue is that I cant seem to get my foreach loop to read the files in the directory i specified and display the name along with being able to play the file as well . Any pointers would be great its over my head at this point . Thanks <!DOCTYPE html > <head> <title>Music Viewer</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link href="http://www.cs.washington.edu/education/courses/cse190m/09sp/labs/3-music/viewer.css" type="text/css" rel="stylesheet" /> </head> <body> <div id="header"> <h1>190M Music Playlist Viewer</h1> <h2>Search Through Your Playlists and Music</h2> </div> <div id="listarea"> <ul id="musiclist"> <!-- *means is equivalent to windows explorer search --> <?php foreach (scandir(C:\Users\test\Desktop\Main\xampp\htdocs\mp3)("./mp3/*.mp3") as $song) { ?> <li class="mp3item"> <a href="./<?= $song ?>"> <?= basename($song) ?> </a> <!--end of href -- > </li> </ul> </div> </body> </html>
  23. I just started a new project and wanted some feedback. Its an add on story where users add on one paragraph at a time. http://whatsintheredsuitcase.com/
  24. I've been trying to generate a database for a quiz game, where players can submit their questions to a database and send their friends the quiz that they have created. I have three problems i hope you can help: 1. I'm having trouble storing the id generated from my last query into a table after the page has changed using the header function, it always returns a 0. 2. I am also having trouble with the final page echoing both an error message about submission and a success message at the same time. 3. I also have a problem with the header link not being able to modify, although it does take you to that page. When the final submit button is pressed I get this: Please complete form before submission Warning: Cannot modify header information - headers already sent by (output started at /Applications/MAMP/htdocs/Quiz/go.php:33) in /Applications/MAMP/htdocs/Quiz/go.php on line 52 Notice: Undefined variable: quizid in /Applications/MAMP/htdocs/Quiz/go.php on line 73 Quiz submitted sucessfully my code is like this: <?php //error reporting error_reporting(E_ALL); //connect to mysql $con = mysql_connect("localhost","dinita","*****"); if(!$con) { die('Could not connect: '.mysql_error()); } else{ // SELECT DATABASE mysql_select_db("quizCreation", $con); //Which form is it? if(isset($_POST['title']) &&!empty($_POST['title'])) { //accept POST data $name = $_POST['name']; $desc =$_POST['desc']; } //check if POST data is complete (all required fields are filled in) //if POST data is not complete return an error if(empty($name)) { echo "Please complete form before submission"; } else { //insert quiz title $sql=" INSERT INTO quizName (Name, Description) VALUES ('$name','$desc')"; mysql_query($sql, $con); //get ID for quiz title $quizid = mysql_insert_id(); if (empty($quizid)){ die("No Quiz id"); } } header("Location: http://localhost:8888/Quiz/quiz.creator.html"); } if (isset($_POST['creator'])&&!empty($_POST['creator'])) { //accept POST data $question = $_POST['question']; } //check if POST data is complete (all required fields are filled in) //if POST data is not complete return an error if(empty($question) && empty($ans1) && empty($ans2) && empty($ans3) && empty($ans4)) { echo "Please complete form before submission"; } else { //insert question $sql= "INSERT INTO questions (text, quiz_ID) VALUES ('$question', '$quizid')"; mysql_query($sql, $con); //get id of inserted question $id = mysql_insert_id(); //insert answers + question id for($i=1; $i<=4; $i++) { $correct = 0; if($_POST['radio'] == "radio".$i) { $correct = 1; } $answer = $_POST['answer'.$i]; $sql=" INSERT INTO answers (question_ID, answer, correct) VALUES ('$id','$answer','$correct')"; mysql_query($sql, $con); } } //show message to say insert has completed successfully echo "Quiz submitted sucessfully"; //close connection to mysql mysql_close($con); Thanks in advance for any help you can offer.
  25. Hi, I have a string which I am pulling from a MySQL DB which unfortunately looks like the following. <p><img src="myimage.jpg" border="0" /></p> <p>My short paragraph</p> I would like to pull out <img src="myimage.jpg" border="0" /> and place it in a separate variable 'strImage' (so I can echo it elsewhere), and then place the remainder of the string in a second variable 'strText'. Note: The <img src> and <border> values will vary depending on the article I pull from the database. What method should I use to make this happen? Thank you so much for your help in advance! Matt
×
×
  • 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.