PHP - Syntax Help Needed
i have the following code but i am struggling to get the syntax correct on it as its throwing me a fetch row error
does any1 have any suggestions as to how this code should look to work properly pls? any help would be appreciated Code: [Select] $weeknr = get_league_weeknr($league); $sql = "SELECT league_id, hometeam_id, awayteam_id, game_id, week_nr ". "FROM fixtures_result ". "WHERE home_result IS NULL "; if ($league!="all"){ $sql .= "AND league_id='" . mysql_real_escape_string($league) . "' AND week_nr < $weeknr "; } $sql .= "AND fixture_ignore='no' "; $sql .= "ORDER BY week_nr"; //echo $sql; $result = mysql_query($sql); cheers in advance Similar TutorialsHi, I had a chat script lying around but wanted to add a login form in case the mxitid wasn't found in the database so I made a few changes to the script to check for records in databases and retrieving the username according the mxit ID. but after I made few changes im getting syntax errors can someone maybe tell me where I made mistakes please.
<?php // database connection info $conn = mysql_connect('*******','********','*******') or trigger_error("SQL", E_USER_ERROR); $db = mysql_select_db('************',$conn) or trigger_error("SQL", E_USER_ERROR); $query0 = mysql_query("SELECT username FROM Users WHERE mxitid=$mid", $con); $result = mysql_query($query0); $myrows = mysql_fetch_array($result); if (mysql_num_rows($query0) != 0) { echo "define('TIMEZONE', 'Africa/Harare'); date_default_timezone_set(TIMEZONE); echo "<html><br> <span style="color:red"><b><u>Chat Beta: Errors may apply please send feedback with contact us regarding problems!</u></b></span> </html>"; // find out how many rows are in the table $sql = "SELECT COUNT(*) FROM StringyChat"; $result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR); $r = mysql_fetch_row($result); $numrows = $r[0]; // number of rows to show per page $rowsperpage = 20; // find out total pages $totalpages = ceil($numrows / $rowsperpage); // get the current page or set a default if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) { // cast var as int $currentpage = (int) $_GET['currentpage']; } else { // default page num $currentpage = 1; } // end if // if current page is greater than total pages... if ($currentpage > $totalpages) { // set current page to last page $currentpage = $totalpages; } // end if // if current page is less than first page... if ($currentpage < 1) { // set current page to first page $currentpage = 1; } // end if // the offset of the list, based on current page $offset = ($currentpage - 1) * $rowsperpage; /* * StringyChat * * Please refer to readme.txt supplied with the StringyChat distribution for information on * installing and configuring. * */ define('TIMEZONE', 'Africa/Harare'); date_default_timezone_set(TIMEZONE); include("chat_code_header.php"); $result = mysql_query("SELECT * FROM ".$ConfigTable, $db); $myrow = mysql_fetch_array($result); $domain_installed = $myrow["domain_installed"]; // The domain StringyChat is installed on $install_url = $myrow["install_url"]; // URL to install dir of StringyChat $name_size = $myrow["name_size"]; // Maximum size of the name $message_size = $myrow["message_size"]; // Maximum message size. Do not exceed 250 as this is the database limit. $line_length = $myrow["line_length"]; // Maximum length of words in a line. Anything above this value will be split. $ShowPostNum = $myrow["show_posts"]; // The number of historic posts to load and display. $email_notification = $myrow["email_notification"]; // Send email to administrator when new posts are made. 0 = No, 1 = Yes $email_notification_to = $myrow["email_notification_to"]; // The email address to send notifications to if ($_SERVER['REQUEST_METHOD'] == "POST" && !empty($_POST['StringyChat_name'])) { $StringyChat_name = $_POST['StringyChat_name']; $StringyChat_message = $_POST['StringyChat_message']; } <div id="StringyChat"> // Check if visitor's IP is banned. If so, do not display the form, // show a banned IP message instead. $name = $myrows["Username"]; if(!isset($name)) { $name = "SYSOP"; } $ip = $_SERVER["REMOTE_ADDR"]; $sql = "SELECT * FROM StringyChat_IPBan WHERE ip=\"$ip\""; $result = mysql_query($sql); $myrow = mysql_fetch_array($result); if($myrow["ip"] == "") { // Checks if IP not found in banned list ?> <html><form name="StringyChat_form" method="POST" action="<? echo $_SERVER['REQUEST_URI']; ?>"> <input type="hidden" name="StringyChat_name" class="StringyChatFrm" value="<?php echo $name ?>" size="20"> <textarea name="StringyChat_message" class="StringyChatFrm" cols="20" rows="1"></textarea> <br> <input name="StringyChat_submit" class="StringyChatFrm" type="submit" value="Post Message"> </form> </html> <? } else { echo "Posting disabled - Your IP has been banned."; } // Should we try to create a post? if (isset($StringyChat_name) && isset($StringyChat_message)) { // Remove whitespaces and slashes. $name = trim(stripslashes($StringyChat_name)); $message = trim(stripslashes($StringyChat_message)); // Check name and message have been entered. if (strlen($name) > 0 && strlen($message) > 0) { // Limit the size of the fields as per variable defnitions. if (strlen($name) > $name_size) { $name = substr($name, 0, $name_size); } if (strlen($message) > $message_size) { $message = substr($message, 0, $message_size); } // Remove new lines from name. $name = str_replace("\n", " ", $name); // Stripping out \r's so email formattnig appears correctly. $message = str_replace("\r", "", $message); // Create an email-friendly version of the message. $message_emailable = str_replace("<br>", "\n", $message); $result_wordswap = mysql_query("SELECT * FROM ".$WordBanTable,$db); while ($myrow_wordswap = mysql_fetch_array($result_wordswap)) { $the_word = $myrow_wordswap["word"]; $message_emailable = ereg_replace($the_word, "!*#$%",$message_emailable); } // Replace the new lines with encoded line breaks for HTML (thanks milahu). $message = str_replace("\n", "c#lb", $message); // Use HTML encoding on ame and message so database doesn't misinterpret data. $name = htmlentities($name); $message = htmlentities($message, ENT_COMPAT); // IP address of submitter and time of post. $ip = $_SERVER["REMOTE_ADDR"]; $name = $_SERVER["HTTP_X_MXIT_NICK"]; $msg = $_POST['StringyChat_message']; $post_time = date("U"); $mxitid = $_SERVER["HTTP_X_MXIT_LOGIN"]; if(!isset($mxitid)) { $mxitid = "DEFAULT"; } if(!isset($name)) { $name = "SYSOP"; } // check to see if a duplicate exists $sql = "SELECT * FROM StringyChat WHERE StringyChat_ip=\"$ip\" AND StringyChat_message=\"$msg\" AND StringyChat_time>($post_time - 1800 )"; $result = mysql_query($sql); $myrow = mysql_fetch_array($result); if($myrow["StringyChat_message"] == "") { // Checks if record not matching in db // Save the record $sql = "INSERT INTO StringyChat (StringyChat_ip,StringyChat_name,StringyChat_message,StringyChat_time) VALUES (\"$ip\",\"$name\",\"$msg\",$post_time)"; $result = mysql_query($sql); } else { echo "Duplicate post detected<br>"; } } else { echo "<font color=\"red\">You must Type a message</font><br><br>"; } unset($_POST["StringyChat_name"]); unset($_POST["StringyChat_message"]); unset($StringyChat_ip); unset($StringyChat_name); unset($StringyChat_message); unset($StringyChat_time); unset($mxit_id); } // get the info from the db $sql = "SELECT StringyChat_time, StringyChat_name, StringyChat_message FROM StringyChat ORDER BY id DESC LIMIT $offset, $rowsperpage"; $result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR); function filterBadWords($str) { $result1 = mysql_query("SELECT word FROM StringyChat_WordBan") or die(mysql_error()); $replacements = ":-x"; while($row = mysql_fetch_assoc($result1)) { $str = eregi_replace($row['word'], str_repeat(':-x', strlen($row['word'])), $str); } return $str; } // while there are rows to be fetched... while ($list = mysql_fetch_assoc($result)) //while (($pmsg = $list['StringyChat_message'] == $bwords) ? ":-x" : $list['StringyChat_message']) { // echo data //echo ($pmsg = ($list['StringyChat_message'] == $bwords) ? ":-x" : $list['StringyChat_message']) $admin = array('SYSOP','cobusbo'); if (in_array($list['StringyChat_name'], $admin)) { print '<span style="color:#828282">' . '(' . date( 'D H:i:s', $list['StringyChat_time'] ) . ') ' . '</span>' . '<span style="color:red">' . '<b>' . $list['StringyChat_name'] . '</b>' . ' : ' . filterBadWords($list['StringyChat_message']) . '</span>' . '<br />' . '<p>'; } else { print '<span style="color:#828282">' . '(' . date( 'D H:i:s', $list['StringyChat_time'] ) . ') ' . '</span>' . '<b>' . $list['StringyChat_name'] . '</b>' . ' : ' . filterBadWords($list['StringyChat_message']) . '<br />' . '<p>'; } } // Load up the last few posts. The number to load is defined by the "ShowPostNum" variable. $result = mysql_query("SELECT * FROM ".$dbTable." ORDER BY StringyChat_time DESC LIMIT " . $ShowPostNum,$db); include("sort_widths.php"); while ($myrow = mysql_fetch_array($result)) { $msg = $myrow["StringyChat_message"]; // Convert the encoded line break into an actual <br> tag (thanks milahu) $msg = str_replace("c#lb", "<br>", $msg); // Convert the encoded image tag into a html tag $msg = eregi_replace("im#([a-z]{3})", "<img src=\"http://".$install_url."images/\\1.gif\" alt=\"emoticon\">",$msg); // split the lines $msg = htmlwrap($msg, $line_length); $result_wordswap = mysql_query("SELECT * FROM ".$WordBanTable,$db); while ($myrow_wordswap = mysql_fetch_array($result_wordswap)) { $the_word = $myrow_wordswap["word"]; $msg = ereg_replace($the_word, ":-x",$msg); } } ?> <? // end while /****** build the pagination links ******/ // range of num links to show $range = 3; // if not on page 1, don't show back links if ($currentpage > 1) { // show << link to go back to page 1 echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=1'><<</a> "; // get previous page num $prevpage = $currentpage - 1; // show < link to go back to 1 page echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage'><</a> "; } // end if // loop to show links to range of pages around current page for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) { // if it's a valid page number... if (($x > 0) && ($x <= $totalpages)) { // if we're on current page... if ($x == $currentpage) { // 'highlight' it but don't make a link echo " [<b>$x</b>] "; // if not current page... } else { // make it a link echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$x'>$x</a> "; } // end else } // end if } // end for // if not on last page, show forward and last page links if ($currentpage != $totalpages) { // get next page $nextpage = $currentpage + 1; // echo forward link for next page echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage'>></a> "; // echo forward link for lastpage echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages'>>></a> "; } // end if /****** end build pagination links ******/ ?><br> <html> <i>Type your Message here...</i>:<br></html> "; } else { <html> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="GET"> Username:<br> <input type="text" name="username" ><br> <input type="hidden" value="<?php echo $_SERVER['HTTP_X_MXIT_LOGIN']; ?>" name"userid" > <br><br> <input type="submit" value="Submit"> </form> </html> <? $usernames = $_GET['username']; $mid = $_GET['userid']; $sql0 = "INSERT INTO Users (username,mxitid) VALUES (\"$usernames\",\"$mid\")"; $result = mysql_query($sql0); ?> } I have been looking at this code most of the morning and do not have a clue what is wrong with the code. I am hoping its not a stupid mistake, can someone please help me out? thank you
<title>Inputing Travel Detials</title> <header> <h1 align="center"> Adding Travel Detials </h1> <body> <p> <center><img src="cyberwarfareimage1.png" alt="Squadron logo" style="width:200px;height:200px" style="middle"></center> <table border="1"> <tr> <td><a href="index.php"> Home Page </a></td> <td><a href="administratorhomepage.html">Administrator Home Page </a></td> <td><a href="viewhomepage.html">View Home Page </a></td> <td><a href="Inputhomepage.html">Input Home Page </a></td> <td><a href="traveldetials.html">Enter More Travel Detials </a></td> </table> </p> <?php include "connection.php"; $Applicant_ID = $_POST["Applicant_ID"]; $Method_Of_Travel = $_POST["Method_Of_Travel"]; $Cost = $_POST["Cost"]; $ETA = $_POST["ETA"]; $Main_Gate_Advised = $_POST["Main_Gate_Advised"]; $query = ("UPDATE `int_board_applicant` SET `Method_Of_Travel`=`$Method_Of_Travel', `Cost`=`$Cost', `ETA`='$ETA', `Main_Gate_Advised`='$Main_Gate_Advised' WHERE `Applicant_ID`='$Applicant_ID'"); $result = mysqli_query($dbhandle, $query) or die(mysqli_error($dbhandle)); if($result){ echo "Success!"; } else{ echo "Error."; } // successfully insert data into database, displays message "Successful". if($query){ echo "Successful"; } else { echo "Data not Submitted"; } //closing the connection mysqli_close($dbhandle) ?> Ok this is puzzleing. I am geting "Could not delete data: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1' at line 1". but its is deleting the entry that needs to be removed. The "1" is the entry. Just not sure what is causing the error. I do have another delete php but I have put that on the back burning for the time being.
<?php $con = mysqli_connect("localhost","user","password","part_inventory"); // Check connection if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } else { $result = mysqli_query($con, "SELECT * FROM amp20 "); $amp20ptid = $_POST['amp20ptid']; // escape variables for security $amp20ptid = mysqli_real_escape_string($con, $_POST['amp20ptid']); mysqli_query($con, "DELETE FROM amp20 WHERE amp20ptid = '$amp20ptid'"); if (!mysqli_query($con, $amp20ptid)); { die('Could not delete data: ' . mysqli_error($con)); } echo "Part has been deleted to the database!!!\n"; mysqli_close($con); } ?> Hi guys
I have this code below and all works fine when submitting this online application apart from when someone types either ' # & into one of the comment fields in which it throws up the error. Have tried various fixes from across the internet but no joy. Can anyone offer suggestions?
<?php
$con = mysql_connect("localhost:3306","root","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db('sfapp', $con);
$sql="INSERT INTO 'sfapp' ('surname_add','forename_add','dob_add','hometele_add','mobiletele_add','homeadd_add','siblings_add','schoolname_add','headname_add','schooladd_add','schooltele_add','schoolem_add','alevel_add','personstate_add','nameprovided_add','pe_add','se_add','PredGrade_Art','PredGrade_AScience','PredGrade_BusStudies','PredGrade_Electronics','PredGrade_EnglishLang','PredGrade_EnglishLit','PredGrade_French','PredGrade_German','PredGrade_Geog','PredGrade_Graphics','PredGrade_History','PredGrade_Maths','PredGrade_SepScience','PredGrade_ProductDesign','PredGrade_Spanish','PredGrade_Other','Gender_Male','Gender_Female','Sub_EnglishLit','Sub_Maths','Sub_FurtherMaths','Sub_Biology','Sub_Chemistry','Sub_Physics','Sub_French','Sub_German','Sub_Spanish','Sub_Geography','Sub_History','Sub_RE','Sub_FineArt','Sub_Business','Sub_Computing','Sub_GlobPersp','Sub_DramaAndTheatre','Sub_PE','Sub_Dance','Sub_Politics','Sub_Psychology','Sub_Sociology','readprospect_chk','Sib_Yes','Sib_No','Current_Student_Yes','Current_Student_No','I_Understand_chk','Current_Education_chk','Local_Care_chk','Staff_Cwhls_chk','Sub_Film')
VALUES
('$_POST[surname_add]','$_POST[forename_add]','$_POST[dob_add]','$_POST[hometele_add]','$_POST[mobiletele_add]','$_POST[homeadd_add]','$_POST[siblings_add]','$_POST[schoolname_add]','$_POST[headname_add]','$_POST[schooladd_add]','$_POST[schooltele_add]','$_POST[schoolem_add]','$_POST[alevel_add]','$_POST[personstate_add]','$_POST[nameprovided_add]','$_POST[pe_add]','$_POST[se_add]','$_POST[PredGrade_Art]','$_POST[PredGrade_AScience]','$_POST[PredGrade_BusStudies]','$_POST[PredGrade_Electronics]','$_POST[PredGrade_EnglishLang]','$_POST[PredGrade_EnglishLit]','$_POST[PredGrade_French]','$_POST[PredGrade_German]','$_POST[PredGrade_Geog]','$_POST[PredGrade_Graphics]','$_POST[PredGrade_History]','$_POST[PredGrade_Maths]','$_POST[PredGrade_SepScience]','$_POST[PredGrade_ProductDesign]','$_POST[PredGrade_Spanish]','$_POST[PredGrade_Other]','$_POST[Gender_Male]','$_POST[Gender_Female]','$_POST[Sub_EnglishLit]','$_POST[Sub_Maths]','$_POST[Sub_FurtherMaths]','$_POST[Sub_Biology]','$_POST[Sub_Chemistry]','$_POST[Sub_Physics]','$_POST[Sub_French]','$_POST[Sub_German]','$_POST[Sub_Spanish]','$_POST[Sub_Geography]','$_POST[Sub_History]','$_POST[Sub_RE]','$_POST[Sub_FineArt]','$_POST[Sub_Business]','$_POST[Sub_Computing]','$_POST[Sub_GlobPersp]','$_POST[Sub_DramaAndTheatre]','$_POST[Sub_PE]','$_POST[Sub_Dance]','$_POST[Sub_Politics]','$_POST[Sub_Psychology]','$_POST[Sub_Sociology]','$_POST[readprospect_chk]','$_POST[Sib_Yes]','$_POST[Sib_No]','$_POST[Current_Student_Yes]','$_POST[Current_Student_No]','$_POST[I_Understand_chk]','$_POST[Current_Education_chk]','$_POST[Local_Care_chk]','$_POST[Staff_Cwhls_chk]','$_POST[Sub_Film]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
?>
<?php
//if "email" variable is filled out, send email
if (isset($_REQUEST['pe_add'])) {
//Email information
$admin_email = $_REQUEST['pe_add'];
$forename = $_REQUEST['forename_add'];
$email = "autoreply@testing.com";
$subject = "Application";
$desc =
"Dear $forename
Thank you for submitting your online application, we will be in touch shortly.
"
;
//send email
mail($admin_email, "$subject", "$desc", "From:" . $email);
//Email response
echo "Thank you for contacting us!";
}
//if "email" variable is not filled out, display the form
else {
?>
If you are seeing this, you need to go back and fill out the Personal Email section!
<?php
}
header("location:complete.php");
mysql_close($con)
?>
Thanks in advance.
Hi.. I create mysql syntax for query testing before i input to my php code here is my mysql code: Code: [Select] set @t = 0; set @rqty=31968; SELECT LOT_CODE as code, DATE_ENTRY, CASE WHEN @t+OUTPUT_QTY > @rqty THEN @rqty -@t ELSE OUTPUT_QTY END as qty, @t := @t + d.OUTPUT_QTY as cumulative FROM dipping d WHERE SUBSTR(LOT_CODE, 9,4) = 'P28' AND (@t < @rqty); and i attach the sample output of the above query. Now that query test is work i will input that code to my php codes. $sql = "SELECT SKUCode, Materials, Comp, Qty FROM bom WHERE SKUCode = '$SKUCode'"; $res = mysql_query($sql, $con); ($row = mysql_fetch_assoc($res)); $Materials = $row['Materials']; $Qty = $row['Qty']; $Comp = $row['Comp']; //P28 //-----Compute Req Qty and Save to table---// $ReqQty = $Qty * $POReq; // 31968 $sql = "UPDATE bom SET ReqQty = '$ReqQty' WHERE SKUCode = '$SKUCode' AND Materials = '$Materials'"; $resReqQty = mysql_query($sql, $con); $t = 0; $sql = "SELECT LOT_CODE as code, DATE_ENTRY, CASE WHEN $t+OUTPUT_QTY > $ReqQty THEN $ReqQty -$t ELSE OUTPUT_QTY END as qty, $t := $t + d.OUTPUT_QTY as cumulative FROM dipping d WHERE SUBSTR(LOT_CODE, 9,4) = '$Comp' AND ($t < $ReqQty)"; when I echo the query: I got this: SELECT LOT_CODE as code, DATE_ENTRY, CASE WHEN 0+OUTPUT_QTY > 31968 THEN 31968 -0 ELSE OUTPUT_QTY END as qty, 0 := 0 + d.OUTPUT_QTY as cumulative FROM dipping d WHERE SUBSTR(LOT_CODE, 9,4) = 'P28' AND (0 < 31968) then I run it to the sql and I got an error: Error Code : 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':= 0 + d.OUTPUT_QTY as cumulative FROM dipping d WHERE SUBSTR(LOT_CODE, 9,4) = '' at line 1 (0 ms taken) Any help is highly appreciated Thank you so much Which of the below syntax is the better to be using? $bal = 100; if($bal > 100) { echo "you have over 100 pounds; } else { echo "you have less than 100 pounds"; } if ($bal > 100); echo "you have over than 100"; else ; echo "you have less than 100"; endif; The issue is there seems to be NO syntax error. 1. There is no relevant code before or after this line. 2. Yes, one would think a ! should be there as did I (I didn't write the code), however, even with the ! it still gives the same error. if (function_exists('gzcompress')) die(FUNCTION_NOT_FOUND); is giving me a syntax error, unexpected 'if', expecting 'function' or 'const' I am updating this code from PHP5.3 to PHP7.4 and I can't figure out what the syntax problem is since PHP allows this. I am using Eclipse PHP to do the conversion. I really appreciate you guys. Could you guys help me out with a little syntax trouble. <?php $id=$_POST['id']; $db="prayers"; $link = mysql_connect('localhost', 'root' , ''); if (! $link) die(mysql_error()); mysql_select_db($db , $link) or die("Select Error: ".mysql_error()); $rt=mysql_query($query); echo mysql_error(); while($nt=mysql_fetch_array($rt)){ $result=mysql_query( $query = "SELECT howmanyprayed from prayerwall BY ". $id ."" $new_val = $row['howmanyprayed'] + 1; "INSTERT $new_val into prayerwall ( howmanyprayed) VALUES ( '$new_val')") or die("Insert Error: ".mysql_error()); mysql_close($link); ?> It's a button that's like the facebook "like" button. It's submitting a form through a button, but I'm getting this error when I submit. Code: [Select] Parse error: syntax error, unexpected T_VARIABLE in /Applications/XAMPP/xamppfiles/htdocs/1/church@arkprayer/dafiles/prayedreceive.php on line 18 Here's the form submit button <FORM METHOD=LINK ACTION=prayedreceive.php> <INPUT TYPE=HIDDEN NAME=clickprayed value=$nt[id]> <INPUT TYPE=submit VALUE=Prayed> #$nt[id] </FORM></br></br>"; I really appreciate any help. I just came up with a line of code that I am not able to understand what's it doing. The code is: Code: [Select] function cost() { return $this->costStrategy->cost($this); } here costStrategy is a class property which holds a reference to the object of type CostStrategy class and cost() is a method defined in CostStrategy. Code: [Select] <?php /* Register footer widget */ if (function_exists('register_footercounter') ) register_footercounter(array( 'before_widget' => '', 'after_widget' => '', 'before_title' => '', 'after_title' => '', )); ?> How exactly does this syntax work. I am not use to seeing this. It is an if statement without brackets. It uses a function inside of it with an array. So, I do not exactly understand what is happening here. I have used php for a long time and just now started working with Wordpress awhile back, and reviewing how to do themes, and I am seeing this kind of funky syntax all over the place. Thanks again. Hi, i,m trying to echo a "a href" based on the language session of my page like this: Code: [Select] ?php if ($_SESSION['session_idioma'])=="eng" { echo '<a href="preordering.php"><img src="img/top_banner_'.$_SESSION['session_idioma'].'.jpg" width="744" height="182"></a>'; } { else echo '<a href="ordering.php"><img src="img/top_banner_'.$_SESSION['session_idioma'].'.jpg" width="744" height="182"></a>'; }?>but I'm getting a blank page wit no errors...must be a syntax error that I can't spot... Hi, I'm trying to redirect like this: Code: [Select] header("Location: PC_images_display.php?imagenupdated=true&id_categoria = $row_images_update_RS['id_categoria']"); } but the variable $row_images_update_RS['id_categoria'] is being passed and causes a 500 error...I know it must be a syntax error ut I can't figure it out... Thanks in advance Hi there, I was trying to modify the code from the tutorial "PHP Basic Database Handling" and the code uses something I haven't seen before, but looks intriguing. Can someone explain how to use this: echo <<<SOMELABEL stuff SOMELABEL; Or let me know why my code didn't work? The error is an unexpected end statement on the last line of the file. My Code: Code: [Select] <?php $mystring = $_GET['FirstLast']; if($mystring == "") { echo "You reached this page by mistake, click on the link in your email"; }else { //echo $mystring; // connect to db $conn = mysql_connect('localhost','user','pw') or trigger_error("SQL",E_USER_ERROR); $db = mysql_select_db('tsec',$conn) or trigger_error("SQL",E_USER_ERROR); $sql = "SELECT `First Name`, `Last Name`, `Title`, `Org Parameter 1`, `Org/Person Name`, `Attendee Parm Value 1`, `Attendee Parm Value 2`, `Attendee Parm Value 3`, `Attendee Parm Value 4`, `Attendee Parm Value 5`, `Attendee Parm Value 6`, `Attendee Parm Value 7`, `Attendee Parm Value 8` FROM `attendees` WHERE FirstLast = '$mystring'"; $result = mysql_query($sql,$conn) or trigger_error("SQL", E_USER_ERROR); $list = mysql_fetch_assoc($result); echo <<<LISTNAME <form action = '{$_SERVER['PHP_SELF']}' method = 'post'> <table border = '1'><tr><td colspan = '2'>{$list['First Name']} {$list['Last Name']}</td></tr> <tr><td>Title</td><td><input type = 'text' name = 'Title' value = {$list['Title']}</td></tr> </table></form> LISTNAME; mysql_close($conn); } ?> Thanks. hey all, here is the xml code Code: [Select] <title>Dogged determination</title> <link rel="alternate" href="http://video.news.com.au/1959670201/Dogged-determination" /> <author> <name>mr mittens</name> </author> now to parse this to get the title i would do this but what if i want the link? Code: [Select] <?php$feed = simplexml_load_file('http://video.news.com.au/feed.atom');$link = (string) $feed->entry->title;echo $link;?> but what do i do to get the 'link'? i tried link an that obviously didnt work. cheers nick Is this proper syntax? if (($news['accounttyperaw'] !== 0) || ($news['accounttyperaw'] !== 1)) In a piece of code like this: mysql_query("INSERT into users VALUES ('".$_POST['username']."', '".$_POST['password']."')") or die(mysql_error()); What is the difference between ('".$_POST['username'])."') (".$_POST['username']).') (.$_POST['username'].) and ($_POST['username']) ?? Will all four of these work? Does anyone know where in the PHP manual I can find explanation for these syntaxes? i would like to display statistics information and show this on a map with multiple markers i have initially created for a single marker the example is at http://www.sudhakargolakaram.co.in/files/stats.php for this i have written the following in the php file echo (' <script type="text/javascript" src="jquery-1.3.2.min.js"></script> <script src="maps api key"></script> <script src="jquery.googlemaps1.01.js"></script> '); $lat="-36.847385"; $lon="174.765735"; echo(' <script type="text/javascript"> $(document).ready(function() { $("#map_canvas").googleMaps({ markers: { latitude: '); echo $lat; echo(', longitude: '); echo $lon; echo(' } }); }); </script> '); ?> this is working fine however i would like to get the values of the latitude and longitude values from mysql using select query and pass the values of latitude and longitude to the javascript code using a while loop the code to display multiple markers is <script type="text/javascript"> $(document).ready(function() { $('#map_canvas').googleMaps({ markers: [{ latitude: 37.4416, longitude: -122.1516 },{ latitude: 37.4516, longitude: -122.1616 },{ latitude: 37.4566, longitude: -122.1666 }] }); }); </script> this multiple markers is quite different to single marker as this does not have },{ for the last marker in terms of the syntax of the php code how can i write the php code so that i will get the output in the browser as mentioned above for multiple markers thanks I'm trying to update each row in my table with $upoin. But doesn't. No errors shown but it dosen't update the database (table) with $upoin. $count1 = array_sum($count); $upoin = $count1; $query=mysql_query("SELECT * FROM table"); $rownum=mysql_num_rows($query); for($i=0;$i<$rownum;$i++) { $query=mysql_query("SELECT * FROM table LIMIT $i,1"); while($select=mysql_fetch_array($query)) { $update=mysql_query("UPDATE table SET cat_num=$upoin"); } } Help fix the code. Thanks, Ruth \-) Hi, I need to append a language session to a url and I am a bit confused on how to do it. What is wrong with this? Code: [Select] <?php require_once('header_'.echo ($_SESSION['session_idioma']).'.php'); ?> Thanks Hi, I am using this to output a limited amount of text from my DB: Code: [Select] <?php echo substr($row_texts_RS['descripcion_'.$_SESSION['session_idioma'].''],0,450).'<a href="detail.php"> ... read more</a>';?> as you can see I am also creating the link "read more" that takes you to detail.php. This works fine...but I need to also pass the record id to the detail page. I have tried this: Code: [Select] <?php echo substr($row_texts_RS['descripcion_'.$_SESSION['session_idioma'].''],0,450).'<a href="detail.php?id_item=$row_texts_RS['id_item']"> ... read more</a>';?>...but all I get is a blank page...what am I doing wrong? Thanks |